Communication between ESP32 and ESP32 CAM

I came back class,

I have an ESP32 CAM AI-Thinker.

I do not intend to use the SD CARD.

And I would like to connect his inverted RX-TX with pins 16 and 17 of another ESP32 Wroom.

But I would like to view the communication result on ESP-CAM's serial monitor.

So, I ask which ESP-CAM pins I can use to successfully communicate using this code snippet:

Serial2.begin(9600, SERIAL_8N1, RX, TX);

And I have this code to put in the ESP32 WROOM:

#define RXp2 16
#define TXp2 17
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial2.begin(9600, SERIAL_8N1, RXp2, TXp2);
}
void loop() {
    Serial.println("Message Received: ");
    Serial.println(Serial2.readString());
}

I plan to test sending an email address from the ESP32 Wroom to the ESP-CAM.

And email addresses can contain many different characters, letters, numbers, and have different sizes so I believe it should be a String.

Example:
String email = "abc123def456_ghi789@abcdefghijklmnopqrstuwxyz.com.br";

When I power up the ESP32 Wroom I will see this String email arrive on the ESP CAM serial monitor

How should the ESP32 and ESP-CAM codes be to work ?

Very Thanks

We're supposed to automatically know what those pins are?

With ESP32, it is especially important to consult the extended documentation on pin functions and configuration. It's way more complex than on the AVR.

To make matters worse, the assignment of ESP pins to board pins has never followed any standard, it's all over the map.

... a C string (array of char containing a null terminated text string) would be perfect.

The Arduino UART serial functions .write(), .read(), .available() come to mind. See the Serial Input Basics tutorial on this forum.

I have connected an ESP-WROOM-32to an ESP-CAM using serial
ESP32 code

// ESP32  Serial1 test

// for loopback test connect pins 14 and 15

#define RXD1 14
#define TXD1 15

void setup() {
  // initialize both serial ports:
  Serial.begin(115200);
  Serial1.begin(115200, SERIAL_8N1, RXD1, TXD1);
  Serial.println();
  Serial.println("serial1  test Rx pin 14 Tx pin 15");
}

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);
  }
}

ESP-CAM code

// ESP32-CAM  Serial1 test

// for loopback test connect pins 14 and 15

#define RXD1 14
#define TXD1 15

void setup() {
  // initialize both serial ports:
  Serial.begin(115200);
  Serial1.begin(115200, SERIAL_8N1, RXD1, TXD1);
  Serial.println();
  Serial.println("serial1  test Rx pin 14 Tx pin 15");
}

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);
  }
}

interconnected pins 14 and 15 on both board and transmitted text between them OK

Very grateful, friend.

On ESP-cam I did the loopback test and it worked.

But, on ESP32 I did the same loopback test shorting 16 with 17 and it didn't work.

I decided to use 16 and 17 as they are the pins I will use when expanding the code to include more function.

In this way I used the hardwareSerial mySerial(2).

Does it need to have some library to use the Serial hardware ?

I have already measured the short between 16 and 17 with a multimeter and the COM port is correct.

But what I type does not return.

// ESP32  mySerial test
// for loopback test connect pins 16 and 17

HardwareSerial mySerial(2);

void setup() {
  // initialize both serial ports: 
  Serial.begin(115200);
  mySerial.begin(9600, SERIAL_8N1, 17, 16);
  Serial.println();
  Serial.println("mySerial test Rx pin 16 Tx pin 17");
}

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

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

should the above be

// read from port 0, send to port 1:
  if (Serial.available()) {

ops, that was it, thanks

If the ESPCAM is far from the ESP32, up to how many meters can I get a secure communication, without corrupting the data, connecting only with 4 wires (3.3 v, GND, RX, TX) ?

Maybe just a shielded cable.

depends on the cable used (use screened cable) and the electrical noise in the environment
typical several metres is OK
if you require tens of metres use RS252 shields to boost the line voltages

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