Sending Serial info from esp32 to arduino on Elegoo kit

Hi friends! I bought an Elegoo v4 kit, which comes with an Arduino board and an esp32 board with a camera module.

My current goal is to have the esp32 connect to the Wifi, create a web server and then receive HTTP requests, to send some Serial data to the arduino board and make the robot move.

This is the esp32 camera board:

It has a serial connection that goes to...

The arduino shield, and the label on the board says that these are connected to the TXD and RXD, or at least that's what I understand by the label.

The schematics in the documentation for the arduino show me this:

UART specs

I am not sure if my understanding is correct, but I think that this means that the Serial port in the esp32 is connected to the RX and TX pins in the arduino, which I believe are ports 0 and 1, as per the labels on the side of the board:

So I have the following code in my esp32:

// Ping
unsigned long lastPingTime = 0;
const unsigned long pingInterval = 5000; // How many milliseconds to wait for each ping

void setup()
{
  Serial.begin(9600);

  // ... stuff related to camera server

  delay(100);
  pinMode(13, OUTPUT);  
  digitalWrite(13, HIGH);

  // ...stuff related to web server
}


void loop()
{
  if (millis() - lastPingTime >= pingInterval) {
    Serial.println("camera ping: Serial1");
    lastPingTime = millis();
  }
}

I can upload this program and as long as the esp32 is connected to the laptop, I can see the "camera ping" messages every 5 seconds.

Now, I want to be able to capture those messages on the Arduino, so I try to take the first example from this: Serial Input Basics - updated - #4 by Robin2

char receivedChar;
boolean newData = false;

void loop() {
  recvOneChar();
  showNewData();
}

void recvOneChar() {
    if (Serial.available() > 0) {
        receivedChar = Serial.read();
        newData = true;
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChar);
        newData = false;
    }
}

I upload this code, and then nothing happens. I can see messages I print via "Serial.print" but I never read any data with the function recvOneChar.

I was looking in the forum and found this thread: Serial communication between ESP32 and Arduino UNO - #17 by Idahowalker

i can read that one of the responses says that "One cannot use the Uno's pin-0 and pin-1 for serial comms". Is that so? How could I get the data from the esp32 into the arduino, so I can send messages via HTTP request and have the robot move?

This is the picture of the side of the arduino with the pin labels.

I'm not sure what you mean, but first of all you either take the shield out and see where TX and RX pins from that connector go or have a look at the Arduino code: you need to see if the camera communication is made via pins 0 and 1 or not. Secondly, you should check if the serial speed is 9600 baud or not. In any case, if you meant to use that connector to set a communication with an ESP32, I don't really know if you mean also you'll get rid of the camera (you can't have both over the same RX/TX serial line).

Hello! Thanks for the reply. Currently I'm only planning to send some basic messages from the esp32 to the arduino, like "forward", "backward", and then have the shield move the robot.

Lucky for me I figured out a solution looking at the code provided by the manufacturer. The original esp32 camera code declares the second serial port as:

#define RXD2 33
#define TXD2 4

void setup()
{
  Serial.begin(9600);
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);

  //...
}

After doing this, any Serial2.println in the esp32 can be received on the Arduino side, with the old code:

String recvLine() {
  String receivedString;
    if (Serial.available() > 0) {
      receivedString = Serial.readStringUntil('\n');
    }

  return receivedString;
}

On top of that the board has a switch with two modes, one is "Upload" and the other one is "Cam", and of course I had overlooked that switch. Turns out, until you move the switch back to "Cam", there will be nothing coming via serial port.

Everything works now, sorry for taking your time! Have a good weekend

Don't be sorry, we're (almost) all hobbysts here, and happy to help someone to solve problems... :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.