-
Notifications
You must be signed in to change notification settings - Fork 267
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
UART0 pins enabled for ESPSoftwareSerial #134
Conversation
That changes tested and works fine. Was forced to do it because of issue plerup#133 So, now Im able to use 3x HW UART for communication with sensors and for minor diagnostics to PC maintained by SW Uart. It uses only TX, so, Im safe from issue 133 (it crashes in my config only on RX events). Sample code I sed for debug: ''' #define NO_GLOBAL_SERIAL // in sloeber need to add attribute in // project properties/arduino/Compiler options/Add for C and C++ // -DNO_GLOBAL_SERIAL #include <SoftwareSerial.h> #define PM_SERIAL_RX 35 // SDS #define PM_SERIAL_TX 32 // SDS #define PM2_SERIAL_RX 25 // PMS #define PM2_SERIAL_TX 26 // PMS #define GPS_SERIAL_RX 16 // UART2 #define GPS_SERIAL_TX 17 #define DEB_RX 3 #define DEB_TX 1 // Reminder: the buffer size optimizations here, in particular the isrBufSize that only accommodates // a single 8N1 word, are on the basis that any char written to the loopback SoftwareSerial adapter gets read // before another write is performed. Block writes with a size greater than 1 would usually fail. SoftwareSerial Serial; HardwareSerial serialSDS(0); HardwareSerial serialPMS(1); HardwareSerial serialGPS(2); void setup() { serialSDS.begin(9600, SERIAL_8N1, PM_SERIAL_RX, PM_SERIAL_TX); // for HW UART SDS serialPMS.begin(9600, SERIAL_8N1, PM2_SERIAL_RX, PM2_SERIAL_TX); // for HW UART PMS serialGPS.begin(9600, SERIAL_8N1, GPS_SERIAL_RX, GPS_SERIAL_TX); // for HW UART GPS gpio_pad_select_gpio(DEB_RX); gpio_pad_select_gpio(DEB_TX); //pinMode(DEB_RX, INPUT); //pinMode(DEB_TX, OUTPUT); Serial.begin(9600, SWSERIAL_8N1, DEB_RX, DEB_TX, false, 295, 11); Serial.println("\nSoftware serial test started"); for (char ch = ' '; ch <= 'z'; ch++) { Serial.write(ch); } Serial.println(""); } void loop() { //if (SerialSW.available() > 0) { // SerialSW.write(SerialSW.rea); // yield(); //} Serial.println("Hello"); serialSDS.println("serialSDS 0"); serialPMS.println("serialPMS 1"); serialGPS.println("serialGPS 2"); delay(100); yield(); } '''
@executer-uno #define NO_GLOBAL_SERIAL
#include <SoftwareSerial.h>
HardwareSerial Serial0(0);
SoftwareSerial swSerial;
void setup()
{
Serial0.begin(115200, SERIAL_8N1, D7, D8); // WEMOS D1 MINI ESP32 variant
while (!Serial0) {}
delay(500);
Serial0.println("This is HW Serial on D7/D8");
}
// Add the main program code into the continuous loop() function
void loop()
{
} But the PC serial terminal window, connecting to the ESP32 via USB, indicates that no such redirection has succeeded, because it shows:
|
Yes, that behaviour takes few hours for me ;) Just grab pin 1 and 3 to SW serial by |
Let me talk about HW serial sensor 3 with uart 0 uart 1 and uart 2 on esp32 nodemcu .. I'm trying to improve on uart0. Can uart0 be replaced by another pin using the serial software and gpio 1 and 3 fixed for. debug and device communication |
I have found error, Please help me; I:\PROJECT IOT\COBACOBA\COBACOBA.ino: In function 'void setup()': COBACOBA:41: error: no matching function for call to 'HardwareSerial::begin(int, SoftwareSerialConfig, int, int, bool, int, int)' Serial.begin(9600, SWSERIAL_8N1, DEB_RX, DEB_TX, false, 295, 11);
In file included from C:\Users\TARWI\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:154:0,
C:\Users\TARWI\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/HardwareSerial.h:58:10: note: candidate: void HardwareSerial::begin(long unsigned int, uint32_t, int8_t, int8_t, bool, long unsigned int)
C:\Users\TARWI\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/HardwareSerial.h:58:10: note: candidate expects 6 arguments, 7 provided exit status 1 |
Thanks for the research and POC in this PR. I'm releasing EspSoftwareSerial >= 6.7.0 containing the necessary changes - superseding this PR - to attach to RX/TX on ESP32. Here's the minimal MVCE:
Please not how |
That changes tested and works fine.
Was forced to do it because of issue #133
So, now Im able to use 3x HW UART for communication with sensors and for minor diagnostics to PC maintained by SW Uart. It uses only TX, so, Im safe from #133 (it crashes in my config only on RX events).
Sample code I sed for debug: