Hi,
i'm trying to put an ESP32 (later it will be an Arduino) between an ebike controller and its display.
I first tried to listen their communication and it was all ok. The protocol is UART, i think it is at 9600 baud 8N1, but i'm not sure because i can see something readable (but different in from 9600) until 19200 baud. So, the first question is: how can i be sure of the protocol in use?
Then, i tried to put the ESP32 between the two controllers, TX_controller to RX1, RX_controller to TX1, TX_display to RX2, RX_display to TX2.
But it doesn't work.
The code i the default SerialPassthrough:
#define RXD1 18
#define TXD1 19
#define RXD2 16
#define TXD2 17
void setup() {
// Note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin);
//Serial.begin(115200);
Serial1.begin(9600, SERIAL_8N1, RXD1, TXD1);
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
}
void loop() { //Choose Serial1 or Serial2 as required
if (Serial1.available()) { // If anything comes in Serial (USB),
Serial2.write(Serial1.read()); // read it and send it out Serial1 (pins 0 & 1)
}
if (Serial2.available()) { // If anything comes in Serial1 (pins 0 & 1)
Serial1.write(Serial2.read()); // read it and send it out Serial (USB)
}
}
The bike controller is the XC836, while i don't know the display controller.
nikten:
i'm trying to put an ESP32 (later it will be an Arduino)
That seems a strange order of things. I imagine it would be easier to start with an Arduino - particularly a Mega which has 4 HardwareSerial ports
I first tried to listen their communication and it was all ok. The protocol is UART, i think it is at 9600 baud 8N1, but i'm not sure because i can see something readable (but different in from 9600) until 19200 baud. So, the first question is: how can i be sure of the protocol in use?
I find that very confusing. It reads as if you intended to write "can't see" and then I wonder what "it was all OK" refers to.
I putted my USB to TTL to read with my python script what is the behavior of Arduino (i use a Mega now ).
I noticed that when i turn on the display, it sends 0x00 to the arduino. But Arduino don't sends this to controller.
Can it be a problem of Serial.available()? That it returns false with a 0x00 incoming?