networking and communication

fab academy week 14



The class was about the different types of networks and the protocols that allow it. We discussed wired vs wireless communication and their modalities (serial vs parallel, synchronous vs asynchronous...). The content of this week is available here.

For this task, I wanted to use wireless communication and send sensors reading from one microcontroller to another. I followed a tutorial to use ESP-NOW, a protocol developed by Espressif for communication without wifi (see here).
I followed this tutorial for 2 way communication between two ESP32 microcontrollers.

In this tutorial, they are sending data from BME280 sensors between the two boards and displaying it on OLED screens. I modified the code as I used a DHT11 sensor that I had instead and no OLED screen, I displayed the messages sent on the monitor of Arduino IDE instead.

The first step was to get the microcontrollers MAC addresses by uploading some code and pressing the reset button. In my case, the two controllers I was using had the following codes: ESP1 = 3C:61:05:4B:05:C8 and ESP2 = 3C:61:05:48:D3:F8
It is useful to write them done and label them to then remember which one is which when starting to program them for communication.


After that, I wired the DHT11 sensor to one of the boards. In the tutorial they wire a sensor to both controllers but in my case I just wanted to use one, a real life application would be that I could follow the temperature variations of a solar oven that I install on the rooftop without being always next to it so I can continue doing other things inside of the building. According to the specifications, ESP-NOW should support long distance communication even if separated by thick walls.
In the code, I changed all the references to variables of the sensor this tutorial was using to replace them by DHT11 variables and I commented al the parts that were refering to the OLED screen.
I created:
  • one file for the controller with the sensor in which I had to indicate the MAC address of the other (receiver)
  • one file for the controller that was gonna receive the data in which I indicated the MAC address of the other (emitter in that case).


communication sensor


After uploading the code to both controllers, I could read on the monitor of the receiver the temperature and humidity readings of the emitter. I tried to put it further by powering it with a battery and I could still receive the readings.

Here are the two files with the code:
Sender with sensor
Receiver


tools I worked with

2 ESP32 microcontrollers
DHT11 temperature and humidity sensor
Breadboard and wires
Arduino IDE