11. Networking and Communications¶
For this week’s assignment we have worked as follows. Group assignment: - Send a message between two projects. - Document your work to the group work page and reflect on your individual page what you learned. Individual assignment: - Design, build and connect wired or wireless node(s) with network or bus addresses and a local interface.
Assignment Cheklist.¶
item | Activity | Status |
---|---|---|
task 1 | Linked to the group assignment page and reflected on your individual page | IN PROGRESS |
task 2 | Documented your project and what you have learned from implementing networking and/or communication protocols. | IN PROGRESS |
task 3 | Explained the programming process(es) you used. | IN PROGRESS |
task 4 | Outlined problems and how you fixed them | IN PROGRESS |
task 5 | Included design files (or linked to where they are located if you are using a board you have designed and fabricated earlier) and original source code. | IN PROGRESS |
task 6 | Included a ‘hero shot’ of your network and/or communications setup | IN PROGRESS |
Individual Assignment¶
The project presented below seeks to integrate the connection between an ESP32 DEV MODULE board and the well-known SEED XIAO RP2040 electronic board, using the data sending and receiving switches. We retrieve the data through a DHT11 humidity sensor, which will be reflected on an OLED display on the SEEED XIAO RP2040 board.
At first, the idea seems super simple; there have been some difficulties that I can describe as learning.
System design¶
For this task, we will use two different boards: - ESP32 DEV MODULE - SEEED XIAO RP2040
We will also use an input and output device to display the data. - Humidity Sensor - DHT11 - OLED Display
Assembly and samples¶
We base the connection issue on the specifications of our components and experience in this area.
Useful links¶
Code Example¶
Code in ESP32¶
#include "DHT.h"
#define DHTPIN 4
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
// UART2: RX=16, TX=17
Serial2.begin(9600, SERIAL_8N1, 16, 17);
dht.begin();
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Error leyendo DHT11");
delay(2000);
return;
}
// Mostrar en monitor serial
Serial.printf("Temperatura: %.1f °C, Humedad: %.1f %%\n", t, h);
// Enviar al XIAO RP2040 por UART2
Serial2.printf("%.1f,%.1f\n", t, h);
delay(5000);
}
Code on board seeed XIAO RP2040¶
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
String inputString = "";
void setup() {
Serial1.begin(9600);
Serial.begin(115200); // Debug por USB
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println("Error al iniciar OLED");
while (true);
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("Esperando datos...");
display.display();
}
void loop() {
while (Serial1.available()) {
char c = Serial1.read();
if (c == '\n') {
processData(inputString);
inputString = "";
} else {
inputString += c;
}
}
}
void processData(String data) {
Serial.print("Recibido: ");
Serial.println(data);
int commaIndex = data.indexOf(',');
if (commaIndex > 0) {
String tempStr = data.substring(0, commaIndex);
String humStr = data.substring(commaIndex + 1);
float t = tempStr.toFloat();
float h = humStr.toFloat();
// Mostrar en OLED
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0, 0);
display.print("T: ");
display.print(t, 1);
display.println("C");
display.setCursor(0, 30);
display.print("H: ");
display.print(h, 0);
display.println("%");
display.display();
}
}
Video¶
From Youtube¶
IN PROGRESS
## LEARNING, FINDING AND LESSONS
It is important to select the appropriate plates with the correct operating voltages so that we do not have connection or reading problems.