This project is useful for: ESP32-CAM control using Arduino Sensor data transfer to ESP32 Camera-based IoT projects Learning UART communication between 5V and 3.3V devices How It Works UART (Universal Asynchronous Receiver-Transmitter) allows two devices to communicate using TX (Transmit) and RX (Receive) lines.
Arduino UNO sends data via Serial TX ESP32-CAM receives data via UART RX Common GND is shared ESP32-CAM uses Serial2 (GPIO16 & GPIO17) ⚠️ Important: ESP32-CAM works at 3.3V logic, so a voltage divider is recommended on Arduino TX → ESP32 RX.
Wiring Connections To establish UART communication between the Arduino UNO and ESP32-CAM, follow the wiring steps below.
Connect Grounds (Important)
Connect GND of Arduino UNO to GND of ESP32-CAM A common ground is required for proper serial communication Serial Data Connection
Connect Arduino UNO TX (Pin 1) to ESP32-CAM RX (GPIO16) This allows data to be transmitted from Arduino to ESP32-CAM Voltage Level Protection (Recommended)
The Arduino UNO operates at 5V logic, while the ESP32-CAM uses 3.3V logic.
To protect the ESP32-CAM, use a voltage divider :
Place a 1.8kΩ resistor between Arduino TX and ESP32-CAM RX (GPIO16) Place a 3.3kΩ resistor between ESP32-CAM RX (GPIO16) and GND ESP32-CAM Programming Connections
Use a USB-to-TTL adapter to upload code Connect U0R → TX, U0T → RX, 5V → 5V, GND → GND Connect IO0 to GND while uploading the sketch
Arduino UNO Code (Sender) void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Hello from Arduino!");
delay(1000);
}
📌 This code continuously sends text data from the Arduino to the ESP32-CAM every second.
ESP32-CAM Code (Receiver) #include "HardwareSerial.h"
HardwareSerial SerialESP32(2);
void setup() {
Serial.begin(115200);
SerialESP32.begin(9600, SERIAL_8N1, 16, 17);
Serial.println("ESP32-CAM Ready");
}
void loop() {
if (SerialESP32.available()) {
String data = SerialESP32.readStringUntil('\n');
Serial.println("Received: " + data);
}
}
📌 The ESP32-CAM reads data using Serial2 and prints it to the Serial Monitor.
How to Upload Code to ESP32-CAM Connect IO0 to GND Press RESET Upload code using USB-to-TTL adapter Disconnect IO0 from GND Press RESET again References Original tutorial:
https://www.programmingboss.com/2023/01/serial-communication-between-arduino-and-esp32-CAM-UART-data-communication.html