Second board isn't receiving serial data

Hello! I'm trying to send a string over serial pins from an Arduino Nano ESP32 (the "parent") to a WROOM32 (the "child").

The Problem
I can see that the data is being sent by the parent to the serial monitor, but the child is not seeing anything at all coming in.

Hardware
Both boards are externally powered by 5V DC and grounded. They are grounded to each other. The Nano's Tx pin is connected to the Rx2 pin of the WROOM32, and the Nano's Rx pin is connected to the Tx2 pin of the WROOM32.

Firmware
I have a complex pair of scripts for controlling motors through Blynk software. The child MCU was needed to get more output pins.
The relevant simplification of the parent script is:

void setup() { Serial.begin (115200); }
void loop() { 
  Serial.println(dispenser_controls.c_str());
}

where dispenser_controls is a 10-character string ("F0F0F0F0F0" by default). It's modified to be a C string for other reasons.

The relevant child script is:

void setup() {
  Serial.begin(115200);  // Initialize serial communication for USB debugging
  Serial2.begin(115200, SERIAL_8N1, 16, 17);  // Initialize UART2 with RX2/TX2
}
void loop() {
  Serial.println("loop");
  Serial.println(Serial2.readString());
  if (Serial2.available() > 0) {Serial.println("loop2");}
}

When I power up the system and start monitoring Serial on the child, I get:

loop

loop

repeating. It's just a newline between each "loop".

Troubleshooting
Here's what I've tried so far.

  • Verified physical continuity between the Tx-Rx pin pairs with my multimeter
  • Verified that the parent is sending the intended string to serial (using serial monitor)
  • Verified that the child is not receiving any data in its Serial2 buffer (using if (Serial2.available()) )

Any ideas?

readString() will timeout and return if nothing is received in the timeout period
try

void loop() { 
  if (Serial2.available() > 0) {
       Serial.println(Serial2.readString());
    }
}
1 Like

I'm not familiar with your boards. But Serial is not on the Rx/Tx pins on the Nano ESP32; see the schematic (https://docs.arduino.cc/resources/schematics/ABX00083-schematics.pdf). Use Serial1 for communication with the child and check if that works.

1 Like

Oh I see, so Serial is used through the USB port, and Serial1 is used on the Tx/Rx pins? I've tried to replace the two instances of "Serial" with "Serial1" in my code, but I see no change when I monitor what's being received by the child. Is there another change I need to make besides this? I've searched for example scripts of Serial1 being used on the Nano ESP32 but could find none.

Disconnect the child and short pins 0 and 1.

Write a simple sketch that sends e.g. "Hello world" to Serial1; on receive from Serial1, send the received message to Serial.

Something like below will probably do for testing.

void loop()
{
  Serial1.println("Hello world");
  delay(1000);
  while(Serial1.available())
  {
    Serial.write(Serial1.read());
  }
}

The delay(1000) is used prevent sending again before the complete message is received; one should actually use some form of state machine for this.

Hi, @coppergenie

How are you monitoring the serial?

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Hey Tom, thank you for your response! Hopefully you can invest some time in this, because it will take a while to include what you asked for.

I'm monitoring the serial using a USB on the WROOM32. As I understand it, the WROOM32 has two hardware serial (Rx/Tx [Serial in the code] and Rx2/Tx2 [Serial2 in the code]). Before making this circuit, I did a serial comm test where I connected two WROOM32s over Rx2/Tx2 [Serial2] and monitored over USB [Serial] and it worked perfectly. I assume it would also work the same way here, which is why I'm assuming the problem lies in the communication between the Nano ESP32 and the WROOM32, not in the multi-serial interactions within the WROOM32 itself.

As far as circuit and photos, I will get that to you shortly!

Tom! Sorry something came up. Here are the schematics and photos. I'll try to explain well enough, but let me know if you need any clarification. Thanks!

This is the schematic for the interaction in question. From left to right: motor drivers, battery, 5 V stepdown converter, WROOM32, Nano ESP32. Just the logic connections are shown for the drivers. 5V powers the MCUs. Rx/Tx on the Nano is connected to Tx2/Rx2 on the WROOM. WROOM is sending two logic outputs to each of the five drivers.

This is the schematic for part of my circuit controlled solely by the Nano. The battery and stepdown here are the same devices as in the first schematic. Not sure if any of the other devices may be relevant; from left to right: motor encoders, battery, 5 V stepdown, 5-3.3 V stepdown, 5-3.3 V logic level converters, Nano ESP32, motor drivers, motors.

Nano wiring. Serial on bottom left, power on bottom right. THE USB IS NOT PLUGGED IN TO ANYTHING!

WROOM wiring left side. Serial pins near the middle.

WROOM wiring right side. Power on far right pins.

Please excuse the wiring mess at the moment lol

Hi, @coppergenie
Thanks for the the info.
TIP, you can use symbols for 5V and gnd to simplify the wiring.

How are you monitoring the serial.

Tom.. :smiley: :+1: :coffee: :australia:

1 Like

It's in post #7. I'm monitoring serial on the WROOM using USB.

Hey Tom, any update? This issue is kicking my butt

Hi, @coppergenie

Write code to JUST test sending data from one to the other, nothing complicated.
Forget strings for the moment and just basic "hello world" stuff.

Disconnect everything from your controllers and just have gnd and Tx to Rx and Rx to Tx interconnections.

This may help with basic UART/RS232 comms between microcontrollers.

This may help to;
Googled;

esp32 to esp32 uart communication

Tom.. :smiley: :+1: :coffee: :australia:

Hey Tom, I was getting too far behind schedule with this that I ended up finding another workaround. All is good now :slight_smile:

(The workaround is that I'm Blynk software to control the MCUs over virtual pins, and I initially just wanted one Blynk program communicating with the parent MCU, with the parent transferring necessary data to the child, but I instead just made a second Blynk program for the child which adds just a few extra button presses for the user to switch between them.)