2

I'm trying to get an ESP8266 to work with Arduino by using PlatformIO. But, I get errors when importing SoftwareSerial.h

Tried: Arduino IDE, PlatformIO, Change baudrate, change port

How can I get SoftwareSerial to work with the ESP8266?

#include <SoftwareSerial.h>

SoftwareSerial BTserial(3, 1); // RX | TX

char Bluetooth_Name = ' ';

void setup() 
{
    // Arduino IDE serial monitor
    Serial.begin(9600);

    // HC-05 default serial speed for AT mode is 38400
    BTserial.begin(38400);  

    // Wait for hardware to initialize
    delay(1000);

    // Print debug string
}

void loop()
{

   // Keep reading from HC-05 and send to Arduino Serial Monitor
   if (BTserial.available())
   {
      reading = BTserial.read();
      Serial.println(reading);
   }

   // Keep reading from Arduino Serial Monitor and send to HC-05
   if (Serial.available())
   {
      reading = Serial.read();
      BTserial.write(reading);
   }
}

I want to use the SoftwareSerial without errors.


Error code:

Compiling .pio\build\huzzah\lib0be\EspSoftwareSerial_ID168\SoftwareSerial.cpp.o
In file included from C:\Users\Bart\.platformio\lib\EspSoftwareSerial_ID168\src/SoftwareSerial.h:27:0,
                 from C:\Users\Bart\.platformio\lib\EspSoftwareSerial_ID168\src\SoftwareSerial.cpp:23:
C:\Users\Bart\.platformio\lib\EspSoftwareSerial_ID168\src/circular_queue/circular_queue.h:144:10: error: expected ';' at end of member declaration
     bool IRAM_ATTR push(T&& val);
          ^
Juraj
  • 3,490
  • 4
  • 18
  • 25
Bart
  • 21
  • 1
  • 1
  • 2
  • Yes I used arduino core – Bart Aug 15 '19 at 09:17
  • I truly have no idea, I just saw it on the internet so i tried it. I don't even know what a baud rate is and I can't find anyone explaining it in a tutorial how to have an esp12s chip work with arduino. – Bart Aug 15 '19 at 11:10
  • take a look at this issue https://github.com/plerup/espsoftwareserial/issues/103, in these issue, they say that you need to use the latest git version of esp8266, not the pre-packaged version from arduino. – Hayi Nukman Aug 15 '19 at 12:05
  • 1
    It looks like you're using the hardware serial pins with the software serial port. Try using non-UART pins for the software serial connection. – stevieb Aug 16 '19 at 13:38

2 Answers2

2

Actually the standard software serial library didn't work for me with my NodeMCU v1.0... And in the rare cases when it worked, it was very limited. Maybe check out this library:

ESP 8266/32 Software Serial Library

dda
  • 6,030
  • 2
  • 25
  • 34
Luca
  • 89
  • 7
  • This library seems to work on my ESP8266. But it also uses a lot of memory, and the microcontroller randomly crashes. I'll try to play a bit with buffer size and see it if helps. – Eric Duminil Mar 23 '22 at 19:56
0

in platformio.ini you can add the following line to choose a specific version which compiles with the latest released 8266 platform

lib_deps_external =
  plerup/espsoftwareserial#5.0.3 ; this version compiles with a standard 8266 platform

Using this way the code is directly fetched from github.

Michael Dreher
  • 1,369
  • 11
  • 17