I have a project that pulls data from a solar charge controller using the controller's RS232 port and modbus. It works great on an ESP32 Wroom. But oddly it won't work on any of my ESP32 Rovers.
I'm using the same wiring, same RS232 to TTL board (exact same board, not an identical one), same everything.
It uses a second serial port, on pins 16 and 17, which on the Wroom are labelled RX2 and TX2.
I don't imagine anyone has any theories, or ways to get the Rover to work?
#include <HardwareSerial.h>
HardwareSerial MySerial2 (1);
#define RXD2 16
#define TXD2 17
void setup()
{
Serial.begin(115200);
Serial.println("Started!");
// create a second serial interface for modbus
//Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
MySerial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
int modbus_address = 255; // my Renogy Wanderer has an (slave) address of 255! Not in docs???
//node.begin(modbus_address, Serial2);
node.begin(modbus_address, MySerial2);
}
Well I'm embarassed to admit that changing the pins fixed it for me. Oops, I definitely should have tried that. And thank you.
I used pins 13 and 14, which works on both my Wroom and Rover boards with no other mods to my original code.
#define RXD2 13
#define TXD2 14
void setup()
{
Serial.begin(115200);
Serial.println("Started!");
// create a second serial interface for modbus
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
int modbus_address = 255; // my Renogy Wanderer has an (slave) address of 255! Not in docs???
node.begin(modbus_address, Serial2);
}
I don't have an Arduino board to test with at the moment, any thoughts on whether this would/should work on an Arduino Uno for example?
I'm wondering if an Arduino Uno would be able to use Serial for serial monitor, and a second serial interface for RS232/modbus (as I'm currently doing with an ESP32).