13. Embedded Networking and Communications¶
This week I worked on networking, aka transmitting data from the PCB board to another place. For this week, I heavily used the work done in Week 11 for reading sensor data, and then send it to another Seeed Xiao ESP32C3 module via Bluetooth Low Energy, and displayed it on Serial Monitor.
During group work, we transmitted data from one PCB to another via serial communication.
Sending data from one place to another via Bluetooth needs setting up one server and one client. In my exercise, the server (PCB with ESP32C3 Module) senses temperature and humidity data with DHT11 Sensor and sends them to the client (another ESP32CE module). For this exercise, I took hints from a tutorial on Randomnerd Tutorials Site.
Setting Bluetooth Server¶
A Bluetooth server advertises its presence by broadcasting some data (in a specific data structure) which can be read by potential clients located nearby within the range. Once such a client finds the server, it establishes the connection. I am using this particular data structure.
Hierarchical data structure advertised by Bluetooth server to nearby devices. Copyright held by Random Nerd Tutorials.
It can be seen that it has two data attributes: temperature and humidity which are being sent by the server to any client which connects to it. One particularly noteworthy attribute is UUID (Universally Unique Identifier). Each service, characteristic, and descriptor have a UUID (Universally Unique Identifier). It is a unique 128-bit (16 bytes) number that describes each service, characteristic, and descriptor.
Hardware setup (on PCB Board)¶
DHT11 sensor has 3 pinouts: Signal pin, Vcc (aka. Power) pin and GND pin.
- Signal pin of the DHT11 sensor is connected to the D4 (SDA) pin of Xiao RP2040 MCU on the PCB.
- Power pin of the DHT11 sensor is connected to the 5V pin of Xiao ESP32C3 MCU on the PCB since the DHT11 sensor works with a power supply in the range of from 3.5V to 5.5V DC.
- GND pin of the DHT11 sensor is connected to the GND pin of Xiao ESP32C3 MCU on the PCB
Layout/schematics of PCB can be seen here, and corresponding design files in Kicad can be found from here. I designed the PCB board in Week 06. Electronics Design, and fabricated it in Week 08. Electronics Production.
Arduino code to program the server can be found here.
I modified the program according to the hard setup configuration mentioned above. Another major change was that I was using the DHT11 sensor to read temperature and humidity, while the original code was written for the Adafruit BME280 sensor. It requires us to take care that the relevant libraries are installed. I described this step of installing the relevant library in Week 04.
Setting Bluetooth Client¶
Arduino code to program the server can be found here. I modified it in order to see the output on the serial monitor in Arduino IDE.
Bluetooth Server (Seeed Xiao ESP32C3 Module with DHT11 Sensor on PCB) and Bluetooth CLient (Seeed Xiao ESP32C3 Module).
Output¶
Serial Monitor connected to Bluetooth Client showing temperature and humidity reading received from the Bluetooth Server