Networking and Communications

This week is about the serial connections and the WiFi connection used in my final project. This video shows that the D11C was able to get the "Hiii" information that sent from ESP32-CAM successfully.

WiFi Connection

This part was already talked about in the Week 9 document.

Serial Connection

In weeks 9 & 10 I milled a D11C to expand the pins of ESP32-CAM. I planned to use ESP32-CAM to control the D11C. Therefore I need to send the speed information so D11C can control the motor it was responsible for.

After watching this tutorial, I understand that TX is sending pin and RX is receiving pin, so if you only have one set of them, you can only do one direction.

I found this sample code online, but I noticed the D11C couldn't receive the signal, I double-checked the pin mapping, and I was using the right RX port:

Later I realized I should use Serial1. instead of Serial because the later is for the board to talk to the computer via USB. And yes I was able to send and receive Data!

HardwareSerial

Because I want to pass the motor speeds from the computer to the two motors, I decided to use the RX pin on the ESP32-CAM to receive data and the TX pin to pass the data to D11C. I thought this would be easy, but I ended up spending a long time because I realized that even if I don't initialize the Serial on ESP32-CAM, it's still gonna send random debug information through 115200.

Then I found this link that manually sets TX/RX to any pin you like. I used pin 2 and 33 (the LED pin) as TX and RX, following the order provided as a comment, but it didn't work. Then I tried 2 and 4. I noticed the flashlight is flashing and if I used 4 instead 2 as TX it worked! Now I know the comments has the wrong order. It should be RX, TX instead of TX, RX. After that I was able to send the data from the computer to ESP32-CAM to D11C.

As shown in the picture, I used the `GPIO 2` on ESP32-CAM as TX and RX1 pin (bottom right pin) on the D11C as RX.

I was able to pass the speed information as shown in the video:

It shows how I passed the speed information as serial information from the computer to ESP32-CAM to D11C, and how they updated the motors accordingly.

Files: