Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 board - SoftwareSerial #4

Open
dl5dla opened this issue Apr 7, 2021 · 3 comments
Open

ESP32 board - SoftwareSerial #4

dl5dla opened this issue Apr 7, 2021 · 3 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@dl5dla
Copy link

dl5dla commented Apr 7, 2021

Hi Pavel,
the code does not successfully compile for ESP32 board. Error message is

src/main.cpp:14:28: fatal error: SoftwareSerial.h: No such file or directory

It looks like that SoftwareSerial is not supported out of the box for ESP32 boards. May be there are some special libraries for SoftwareSerial on ESP32, but nevertheless it might be more efficient to use one of the three available UARTs (UART0, UART1 and UART2) of the ESP32. I am wondering how to adapt the code accordingly but I am not sure (and may be not skilled enough) to start.

@stdevPavelmc stdevPavelmc self-assigned this Apr 7, 2021
@stdevPavelmc stdevPavelmc added bug Something isn't working enhancement New feature or request labels Apr 7, 2021
@stdevPavelmc
Copy link
Owner

Thanks for the bug report and the idea, it can be extended to the ESP8266 I think...

I will take a peek on it on the weekend.

Thanks

@dl5dla
Copy link
Author

dl5dla commented Apr 19, 2021

I made some quick and dirty changes to support UART2 of the ESP32. Code needs to be cleaned up.

in ft817.h:

line 286:

#define HAVE_ESP 1
#include <Arduino.h>
#ifndef HAVE_ESP
#include <SoftwareSerial.h>
#endif

line 335:

class FT817
{
public:
FT817();
// setup
#ifdef HAVE_ESP
void begin(int baud,int handshake,int rx,int tx);
#else
void setSerial(SoftwareSerial portInfo); // load the softserial into the FT817
void begin(int baud); // set the baudrate of the softserial lib
#endif
// toggles

in ft817.cpp:

line 29:

#include "ft817.h"

#ifdef HAVE_ESP
#include <HardwareSerial.h>
HardwareSerial rigCat(2);
#else
#include <SoftwareSerial.h>
extern SoftwareSerial rigCat(12, 11); // rx,tx
#endif

#define dlyTime 5 // delay (in ms) after serial writes

FT817::FT817(){ } // nothing to do when first instanced

/****** SETUP ********/

#ifndef HAVE_ESP
// Setup software serial with user defined input
// from the Arduino sketch (function, though very slow)
void FT817::setSerial(SoftwareSerial portInfo)
{
rigCat = portInfo; // just commented out for ESP - no idea how to adapt for ESP
}
#endif

// similar to Serial.begin(baud); command
#ifdef HAVE_ESP
void FT817::begin(int baud,int handshake,int rx,int tx)
{
rigCat.begin(baud,handshake,rx,tx);
}
#else
void FT817::begin(int baud)
{
rigCat.begin(baud);
}
#endif

in main.cpp:

line 14:

#include "ft817.h"

#ifndef HAVE_ESP
#include <SoftwareSerial.h>
#endif

line 29:

void setup()
{
Serial.begin(9600,SERIAL_8N1,12,13);
#ifdef HAVE_ESP
radio.begin(9600,SERIAL_8N1,22,23);
#else
radio.begin(9600);
#endif

Serial.println("Starting...");

}

@dl5dla dl5dla closed this as completed Apr 19, 2021
@dl5dla dl5dla reopened this Apr 19, 2021
@stdevPavelmc
Copy link
Owner

Sorry for the long delay...

I will be playing with this this weekend and will try to simulate here an fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants