Waveshare ESP32S3-POE-ETH with rain sensor RG15, cannot get serial comms going

Hi,

The ESP32 is not communicating via UART with the RG15. Maybe someone could spot where this is running off the rails?

Much of my understanding has come from this excellent project: GitHub - sensebox/rg15-arduino-lib: Library for Hydreon RG15 and arduino, made to fix problems with old hydreon lib and original lib. · GitHub.

For this project the RG15 is powered via the ESP32’s VSYS and GND pins.

When the ESP32’s power comes on the RG15 boots a few seconds later with its three LED flashes, indicating it is ready to go.

In the sketch UART2 is connected to the RG15 like this

#define SerialSensor Serial2 // UART = UART2
#define GPIO16 32 /*RX*/
#define GPIO17 34 /*TX*/
// Serial2 Pin Mapping
// • RX (Receive): GPIO 16 (physical 32, white wire, connected to RG15 4 - Serial OUT)
// • TX (Transmit): GPIO 17 (physical 34, green wire, connected to RG15 5 - Serial IN)
// • VSYS (physical 39, red wire supplies line voltage (5v) from USB or PoE connection)
// • GND (physical 38, black)

void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println(" Serial Setup done...");  
  SerialSensor.begin(9600, SERIAL_8N1, /*RX*/GPIO16, /*TX*/GPIO17);
  while (!SerialSensor);
  Serial.println(" SerialSensor Setup done...");
}

SeriaSensor.begin seems to return successfully. Later in the sketch a command is sent to the RG15 like this

SerialSensor.println(data); // Send to sensor This appends CRLF

And then later the sketch looks for a response from the RG15 like this

  while (SerialSensor.available()) {
    data = SerialSensor.readString();
    Serial.print(" recieved: ");
    Serial.print(data);
  }

But SerialSensor.available() never returns true so the command never made it or it never responds or …

The wiring between the TX and DX connections has been verified several times. Both UART0 and the RG15 are set to 9600 Baud.

Thank you in advance for any thoughts as to where this might be running off the rails!

WoodManEXP (Robert)

Here is a pic of the setup:

I moved your topic to an appropriate forum category @woodmanexp.

In the future, when creating a topic please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Headers soldered?

Magic numbers from where?

What are these "physical pins" and what are you trying to do here?
Your definition uses gpio32 for RX, which your board doesn't have exposed (that is used for flash/psram).

Magic numbers are from the ESP32S3 pin diagram

Am I reading the diagram wrong?

So where is your magic 32? Gpio16?
You use 16 on your code. That's it.
SerialSensor.begin(9600, SERIAL_8N1, 16, 17);

Completely. The physical header pin number has no relationship with the IO number.

Hi Kitaabnagri Reader, TY for the speedy and considered response. It seems most plausible!

Few questions please

  • Looks like the MAX3232 boards can be powered by the MCU (VSYS and GND)?
  • Can that power be made to pass through the MAX3232 board via the RS232 connection to the sensor on the other side or will the sensor require another power source/additional wiring?
  • The sensor does not have an RS232 connector. What might you suggest as a way to connect a MAX3232 board to the sensor.

TY!

Except that information is incorrect.
Documentation states clearly that serial communication is done at 3.3V.
So no MAX here!

Seems most plausible does not correlate with being correct.

did you try a simple loopback to check the serial is working, e.g.

// Waveshare ESP32-S3 ETH Development Board Serial1 test - for loopback test connect pin GPIO17 U1TXD to pin GPIO18 U1RXD"
// ss https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/_images/ESP32-S3_DevKitC-1_pinlayout_v1.1.jpg

#define RXD1 48
#define TXD1 47

void setup() {
  // initialize both serial ports:
  Serial.begin(115200);
  delay(2000);
  Serial1.begin(9600, SERIAL_8N1, RXD1, TXD1);
  Serial.println();
  Serial.printf("\n\nWaveshare ESP32-S3 ETH Development Board serial1  test pin GPIO%d U1TXD pin GPIO%d U1RXD\n",
                                TXD1, RXD1);
  Serial.printf("   for loopback test connect pin GPIO%d U1TXD to pin GPIO%d U1RXD\n", TXD1, RXD1);
  Serial.printf("RS232: ESP32S3 pin %d RXD1 to TTL/RS232 Rx and pin %d TXD1 to TTL/RS232 Tx\n", RXD1, TXD1);
  Serial.printf("RS232 - loopback connect 9-pin D-type pin 2 Tx to pin 3 Rx\n");
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
  }

  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();
    //Serial.write(inByte);
    Serial1.write(inByte);
  }
}

Serial monitor output with GPIO47 connected to GPIO48

Waveshare ESP32-S3 ETH Development Board serial1  test pin GPIO47 U1TXD pin GPIO48 U1RXD
   for loopback test connect pin GPIO47 U1TXD to pin GPIO48 U1RXD
RS232: ESP32S3 pin 48 RXD1 to TTL/RS232 Rx and pin 47 TXD1 to TTL/RS232 Tx
RS232 - loopback connect 9-pin D-type pin 2 Tx to pin 3 Rx
test 1 loopback
test 2 12344567890
test3 abcdefghijklmnopqrstuvwxyz

if the device you are communicating with is RS232 you require a TTL-RS232 module, e.g. a ESP32-S3 ETH Development Board connected to a Quectel EC21 modem

serial monitor output

Waveshare ESP32-S3 ETH Development Board serial1  test pin GPIO47 U1TXD pin GPIO48 U1RXD
   for loopback test connect pin GPIO47 U1TXD to pin GPIO48 U1RXD
RS232: ESP32S3 pin 48 RXD1 to TTL/RS232 Rx and pin 47 TXD1 to TTL/RS232 Tx
RS232 - loopback connect 9-pin D-type pin 2 Tx to pin 3 Rx

RDY
at
OK
at+cgmi
Quectel

OK
at+cgmm
EC21

OK

have you an oscilloscope (or at least a multimeter) to look at the serial signal levels?

Yes, I read the 3.3V specification as well and so figured it was OK to straight between ESP32 to RG15 (but others know much more than me!). Let me give Horace's loopback test idea a go. Maybe there is just a bad connection :shushing_face:

you can do a quick check by looking at the TX idle state voltage level from the device

  1. TTL 3.3V logical 1 - OV logical 0 - idle state is logical 1 (3.3V)
  2. RS232 voltages -6 to -12V logical 1 - +6 to +12V logical 0 - idle state is logical 1 (-6 to -12V)

Hi Horace,

Looking at the looptest back idea it is referring to GPIO47 and GPIO48

#define RXD1 48
#define TXD1 47

My ESP32S3 has no GPIOs or physical pins in that range. Let me ask for this clarification. When looking at the ESP32S3 diagram and selecting pins for Serial.begin() you are to use the physical pin numbers from the diagram (the numbers next to the pins in the small, gray boxes on the diagram)?

Feels like I asked this before, apologies. So, for example, to use GPIO16 the value to .begin() would be 32?

you use GPIO47 and GPIO48 , e.g.
image

in code use GPIO numbers

#define RXD1 48
#define TXD1 47

void setup() {
  // initialize both serial ports:
  Serial.begin(115200);
  delay(2000);
  Serial1.begin(9600, SERIAL_8N1, RXD1, TXD1);

or explicitly

  Serial1.begin(9600, SERIAL_8N1, 48, 47);

Ahhh, this may be my basic problem. On this diagram if one wants to use GPIO16 then put 16 in the .begin() call rather than the number in the little gray box (32) ?

yes

Yep, that was/is exactly my mistake. I was using the numbers in the little gray box. Switching to the GPIO numbers the RG15 reponds nicely. You are the man, @horace. And TY to @van_der_decken for trying to tell me the same thing. TY!

in case anyone else has the same problem it maybe worth marking your final post 19 as the Solution

have you tried Ethernet using the POE module?

Yes, have had good success with the Ethernet PoE module. All of the sensors, cameras, switches, and MCU units on my sensor network are PoE. Some are 100+ meters from the PoE injection units, no issues.