Bonjour, pourriez vous m'aider à comprendre ce que le compilateur me demande de faire?
J'utilise un D1 mini et dans l'IDE j'ai choisi Generic ESP8266 Module.
Le probleme semble venir de la déclaration des pins du 8266, mais je ne vois pas quoi mettre d'autre.
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:117:15: error: 'D6' was not declared in this scope
117 | #define RXPin D6 // Serial Receive pin
| ^~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:119:28: note: in expansion of macro 'RXPin'
119 | SoftwareSerial RS485Serial(RXPin, TXPin);
| ^~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:118:15: error: 'D7' was not declared in this scope
118 | #define TXPin D7 // Serial Transmit pin
| ^~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:119:35: note: in expansion of macro 'TXPin'
119 | SoftwareSerial RS485Serial(RXPin, TXPin);
| ^~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino: In function 'int sendModbus(uint8_t*, byte, modbusResponse*)':
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:114:42: error: 'D5' was not declared in this scope
114 | #define SERIAL_COMMUNICATION_CONTROL_PIN D5 // Transmission set pin
| ^~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:561:15: note: in expansion of macro 'SERIAL_COMMUNICATION_CONTROL_PIN'
561 | digitalWrite(SERIAL_COMMUNICATION_CONTROL_PIN, RS485_TX);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino: In function 'int listen(modbusResponse*)':
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:644:24: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
644 | resp->errorMessage = "Response too short";
| ^~~~~~~~~~~~~~~~~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:649:24: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
649 | resp->errorMessage = "Valid data frame";
| ^~~~~~~~~~~~~~~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:654:24: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
654 | resp->errorMessage = "Error: invalid data frame";
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino: In function 'void setup()':
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:114:42: error: 'D5' was not declared in this scope
114 | #define SERIAL_COMMUNICATION_CONTROL_PIN D5 // Transmission set pin
| ^~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:854:10: note: in expansion of macro 'SERIAL_COMMUNICATION_CONTROL_PIN'
854 | pinMode(SERIAL_COMMUNICATION_CONTROL_PIN, OUTPUT);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exit status 1
Compilation error: 'D6' was not declared in this scope
Comme le module existe, il faut le choisir afin que la définition de la carte soit prise en compte, notamment le fait que les pins sont nommées par D0, D1, D2, ...
(l'ESP8266 n'a pas de bornes Dx, ce nommage est introduit par certains fabricants de cartes, d'où la nécessité de selectionner une carte qui par exemple associe D6 au GPIO12)
autre solution : utiliser systématiquement les numéros de GPIO = remplacer par exemple D6 par 12 dans le code
Si je remplace par GPIO12 et GPIO13, erreur durant la compilation. J'ai bien sélectionné LOLIN(WEMOS) D1 R2 & mini.
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:117:15: error: 'GPIO12' was not declared in this scope; did you mean 'GPC12'?
117 | #define RXPin D6 // Serial Receive pin
| ^~~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:119:28: note: in expansion of macro 'RXPin'
119 | SoftwareSerial RS485Serial(RXPin, TXPin);
| ^~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:118:15: error: 'GPIO13' was not declared in this scope; did you mean 'GPC13'?
118 | #define TXPin D7 // Serial Transmit pin
| ^~~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:119:35: note: in expansion of macro 'TXPin'
119 | SoftwareSerial RS485Serial(RXPin, TXPin);
| ^~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino: In function 'int sendModbus(uint8_t*, byte, modbusResponse*)':
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:114:42: error: 'GPIO14' was not declared in this scope; did you mean 'GPC14'?
114 | #define SERIAL_COMMUNICATION_CONTROL_PIN D5 // Transmission set pin
| ^~~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:561:15: note: in expansion of macro 'SERIAL_COMMUNICATION_CONTROL_PIN'
561 | digitalWrite(SERIAL_COMMUNICATION_CONTROL_PIN, RS485_TX);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino: In function 'int listen(modbusResponse*)':
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:644:24: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
644 | resp->errorMessage = "Response too short";
| ^~~~~~~~~~~~~~~~~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:649:24: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
649 | resp->errorMessage = "Valid data frame";
| ^~~~~~~~~~~~~~~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:654:24: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
654 | resp->errorMessage = "Error: invalid data frame";
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino: In function 'void setup()':
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:114:42: error: 'GPIO14' was not declared in this scope; did you mean 'GPC14'?
114 | #define SERIAL_COMMUNICATION_CONTROL_PIN D5 // Transmission set pin
| ^~~~~~
/Users/franck/Downloads/Sofar2mqtt/Sofar2mqtt.ino:854:10: note: in expansion of macro 'SERIAL_COMMUNICATION_CONTROL_PIN'
854 | pinMode(SERIAL_COMMUNICATION_CONTROL_PIN, OUTPUT);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exit status 1
Compilation error: 'GPIO12' was not declared in this scope; did you mean 'GPC12'?
cette ligne positionne la broche chargée du signal Reset en GPIO0 alias D3
SDA et SCL sont définis par ailleurs leur emplacement étant imposé dans les cas de l'ESP8266
Rien à ajouter à ce sujet dans le code
Pour information : quand tu sélectionnes une des cartes D1 Mini dans l'IDE voici le fichier qui est ajouté au code à ton sketch : (on y voit l'attribution des alias aux GPIOs)
Dans l'exemple c'est le Shields OLED qui est utilisé, moi j'ai ce model et il n'a pas de broche de RESET comme on peu le voir donc je suppose que c'est pour sa qu'il ne fonctionne pas?
J'ai récupéré un pc sous Windows 10, IDE 2.2.1, même carte 8266, même choix LOLIN(WEMOS) .... et la pas d'erreur dans le compilateur, nul besoin de modifier les pins, etc ...
Par contre une fois uploader, le sketch ne fonctionne pas, l'ESP ne ce connecte pas au wifi et l'oled affiche une constellation de pixel blanc. J'ai testé avec un sketch de démo l'ESP et l'OLED et tout fonctionne.
Si vous pouvez me guider pour me dire ou je pêche je suis preneur