Skocz do zawartości

Problem z pinem MISO na nodeMCU


SOYER

Pomocna odpowiedź

2 minuty temu, SOYER napisał:

arduino ide, wersja 1.8.10

nie za stara ta wersja?? tez mialem problem na poczatku z esp wlasnie ze wzgledu na stara wersje..@ethanak mnie wtedy uswiadomil ze to bjest przyczyna moich problemow...druga sprawa to moze uzyj innej wetrsji plytki esp, masz wersje 30 pin czyli to co u mnie z tym ze ja uzywam ponizszej wersji i wszystko smiga zawsze...

 166940_Zrzutekranu2022-12-15201854.thumb.png.fdfd68c5958527873b68377664ae3c20.png

Link do komentarza
Share on other sites

@farmaceuta zmiana płytki na taka jak Twoja nie pomogło.

Nie aktualizowałem IDE z obawy przed problemami z ew. ponownym wgraniem starych szkiców.

To się aktualizuje, czy trzeba wgrać jak nowy program. Jak zachować stare szkice i biblioteki?

Jakieś inne rady przy wgrywaniu nowszej wersji IDE?

Link do komentarza
Share on other sites

Zarejestruj się lub zaloguj, aby ukryć tę reklamę.
Zarejestruj się lub zaloguj, aby ukryć tę reklamę.

jlcpcb.jpg

jlcpcb.jpg

Produkcja i montaż PCB - wybierz sprawdzone PCBWay!
   • Darmowe płytki dla studentów i projektów non-profit
   • Tylko 5$ za 10 prototypów PCB w 24 godziny
   • Usługa projektowania PCB na zlecenie
   • Montaż PCB od 30$ + bezpłatna dostawa i szablony
   • Darmowe narzędzie do podglądu plików Gerber
Zobacz również » Film z fabryki PCBWay

Ok, 1.8.19 wgrane, odpalone. WW. szkic:

#include "Arduino.h"
#include "DFRobotDFPlayerMini.h"

DFRobotDFPlayerMini myDFPlayer;

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600, SERIAL_8N1, 23, 19);
  Serial2.begin(9600);
  myDFPlayer.volume(10);
  delay(3000);
  myDFPlayer.play(1);  //Play the first mp3
  delay(2000);
  myDFPlayer.play(2);
  test_sim800_module();
}

void loop() {
updateSerial();
}

void test_sim800_module()
{
  Serial2.println("AT");
  updateSerial();
  Serial.println();
  Serial2.println("AT+CSQ");
  updateSerial();
  Serial2.println("AT+CCID");
  updateSerial();
  Serial2.println("AT+CREG?");
  updateSerial();
  Serial2.println("ATI");
  updateSerial();
  Serial2.println("AT+CBC");
  updateSerial();
  Serial2.println("AT+CLVL=95");
  updateSerial();
  Serial2.println("AT+CRSL=95");
  updateSerial();
/*Serial2.println("AT+CMIC= 0,14");
  updateSerial();
  Serial2.println("AT+CMIC= 1,14");
  updateSerial();
  Serial2.println("AT+CMIC= 2,14");
  updateSerial();
  Serial2.println("AT+CMIC= 3,14");
  updateSerial();*/
}
void updateSerial()
{
  delay(500);
  while (Serial.available())
  {
    Serial2.write(Serial.read());//Forward what Serial received to Software Serial Port
  }
  while (Serial2.available())
  {
    Serial.write(Serial2.read());//Forward what Software Serial received to Serial Port
  }
}

wgrany, info po wgraniu z IDE:

esptool.py v4.2.1
Serial port COM3
Connecting..............
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: c4:de:e2:10:73:5c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x0004bfff...
Compressed 18912 bytes to 13025...
Writing at 0x00001000... (100 %)
Wrote 18912 bytes (13025 compressed) at 0x00001000 in 0.5 seconds (effective 322.7 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 523.9 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 599.3 kbit/s)...
Hash of data verified.
Compressed 243872 bytes to 134499...
Writing at 0x00010000... (11 %)
Writing at 0x0001d588... (22 %)
Writing at 0x000247f6... (33 %)
Writing at 0x00029c4e... (44 %)
Writing at 0x0002efdf... (55 %)
Writing at 0x00037699... (66 %)
Writing at 0x0003f7e4... (77 %)
Writing at 0x00044dd2... (88 %)
Writing at 0x0004a555... (100 %)
Wrote 243872 bytes (134499 compressed) at 0x00010000 in 2.6 seconds (effective 738.8 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Efekt bez zmian, PANIC

... ... ...

leżę i kwiczę

Link do komentarza
Share on other sites

Ok, wykonałem pewną pracę, błąd chyba związany z biblioteka do dfplayera, bo komunikat panica:

12:08:46.955 -> d ⸮⸮W⸮⸮V⸮&,⸮	vGuru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
12:08:47.190 -> 
12:08:47.190 -> Core  1 register dump:
12:08:47.237 -> PC      : 0x400d13ac  PS      : 0x00060a30  A0      : 0x800d13fe  A1      : 0x3ffb2790  
12:08:47.330 -> A2      : 0x3ffc10c0  A3      : 0x00000000  A4      : 0x00000000  A5      : 0x00000001  
12:08:47.424 -> A6      : 0x00060c20  A7      : 0x00000001  A8      : 0x00000000  A9      : 0x00000007  
12:08:47.518 -> A10     : 0x00000000  A11     : 0x00060c23  A12     : 0x0000000a  A13     : 0x00000001  
12:08:47.612 -> A14     : 0x007b7f18  A15     : 0x003fffff  SAR     : 0x00000010  EXCCAUSE: 0x0000001c  
12:08:47.705 -> EXCVADDR: 0x00000000  LBEG    : 0x400ed6a8  LEND    : 0x400ed6b4  LCOUNT  : 0x00000000  
12:08:47.799 -> 
12:08:47.799 -> 
12:08:47.799 -> Backtrace:0x400d13a9:0x3ffb27900x400d13fb:0x3ffb27b0 0x400d1420:0x3ffb27d0 0x400d1166:0x3ffb27f0 0x400d1c62:0x3ffb2820 

ten sam komunikat zdekodowany przy pomocy narzędzia exeption decoder:

PC: 0x400d13ac
EXCVADDR: 0x00000000

Decoding stack results
0x400d13a9: DFRobotDFPlayerMini::sendStack() at D:\ARDUINO\projekty\libraries\DFRobotDFPlayerMini\DFRobotDFPlayerMini.cpp line 50
0x400d13fb: DFRobotDFPlayerMini::sendStack(unsigned char, unsigned short) at D:\ARDUINO\projekty\libraries\DFRobotDFPlayerMini\DFRobotDFPlayerMini.cpp line 67
0x400d1420: DFRobotDFPlayerMini::volume(unsigned char) at D:\ARDUINO\projekty\libraries\DFRobotDFPlayerMini\DFRobotDFPlayerMini.cpp line 312
0x400d1166: setup() at C:\Users\user\AppData\Local\Temp\arduino_modified_sketch_782360/DOMOFON_GSM_DFPLAYER.ino line 16
0x400d1c62: loopTask(void*) at C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\cores\esp32\main.cpp line 42

wreszcie plik cpp z tej biblioteki: niestety nie mogę wkleić tu pliku cpp, musicie go sami przekopiować do jakiegoś notepad++ by znać numery linii

/*!
 * @file DFRobotDFPlayerMini.cpp
 * @brief DFPlayer - An Arduino Mini MP3 Player From DFRobot
 * @n Header file for DFRobot's DFPlayer
 *
 * @copyright	[DFRobot]( http://www.dfrobot.com ), 2016
 * @copyright	GNU Lesser General Public License
 *
 * @author [Angelo](Angelo.qiao@dfrobot.com)
 * @version  V1.0.3
 * @date  2016-12-07
 */

#include "DFRobotDFPlayerMini.h"

void DFRobotDFPlayerMini::setTimeOut(unsigned long timeOutDuration){
  _timeOutDuration = timeOutDuration;
}

void DFRobotDFPlayerMini::uint16ToArray(uint16_t value, uint8_t *array){
  *array = (uint8_t)(value>>8);
  *(array+1) = (uint8_t)(value);
}

uint16_t DFRobotDFPlayerMini::calculateCheckSum(uint8_t *buffer){
  uint16_t sum = 0;
  for (int i=Stack_Version; i<Stack_CheckSum; i++) {
    sum += buffer[i];
  }
  return -sum;
}

void DFRobotDFPlayerMini::sendStack(){
  if (_sending[Stack_ACK]) {  //if the ack mode is on wait until the last transmition
    while (_isSending) {
      delay(0);
      available();
    }
  }

#ifdef _DEBUG
  Serial.println();
  Serial.print(F("sending:"));
  for (int i=0; i<DFPLAYER_SEND_LENGTH; i++) {
    Serial.print(_sending[i],HEX);
    Serial.print(F(" "));
  }
  Serial.println();
#endif
  _serial->write(_sending, DFPLAYER_SEND_LENGTH);
  _timeOutTimer = millis();
  _isSending = _sending[Stack_ACK];
  
  if (!_sending[Stack_ACK]) { //if the ack mode is off wait 10 ms after one transmition.
    delay(10);
  }
}

void DFRobotDFPlayerMini::sendStack(uint8_t command){
  sendStack(command, 0);
}

void DFRobotDFPlayerMini::sendStack(uint8_t command, uint16_t argument){
  _sending[Stack_Command] = command;
  uint16ToArray(argument, _sending+Stack_Parameter);
  uint16ToArray(calculateCheckSum(_sending), _sending+Stack_CheckSum);
  sendStack();
}

void DFRobotDFPlayerMini::sendStack(uint8_t command, uint8_t argumentHigh, uint8_t argumentLow){
  uint16_t buffer = argumentHigh;
  buffer <<= 8;
  sendStack(command, buffer | argumentLow);
}

void DFRobotDFPlayerMini::enableACK(){
  _sending[Stack_ACK] = 0x01;
}

void DFRobotDFPlayerMini::disableACK(){
  _sending[Stack_ACK] = 0x00;
}

bool DFRobotDFPlayerMini::waitAvailable(unsigned long duration){
  unsigned long timer = millis();
  if (!duration) {
    duration = _timeOutDuration;
  }
  while (!available()){
    if (millis() - timer > duration) {
      return false;
    }
    delay(0);
  }
  return true;
}

bool DFRobotDFPlayerMini::begin(Stream &stream, bool isACK, bool doReset){
  _serial = &stream;
  
  if (isACK) {
    enableACK();
  }
  else{
    disableACK();
  }
  
  if (doReset) {
    reset();
    waitAvailable(2000);
    delay(200);
  }
  else {
    // assume same state as with reset(): online
    _handleType = DFPlayerCardOnline;
  }

  return (readType() == DFPlayerCardOnline) || (readType() == DFPlayerUSBOnline) || !isACK;
}

uint8_t DFRobotDFPlayerMini::readType(){
  _isAvailable = false;
  return _handleType;
}

uint16_t DFRobotDFPlayerMini::read(){
  _isAvailable = false;
  return _handleParameter;
}

bool DFRobotDFPlayerMini::handleMessage(uint8_t type, uint16_t parameter){
  _receivedIndex = 0;
  _handleType = type;
  _handleParameter = parameter;
  _isAvailable = true;
  return _isAvailable;
}

bool DFRobotDFPlayerMini::handleError(uint8_t type, uint16_t parameter){
  handleMessage(type, parameter);
  _isSending = false;
  return false;
}

uint8_t DFRobotDFPlayerMini::readCommand(){
  _isAvailable = false;
  return _handleCommand;
}

void DFRobotDFPlayerMini::parseStack(){
  uint8_t handleCommand = *(_received + Stack_Command);
  if (handleCommand == 0x41) { //handle the 0x41 ack feedback as a spcecial case, in case the pollusion of _handleCommand, _handleParameter, and _handleType.
    _isSending = false;
    return;
  }
  
  _handleCommand = handleCommand;
  _handleParameter =  arrayToUint16(_received + Stack_Parameter);

  switch (_handleCommand) {
    case 0x3D:
      handleMessage(DFPlayerPlayFinished, _handleParameter);
      break;
    case 0x3F:
      if (_handleParameter & 0x01) {
        handleMessage(DFPlayerUSBOnline, _handleParameter);
      }
      else if (_handleParameter & 0x02) {
        handleMessage(DFPlayerCardOnline, _handleParameter);
      }
      else if (_handleParameter & 0x03) {
        handleMessage(DFPlayerCardUSBOnline, _handleParameter);
      }
      break;
    case 0x3A:
      if (_handleParameter & 0x01) {
        handleMessage(DFPlayerUSBInserted, _handleParameter);
      }
      else if (_handleParameter & 0x02) {
        handleMessage(DFPlayerCardInserted, _handleParameter);
      }
      break;
    case 0x3B:
      if (_handleParameter & 0x01) {
        handleMessage(DFPlayerUSBRemoved, _handleParameter);
      }
      else if (_handleParameter & 0x02) {
        handleMessage(DFPlayerCardRemoved, _handleParameter);
      }
      break;
    case 0x40:
      handleMessage(DFPlayerError, _handleParameter);
      break;
    case 0x3C:
    case 0x3E:
    case 0x42:
    case 0x43:
    case 0x44:
    case 0x45:
    case 0x46:
    case 0x47:
    case 0x48:
    case 0x49:
    case 0x4B:
    case 0x4C:
    case 0x4D:
    case 0x4E:
    case 0x4F:
      handleMessage(DFPlayerFeedBack, _handleParameter);
      break;
    default:
      handleError(WrongStack);
      break;
  }
}

uint16_t DFRobotDFPlayerMini::arrayToUint16(uint8_t *array){
  uint16_t value = *array;
  value <<=8;
  value += *(array+1);
  return value;
}

bool DFRobotDFPlayerMini::validateStack(){
  return calculateCheckSum(_received) == arrayToUint16(_received+Stack_CheckSum);
}

bool DFRobotDFPlayerMini::available(){
  while (_serial->available()) {
    delay(0);
    if (_receivedIndex == 0) {
      _received[Stack_Header] = _serial->read();
#ifdef _DEBUG
      Serial.print(F("received:"));
      Serial.print(_received[_receivedIndex],HEX);
      Serial.print(F(" "));
#endif
      if (_received[Stack_Header] == 0x7E) {
        _receivedIndex ++;
      }
    }
    else{
      _received[_receivedIndex] = _serial->read();
#ifdef _DEBUG
      Serial.print(_received[_receivedIndex],HEX);
      Serial.print(F(" "));
#endif
      switch (_receivedIndex) {
        case Stack_Version:
          if (_received[_receivedIndex] != 0xFF) {
            return handleError(WrongStack);
          }
          break;
        case Stack_Length:
          if (_received[_receivedIndex] != 0x06) {
            return handleError(WrongStack);
          }
          break;
        case Stack_End:
#ifdef _DEBUG
          Serial.println();
#endif
          if (_received[_receivedIndex] != 0xEF) {
            return handleError(WrongStack);
          }
          else{
            if (validateStack()) {
              _receivedIndex = 0;
              parseStack();
              return _isAvailable;
            }
            else{
              return handleError(WrongStack);
            }
          }
          break;
        default:
          break;
      }
      _receivedIndex++;
    }
  }
  
  if (_isSending && (millis()-_timeOutTimer>=_timeOutDuration)) {
    return handleError(TimeOut);
  }
  
  return _isAvailable;
}

void DFRobotDFPlayerMini::next(){
  sendStack(0x01);
}

void DFRobotDFPlayerMini::previous(){
  sendStack(0x02);
}

void DFRobotDFPlayerMini::play(int fileNumber){
  sendStack(0x03, fileNumber);
}

void DFRobotDFPlayerMini::volumeUp(){
  sendStack(0x04);
}

void DFRobotDFPlayerMini::volumeDown(){
  sendStack(0x05);
}

void DFRobotDFPlayerMini::volume(uint8_t volume){
  sendStack(0x06, volume);
}

void DFRobotDFPlayerMini::EQ(uint8_t eq) {
  sendStack(0x07, eq);
}

void DFRobotDFPlayerMini::loop(int fileNumber) {
  sendStack(0x08, fileNumber);
}

void DFRobotDFPlayerMini::outputDevice(uint8_t device) {
  sendStack(0x09, device);
  delay(200);
}

void DFRobotDFPlayerMini::sleep(){
  sendStack(0x0A);
}

void DFRobotDFPlayerMini::reset(){
  sendStack(0x0C);
}

void DFRobotDFPlayerMini::start(){
  sendStack(0x0D);
}

void DFRobotDFPlayerMini::pause(){
  sendStack(0x0E);
}

void DFRobotDFPlayerMini::playFolder(uint8_t folderNumber, uint8_t fileNumber){
  sendStack(0x0F, folderNumber, fileNumber);
}

void DFRobotDFPlayerMini::outputSetting(bool enable, uint8_t gain){
  sendStack(0x10, enable, gain);
}

void DFRobotDFPlayerMini::enableLoopAll(){
  sendStack(0x11, 0x01);
}

void DFRobotDFPlayerMini::disableLoopAll(){
  sendStack(0x11, 0x00);
}

void DFRobotDFPlayerMini::playMp3Folder(int fileNumber){
  sendStack(0x12, fileNumber);
}

void DFRobotDFPlayerMini::advertise(int fileNumber){
  sendStack(0x13, fileNumber);
}

void DFRobotDFPlayerMini::playLargeFolder(uint8_t folderNumber, uint16_t fileNumber){
  sendStack(0x14, (((uint16_t)folderNumber) << 12) | fileNumber);
}

void DFRobotDFPlayerMini::stopAdvertise(){
  sendStack(0x15);
}

void DFRobotDFPlayerMini::stop(){
  sendStack(0x16);
}

void DFRobotDFPlayerMini::loopFolder(int folderNumber){
  sendStack(0x17, folderNumber);
}

void DFRobotDFPlayerMini::randomAll(){
  sendStack(0x18);
}

void DFRobotDFPlayerMini::enableLoop(){
  sendStack(0x19, 0x00);
}

void DFRobotDFPlayerMini::disableLoop(){
  sendStack(0x19, 0x01);
}

void DFRobotDFPlayerMini::enableDAC(){
  sendStack(0x1A, 0x00);
}

void DFRobotDFPlayerMini::disableDAC(){
  sendStack(0x1A, 0x01);
}

int DFRobotDFPlayerMini::readState(){
  sendStack(0x42);
  if (waitAvailable()) {
    if (readType() == DFPlayerFeedBack) {
      return read();
    }
    else{
      return -1;
    }
  }
  else{
    return -1;
  }
}

int DFRobotDFPlayerMini::readVolume(){
  sendStack(0x43);
  if (waitAvailable()) {
    return read();
  }
  else{
    return -1;
  }
}

int DFRobotDFPlayerMini::readEQ(){
  sendStack(0x44);
  if (waitAvailable()) {
    if (readType() == DFPlayerFeedBack) {
      return read();
    }
    else{
      return -1;
    }
  }
  else{
    return -1;
  }
}

int DFRobotDFPlayerMini::readFileCounts(uint8_t device){
  switch (device) {
    case DFPLAYER_DEVICE_U_DISK:
      sendStack(0x47);
      break;
    case DFPLAYER_DEVICE_SD:
      sendStack(0x48);
      break;
    case DFPLAYER_DEVICE_FLASH:
      sendStack(0x49);
      break;
    default:
      break;
  }
  
  if (waitAvailable()) {
    if (readType() == DFPlayerFeedBack) {
      return read();
    }
    else{
      return -1;
    }
  }
  else{
    return -1;
  }
}

int DFRobotDFPlayerMini::readCurrentFileNumber(uint8_t device){
  switch (device) {
    case DFPLAYER_DEVICE_U_DISK:
      sendStack(0x4B);
      break;
    case DFPLAYER_DEVICE_SD:
      sendStack(0x4C);
      break;
    case DFPLAYER_DEVICE_FLASH:
      sendStack(0x4D);
      break;
    default:
      break;
  }
  if (waitAvailable()) {
    if (readType() == DFPlayerFeedBack) {
      return read();
    }
    else{
      return -1;
    }
  }
  else{
    return -1;
  }
}

int DFRobotDFPlayerMini::readFileCountsInFolder(int folderNumber){
  sendStack(0x4E, folderNumber);
  if (waitAvailable()) {
    if (readType() == DFPlayerFeedBack) {
      return read();
    }
    else{
      return -1;
    }
  }
  else{
    return -1;
  }
}

int DFRobotDFPlayerMini::readFolderCounts(){
  sendStack(0x4F);
  if (waitAvailable()) {
    if (readType() == DFPlayerFeedBack) {
      return read();
    }
    else{
      return -1;
    }
  }
  else{
    return -1;
  }
}

int DFRobotDFPlayerMini::readFileCounts(){
  return readFileCounts(DFPLAYER_DEVICE_SD);
}

int DFRobotDFPlayerMini::readCurrentFileNumber(){
  return readCurrentFileNumber(DFPLAYER_DEVICE_SD);
}

Więc co to będzie?

Zmienić bibliotekę do dfplayera, czy przerobić kod?

Link do komentarza
Share on other sites

20 minut temu, SOYER napisał:

nie mogę wkleić tu pliku cpp

s/mogę/wiem\x20jak/

Wrzucasz do zipa albo tgz i zamieszczasz.

Jest jakaś inna biblioteka do DF? Nie sprawdzałem... kiedyś napisałem swoją, ale korzysta z pinu BUSY. Musiałbym gdzieś się dogrzebać w archiwum...

Link do komentarza
Share on other sites

Jest, mam ją nawet zainstalowaną, sprwdzę czy zadziała. Najciekawsze, że szkice tylko obsługujące dfp z tą biblioteką działają bez problemu, może sie gryzie z innymi bibliotekami pod dowódzwtem esp32.

Link do komentarza
Share on other sites

26 minut temu, SOYER napisał:

może sie gryzie z innymi bibliotekami pod dowódzwtem esp32

By może - biblioteki pisane pod AVR-y wcale nie muszą gadać na ESP (co innego biblioteki pisane od razu z myślą o różnych mikrokontrolerach).

Link do komentarza
Share on other sites

(edytowany)

Cześć, więc tak, po bardzo niemiłym poranku i pracowitym przedpołudniu, wziąłem się za ten szkic. Krótko: działa.

Biblioteka od dfROBOT  dla dfplayera wyleciała, zastosowałem, którą już kiedyś instalowałem ale wydawała mi się skomplikowana i nie używałem. Dzisiaj byłem zmuszony i udało się. Współpracuje z ESP32, nie wywala PANIC błędu.

Druga sprawa, RFID, tak jak pisałeś @ethanak jeśli zastosowało się jeden pin reset, niepodpięty i zadeklarowany jako 255, to szkic raz działał, a raz nie(tzn. czytał tylko jeden czytnik). Po fizycznym dolutowaniu dwóch pinów RESET i uwzględnieniu tego w inicjalizacji, działa niezawodnie(mam nadzieję).

Aktualnie mam szkic ESP32 w którym współpracują SIM800L, DFPlayer i 2 szt czytnika RFID. Na razie ten szkic nic nie robi poza czytaniem kart, współpracą ręczną z sim i odpaleniem w SETUP dwóch sampli mp3.... ale działa i jestem zadowolony, że działa, bo już chciałem ty walnąć w kąt.

Poniżej szkic:

#include "Arduino.h"
#include <DFMiniMp3.h>
#include <SPI.h>
#include <MFRC522.h>
/////////////////RFID////////////
#define RST_1_PIN         34          // Configurable, see typical pin layout above
#define RST_2_PIN         35
#define SS_1_PIN        27        // Configurable, take a unused pin, only HIGH/LOW required, must be different to SS 2
#define SS_2_PIN        15 
  
#define NR_OF_READERS   2

byte rstPins[] = {RST_1_PIN, RST_2_PIN};
byte ssPins[] = {SS_1_PIN, SS_2_PIN};

MFRC522 mfrc522[NR_OF_READERS];

///////////DFP////////////////
class Mp3Notify
{
public:
  static void PrintlnSourceAction(DfMp3_PlaySources source, const char* action)
  {
    if (source & DfMp3_PlaySources_Sd) 
    {
        Serial.print("SD Card, ");
    }
    if (source & DfMp3_PlaySources_Usb) 
    {
        Serial.print("USB Disk, ");
    }
    if (source & DfMp3_PlaySources_Flash) 
    {
        Serial.print("Flash, ");
    }
    Serial.println(action);
  }
  static void OnError(uint16_t errorCode)
  {
    // see DfMp3_Error for code meaning
    Serial.println();
    Serial.print("Com Error ");
    Serial.println(errorCode);
  }
  static void OnPlayFinished(DfMp3_PlaySources source, uint16_t track)
  {
    Serial.print("Play finished for #");
    Serial.println(track);  
  }
  static void OnPlaySourceOnline(DfMp3_PlaySources source)
  {
    PrintlnSourceAction(source, "online");
  }
  static void OnPlaySourceInserted(DfMp3_PlaySources source)
  {
    PrintlnSourceAction(source, "inserted");
  }
  static void OnPlaySourceRemoved(DfMp3_PlaySources source)
  {
    PrintlnSourceAction(source, "removed");
  }
};

DFMiniMp3<HardwareSerial, Mp3Notify> mp3(Serial1);
void setup() {
  
  Serial.begin(9600);
  Serial1.begin(9600, SERIAL_8N1, 23, 19);
  Serial2.begin(9600);
  delay(3000);
  mp3.begin();
  mp3.setVolume(30);
      mp3.playMp3FolderTrack(1);  // sd:/mp3/0001.mp3
      waitMilliseconds(5000);
       Serial.println("track 2"); 
      mp3.playMp3FolderTrack(2); // sd:/mp3/0002.mp3
      waitMilliseconds(5000);
  SPI.begin(14,12,13);
      for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
        mfrc522[reader].PCD_Init(ssPins[reader], rstPins[reader]); // Init each MFRC522 card
        Serial.print(F("Reader "));
        Serial.print(reader);
        Serial.print(F(": "));
        mfrc522[reader].PCD_DumpVersionToSerial();
       }
  Serial.println("starting...");
  test_sim800_module();
}

void loop() {
updateSerial();
rfid();
}


void test_sim800_module()  //GSM
{
  Serial2.println("AT");
  updateSerial();
  Serial.println();
  Serial2.println("AT+CSQ");
  updateSerial();
  Serial2.println("AT+CCID");
  updateSerial();
  Serial2.println("AT+CREG?");
  updateSerial();
  Serial2.println("ATI");
  updateSerial();
  Serial2.println("AT+CBC");
  updateSerial();
  Serial2.println("AT+CLVL=95");
  updateSerial();
  Serial2.println("AT+CRSL=95");
  updateSerial();
/*Serial2.println("AT+CMIC= 0,14");
  updateSerial();
  Serial2.println("AT+CMIC= 1,14");
  updateSerial();
  Serial2.println("AT+CMIC= 2,14");
  updateSerial();
  Serial2.println("AT+CMIC= 3,14");
  updateSerial();*/
}
void updateSerial()  //GSM
{
  delay(500);
  while (Serial.available())
  {
    Serial2.write(Serial.read());//Forward what Serial received to Software Serial Port
  }
  while (Serial2.available())
  {
    Serial.write(Serial2.read());//Forward what Software Serial received to Serial Port
  }
}
void waitMilliseconds(uint16_t msWait)  //DFP
{
  uint32_t start = millis();
  
  while ((millis() - start) < msWait)
  {
    mp3.loop(); 
    delay(1);
  }
}
void rfid(){    //RFID
    for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
    // Look for new cards

    if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {
      Serial.print(F("Reader "));
      Serial.print(reader);
      // Show some details of the PICC (that is: the tag/card)
      Serial.print(F(": Card UID:"));
      dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size);
      Serial.println();
      Serial.print(F("PICC type: "));
      MFRC522::PICC_Type piccType = mfrc522[reader].PICC_GetType(mfrc522[reader].uid.sak);
      Serial.println(mfrc522[reader].PICC_GetTypeName(piccType));

      // Halt PICC
      mfrc522[reader].PICC_HaltA();
      // Stop encryption on PCD
      mfrc522[reader].PCD_StopCrypto1();
    } //if (mfrc522[reader].PICC_IsNewC
  } //for(uint8_t reader
}
void dump_byte_array(byte *buffer, byte bufferSize) {    /////RFID
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], HEX);
  }
}

Szczególnie zadowolony jestem z tego narzędzia Exeption Decoder, bez tego to bym nawet nie wiedział co za PANIC... ktoś już z tego korzystał? Do czego warto tego użyć, to zdaje się narzędzie do debugowania...

Edytowano przez SOYER
Link do komentarza
Share on other sites

59 minut temu, SOYER napisał:

ktoś już z tego korzystał? Do czego warto tego użyć, to zdaje się narzędzie do debugowania...

Ja korzystałem (na ESP8266 co prawda, ale używa się podobnie).

Dobrze Ci się zdaje, narzędzie do debugowania, i służy dokładnie do tego do czego użyłeś.

No, to teraz czekamy na resztę 🙂

 

Link do komentarza
Share on other sites

Dołącz do dyskusji, napisz odpowiedź!

Jeśli masz już konto to zaloguj się teraz, aby opublikować wiadomość jako Ty. Możesz też napisać teraz i zarejestrować się później.
Uwaga: wgrywanie zdjęć i załączników dostępne jest po zalogowaniu!

Anonim
Dołącz do dyskusji! Kliknij i zacznij pisać...

×   Wklejony jako tekst z formatowaniem.   Przywróć formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Twój link będzie automatycznie osadzony.   Wyświetlać jako link

×   Twoja poprzednia zawartość została przywrócona.   Wyczyść edytor

×   Nie możesz wkleić zdjęć bezpośrednio. Prześlij lub wstaw obrazy z adresu URL.

×
×
  • Utwórz nowe...

Ważne informacje

Ta strona używa ciasteczek (cookies), dzięki którym może działać lepiej. Więcej na ten temat znajdziesz w Polityce Prywatności.