ESP32 with SoftwareSerial
micha6554 opened this issue · 6 comments
Its ESP32 with SoftwareSerial possible?
Or, its possible to use RX2 and TX2?
Thanks
Theoretically yes, why not...
but I've never tested it.
you can be first :)
Its from ESP32 the pin 16/17 RX2/TX2 Soft- or Hardwareserial?
don't ask me, I don't know, you have to understand it yourself
you must decide if you want to use the software or hardware implementation
Personally I do not recommend using swserial, especially for esp32 where we have 3 hardware uarts.
...so, for the test, if you have hwserial 2
- uncomment in SDM_Config_User.h:
#define USE_HARDWARESERIAL
- in sdm_simple/sdm_simple.ino example:
//#include <SoftwareSerial.h> // < comment out
#include <SDM.h>
//SoftwareSerial swSerSDM(13, 15); // < comment out
SDM sdm(Serial2, 9600, NOT_A_PIN, SERIAL_8N1, 16, 17); //config SDM
(of course, modify the baud rate if you have other than 9600)
basically if you use the default uart pins, then initialization may look simpler:
SDM sdm(Serial2, 9600, NOT_A_PIN)
Thanks reaper7!!!!
Its work!!
// *************************************************************************************************************
// modbus for SDM-120 Energiemesser
// https://github.com/reaper7/SDM_Energy_Meter
// Config unter https://github.com/reaper7/SDM_Energy_Meter/blob/master/SDM_Config_User.h (unkomment #define USE_HARDWARESERIAL !!!!!!!!!)
// *************************************************************************************************************
#define USE_HARDWARESERIAL // hardwareserial|softwareserial
#define BAUDRATE 2400 // 2400bps (SDM-120)
#define MAX3485_RE_DE_PIN GPIO18 // RE-DE pin
#define RX GPIO16
#define TX GPIO17
#include <SDM.h> // SDM library
SDM sdm(Serial2, BAUDRATE, MAX3485_RE_DE_PIN, SERIAL_8N1, RX, TX); // (Serial2, baudrate, MAX3485_RE_DE_PIN, SERIAL_8N1, RX, TX)
I'm glad to hear that :)
You are the first who confirmed :D