I am currently trying to achieve serial communication between my ESP-32 Cam and Arduino Uno R3, as there is a host of sensors I would like to record data from into the Arduino Uno and then send to the ESP32-CAM. However, as I do not have a TTL adapter, I am forced to program the ESP32-CAM via the Arduino Uno itself. This has left me with a host of challenges.
So far, I understand that the Arduino Uno only has one hardware UART (pins 0 and 1), so as such I have tried to define a SoftwareSerial at pins 4 and 5 to act as RX and TX for the desired serial communication between ESP32CAM. Additionally, since I do not require an SD card, I have established GPIO pins 12 and 13 for use as the resulting RX TX.
The reason I have done this is because it seems as though VoR and VoT & pins 0 and 1 on the Arduino are required to be used during upload of code from Arduino IDE to the ESP32-CAM via the Arduino. To upload the code to the ESP32-CAM, I used the following connections in the image. Then, after upload, I removed the GPIO0-ground connection (to get it out of programming mode), and after hitting the reset button on the ESP32-CAM, I disconnected everything except for 5V and ground pins from the ESP32-CAM including VoR and VoT connections. Then, I uploaded the Arduino code but I cannot see anything pop up on the Serial Monitor of the ESP32.
I am not sure why that is; and I was wondering if my understanding of being able to use GPIO 12 and 13 is correct?
I noticed there was also GPIO16 which can be used for receiving (I only need communication one-way from Arduino to ESP32) but I thought it might be tricky without a partnering TX port. I have also tried uploading the ESP32-CAM code and once uploaded, switched the VoR and VoT connections to the serial ports I designated but that did not work either. Any help in helping achieve serial communication from the Arduino Uno to the ESP32-CAM would be greatly appreciated.
//ESP32 code: using pins 12 and 13 for RX and TX on ESP32
#define RXD2 GPIO_NUM_12
#define TXD2 GPIO_NUM_13
void setup() {
Serial.begin(9600);
SerialH.begin(9600, SERIAL_8N1, RXD2, TXD2); //serial for Uno-ESP32CAm
}
void loop() {
if(SerialH.available()) {
char data = SerialH.read();
Serial.println(data); //printing to serial monitor to verify data is correct
}
}
//Arduino: using RX and TX as pins 4 and 5 on Arduino
#include <SoftwareSerial.h>
#define RX_PIN 4
#define TX_PIN 5
SoftwareSerial sSerial(RX_PIN, TX_PIN);
void setup() {
Serial.begin(9600);
sSerial.begin(9600);
}
void loop() {
if (Serial.available()) {
sSerial.write(22); //sending simple integer
delay(2000);
}
}