13. Networking and Communication

This week, I worked with my group to explore different networking methods and communication protocols. We established a bluetooth connection between a cellphone and the ESP32C3 and sent a message from an Arduino UNO to the ESP32C3 using UART communication protocol. For my individual assignment, I wanted to read input in the Arduino Serial monitor to the ESP32C3 Serial monitor, but for some reason the Arduino Serial monitor stops reading data from its input prompt whenever the ESP is plugged into the same computer. So I just ended up reading 0s and 1s from the Arduino Serial to turn on/off the built-in LED in my development board I had designed in week 8.

Group Assignment

Coming soon...

Individual Assignment

UART Communication Protocol

UART stands for universal asynchronous receiver / transmitter and is used for exchanging data between two devices. UART is very simple as it only uses two wires between transmitter and receiver to receive and transmit data in both directions.

Circuit and Wiring

Circuit

As I only used two microcontrollers, the connections were very simple. I just connected the Arduino GND, RX and TX pins to the ESP32 GND, TX and RX pins, respectively. This allowed data to be transferred in both directions. However, I only sent data from the Arduino to the ESP, but not the other way around. I heard concerns about the ESP32 acting as a transmitter. I did not have enough time to try it out myself, though.

Arduino Code

The Arduino code was very simple. I just printed 0 and 1 with 1500 milliseconds delay between each.

arduinoCode

ESP32C3 Code

ESPCode

For the ESP code, I needed to include the hardwareSerial library to create a new serial object that connects to the Arduino and communicates with it at 9600 baud rate. In the loop function, the if statement reads the values from the arduino serial monitor using parseInt() function. If it reads 1, it turns the LED on; otherwise, it turns it off.

Video

Here is a video of the LED blinking.

Source File

  • Arduino Code
  • ESP32C3 Code