Hieromon/ESP8266

Compile error with Leonardo

esportsim opened this issue · 1 comments

Hi, if I select Leonardo board on Arduino IDE(v1.8.15) I have problem during compiling. If I select Arduino UNO I don't have any error.
The error is this:
/Users/carlo/Documents/Arduino/libraries/ESP8266-master/ESP8266.cpp:42:29: error: no matching function for call to 'ESP8266::ESP8266(Serial_&)' ESP8266 WiFi(_ESP8266_SERIAL); ^ In file included from /Users/carlo/Documents/Arduino/libraries/ESP8266-master/ESP8266.cpp:12:0: /Users/carlo/Documents/Arduino/libraries/ESP8266-master/ESP8266.h:166:2: note: candidate: ESP8266::ESP8266(_ESP8266_SERIAL_TYPE&) ESP8266(_ESP8266_SERIAL_TYPE &uart); ^~~~~~~ /Users/carlo/Documents/Arduino/libraries/ESP8266-master/ESP8266.h:166:2: note: no known conversion for argument 1 from 'Serial_' to '_ESP8266_SERIAL_TYPE& {aka HardwareSerial&}' /Users/carlo/Documents/Arduino/libraries/ESP8266-master/ESP8266.h:144:7: note: candidate: constexpr ESP8266::ESP8266(const ESP8266&) class ESP8266 { ^~~~~~~ /Users/carlo/Documents/Arduino/libraries/ESP8266-master/ESP8266.h:144:7: note: no known conversion for argument 1 from 'Serial_' to 'const ESP8266&' /Users/carlo/Documents/Arduino/libraries/ESP8266-master/ESP8266.h:144:7: note: candidate: constexpr ESP8266::ESP8266(ESP8266&&) /Users/carlo/Documents/Arduino/libraries/ESP8266-master/ESP8266.h:144:7: note: no known conversion for argument 1 from 'Serial_' to 'ESP8266&&' exit status 1

how can I solve this problem?
thank you very much

@esportsim Leonardo differs from Arduino UNO in that it uses a single ATmega32U4 microcontroller to execute sketches and also performs USB communication.
In Leonardo, the Serial class refers to a virtual serial driver between a PC and Leonardo via USB. Unlike traditional Arduino boards such as the Arduino Uno, this is not connected to pins 0 and 1. https://www.arduino.cc/reference/en/language/functions/communication/serial/
To use the hardware serial ports with Leonardo (pins 0 and 1, RX and TX), you must use the Serial1 class. Change the _ESP8266_SERIAL definition as Serial to Serial1.

ESP8266/ESP8266.h

Lines 55 to 58 in 89425c8

// _ESP8266_SERIAL macro defines the actual object of the serial class.
// If you want use other serial, the Serial would be changed along
// the implementation of the board. e.g. Serial1, Serial2, ...
#define _ESP8266_SERIAL Serial

Or switch to software serial.
https://github.com/Hieromon/ESP8266/wiki#softwareserial