Hello together,
since I am trying to get this to work now for a few days and have read nearly any thread that I could find regading this topic, I try to get some new Ideas to this.
Originally I was trying to read serial data from a scale. Since I was not able to get correct Symbols to show in my Serial Monitor I went back a few Steps and now I am stuck at getting the MAX3232 to work at all.
When I run the Code below with pins 22 and 23 respectively 16 and 17 shorted, I get back the sent data from both Serial ports.
When I now connect the MAX3232 Module (this one) to GND, 3,3V and one of the Serial Ports and short the RS232 side data pins, I get no data back (I tried all combinations of RX/TX, but none is working)
I tried this with two MAX3232 Modules an both do the same ting. When I connect them to the serial output of the scale or a USB-Serial Adapter I see that the MAX3232 is reading Data, but I just get squares in my SerialMonitor, not the actual "readable" data.
// ESP32 serial1 and serial2 hardware loop back test
// see https://circuits4you.com/2018/12/31/esp32-hardware-serial2-example/
/* There are three serial ports on the ESP known as U0UXD, U1UXD and U2UXD.
*
* U0UXD is used to communicate with the ESP32 for programming and during reset/boot.
* U1UXD is unused and can be used for your projects. Some boards use this port for SPI Flash access though
* U2UXD is unused and can be used for your projects.
*/
#define RXD1 22
#define TXD1 23
#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_7E1, RXD1, TXD1);
Serial2.begin(9600, SERIAL_7E1, RXD2, TXD2);
Serial.println("ESP32 hardware serial test on Serial1 and Serial2");
Serial.println("Serial Txd is on pin: "+String(TX));
Serial.println("Serial Rxd is on pin: "+String(RX));
Serial.println("Serial1 Txd1 is on pin: "+String(TXD1));
Serial.println("Serial1 Rxd1 is on pin: "+String(RXD1));
Serial.println("Serial2 Txd2 is on pin: "+String(TXD2));
Serial.println("Serial2 Rxd2 is on pin: "+String(RXD2));
}
void loop() { //Choose Serial1 or Serial2 as required
while (Serial2.available()) {
Serial.println("Serial2 = " + Serial2.readStringUntil('\n'));
}
while (Serial1.available()) {
Serial.println("Serial1 = " + Serial1.readStringUntil('\n'));
}
while (Serial.available()) {
String s = Serial.readStringUntil('\n');
Serial1.print( s);
Serial2.print( s);
}
}
I hope anybody has an Idea what I should try to get any progress in my project,
thank you in advance!
