ESP32 CYD with ESP-NOW: Receive and Display Data From Multiple Boards
Use the ESP-NOW communication protocol with the ESP32 CYD Board (Cheap Yellow Display) to receive and display BME280 sensor data from multiple ESP32 sender boards.
- Suitable forB.Tech/Diploma IoT/ESP32 students
- Build time1-2 weeks
- LevelBeginner
- Available atAjvika Labs, Kakinada
About this project
In this project, you’ll learn how to use the ESP-NOW communication protocol with the ESP32 CYD Board (Cheap Yellow Display) to receive and display data from multiple ESP32 sender boards. Two ESP32 boards will each read sensor data from a BME280 and send it to the CYD board. The CYD board, acting as the ESP-NOW receiver, will display the received data in separate tables, one for each sender, each shown on a different tab on the screen.
New to the ESP32 Cheap Yellow Display?
Start here:
Getting Started with ESP32 Cheap Yellow Display Board – CYD (ESP32-2432S028R)
Project Overview
Here’s an overview of how this project works.
In this project, the ESP32 CYD board will act as a ESP-NOW receiver that receives data from other ESP32 boards.
The other ESP32 boards will be sending sensor data (BME280) to the CYD board periodically, via ESP-NOW.
The CYD board displays two tabs, each one for each board. Each tab contains a table with the data received from the other boards.
The tables are updated as soon as the CYD receives new data.
New to ESP-NOW communication protocol?
Get started here:
Getting Started with ESP-NOW (ESP32 with Arduino IDE)
Prerequisites
Before proceeding, make sure you follow the next prerequisites.
You must follow all steps, otherwise, your project will not work.
1) Parts Required
For this project, you need the following parts:
ESP32 Cheap Yellow Display Board
2x ESP32 boards of your choice (we’re using the
DOIT DevKIT V1 Board
)
2x
BME280
Jumper wires
You can use the preceding links or go directly to
MakerAdvisor.com/tools
to find all the parts for your projects at the best price!
2) Install ESP32 Boards in Arduino IDE
We’ll program the ESP32 using Arduino IDE. Make sure you have the ESP32 boards installed. Follow the next tutorial:
Installing ESP32 Board in Arduino IDE 2 (Windows, Mac OS X, Linux)
3) Get familiar with the ESP32 Cheap Yellow Display
The
ESP32-2432S028R
development board has become known in the maker community as the “
Cheap Yellow Display
” or CYD for short. This development board, whose main chip is an ESP32-WROOM-32 module, comes with a 2.8-inch TFT touchscreen LCD, a microSD card interface, an RGB LED, and all the required circuitry to program and apply power to the board.
If this is your first time using the ESP32 Cheap Yellow Display, make sure to follow our getting started guide:
Getting Started with ESP32 Cheap Yellow Display Board and LVGL
4) Install TFT and LVGL Libraries
LVGL
(Light and Versatile Graphics Library) is a free and open-source graphics library that provides a wide range of easy-to-use graphical elements for your microcontroller projects that require a graphical user interface (GUI).
Follow the next tutorial to install and configure the required libraries to use LVGL for the ESP32 Cheap Yellow Display using Arduino IDE.
Get started with LVGL using the ESP32 Cheap Yellow Display Board (ESP32-2432S028R)
5) Install BME280 Libraries
For this project, we’ll use the Adafruit BME280 library to get data from the BME280 on the other ESP32 boards. In the Arduino IDE, go to
Sketch
>
Include Library
>
Manage Libraries
. Search for
Adafruit BME280 Library
in the search box and install the library. Also, install any dependencies that are currently not installed (usually the Adafruit Bus IO and the Adafruit Unified Sensor libraries).
Getting the CYD Board MAC Address
First, you need to know the MAC address of the CYD board so that the sender boards can send messages to it.
Upload the following code to the CYD Board.
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
#include <WiFi.h>
#include <esp_wifi.h>
void readMacAddress(){
uint8_t baseMac[6];
esp_err_t ret = esp_wifi_get_mac(WIFI_IF_STA, baseMac);
if (ret == ESP_OK) {
Serial.printf("%02x:%02x:%02x:%02x:%02x:%02x\n",
baseMac[0], baseMac[1], baseMac[2],
baseMac[3], baseMac[4], baseMac[5]);
} else {
Serial.println("Failed to read MAC address");
}
}
void setup(){
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.STA.begin();
Serial.print("[DEFAULT] ESP32 Board MAC Address: ");
readMacAddress();
}
void loop(){
}
After uploading, open the Serial Monitor at a baud rate of 115200. Press the onboard RST button. The board’s MAC Address will be printed in the Serial Monitor.
Preparing the Sender Boards
For this tutorial, we’ll send data to the CYD from two different boards. You can modify this project to display data from more boards.
Each board will be identified by an ID (a number that we’ll attribute to each board):
ID=1 for board1
ID=2 for board2
Wiring the BME280 Sensor
Each sender board will send environmental data from a BME280 sensor. Wire a BME280 sensor to each of your boards. We’ll use the ESP32 default I2C pins.
Learn more about I2C with the ESP32:
ESP32 I2C Communication: Set Pins, Multiple Bus Interfaces and Peripherals (Arduino IDE)
Not familiar with the BME280 with the ESP32? Read this tutorial:
ESP32 with BME280 Sensor using Arduino IDE (Pressure, Temperature, Humidity)
If you’re using a different board model, the default I2C pins migh different.
ESP32 ESP-NOW Sender Code
The following code reads the data from the BME280 sensor and sends it via ESP-NOW to the CYD board. Don’t forget to modify the code with your CYD board’s MAC address. Additionally, don’t forget to change the board ID for each of your boards.
/*********
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*********/
#include <esp_now.h>
#include <WiFi.h>
#include <Adafruit_BME280.h>
#include <Adafruit_Sensor.h>
// Set your Board ID (ESP32 Sender #1 = BOARD_ID 1, ESP32 Sender #2 = BOARD_ID 2, etc)
#define BOARD_ID 1
Adafruit_BME280 bme;
// REPLACE WITH YOUR ESP RECEIVER'S MAC ADDRESS
uint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
// Structure to send data, must match the receiver structure
typedef struct struct_message {
int id;
float temp;
float hum;
int readingId;
} struct_message;
// Create a struct_message called myData
struct_message myData;
unsigned long previousMillis = 0; // Stores last time temperature was published
const long interval = 10000; // Interval at which to publish sensor readings
unsigned int readingId = 0;
void initBME() {
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
float readTemperature() {
float t = bme.readTemperature();
return t;
}
float readHumidity() {
float h = bme.readHumidity();
return h;
}
esp_now_peer_info_t peerInfo;
// Callback when data is sent
void OnDataSent(const wifi_tx_info_t* mac_addr, esp_now_send_status_t status) {
char macStr[18];
Serial.print("Packet to: ");
// Copies the receiver mac address to a string
snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x",
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
Serial.print(macStr);
Serial.print(" send status:\t");
Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}
void setup() {
Serial.begin(115200);
initBME();
WiFi.mode(WIFI_STA);
if (esp_now_init() != ESP_OK) {
New to the ESP32 Cheap Yellow Display?
Start here:
Getting Started with ESP32 Cheap Yellow Display Board – CYD (ESP32-2432S028R)
Project Overview
Here’s an overview of how this project works.
In this project, the ESP32 CYD board will act as a ESP-NOW receiver that receives data from other ESP32 boards.
The other ESP32 boards will be sending sensor data (BME280) to the CYD board periodically, via ESP-NOW.
The CYD board displays two tabs, each one for each board. Each tab contains a table with the data received from the other boards.
The tables are updated as soon as the CYD receives new data.
New to ESP-NOW communication protocol?
Get started here:
Getting Started with ESP-NOW (ESP32 with Arduino IDE)
Prerequisites
Before proceeding, make sure you follow the next prerequisites.
You must follow all steps, otherwise, your project will not work.
1) Parts Required
For this project, you need the following parts:
ESP32 Cheap Yellow Display Board
2x ESP32 boards of your choice (we’re using the
DOIT DevKIT V1 Board
)
2x
BME280
Jumper wires
You can use the preceding links or go directly to
MakerAdvisor.com/tools
to find all the parts for your projects at the best price!
2) Install ESP32 Boards in Arduino IDE
We’ll program the ESP32 using Arduino IDE. Make sure you have the ESP32 boards installed. Follow the next tutorial:
Installing ESP32 Board in Arduino IDE 2 (Windows, Mac OS X, Linux)
3) Get familiar with the ESP32 Cheap Yellow Display
The
ESP32-2432S028R
development board has become known in the maker community as the “
Cheap Yellow Display
” or CYD for short. This development board, whose main chip is an ESP32-WROOM-32 module, comes with a 2.8-inch TFT touchscreen LCD, a microSD card interface, an RGB LED, and all the required circuitry to program and apply power to the board.
If this is your first time using the ESP32 Cheap Yellow Display, make sure to follow our getting started guide:
Getting Started with ESP32 Cheap Yellow Display Board and LVGL
4) Install TFT and LVGL Libraries
LVGL
(Light and Versatile Graphics Library) is a free and open-source graphics library that provides a wide range of easy-to-use graphical elements for your microcontroller projects that require a graphical user interface (GUI).
Follow the next tutorial to install and configure the required libraries to use LVGL for the ESP32 Cheap Yellow Display using Arduino IDE.
Get started with LVGL using the ESP32 Cheap Yellow Display Board (ESP32-2432S028R)
5) Install BME280 Libraries
For this project, we’ll use the Adafruit BME280 library to get data from the BME280 on the other ESP32 boards. In the Arduino IDE, go to
Sketch
>
Include Library
>
Manage Libraries
. Search for
Adafruit BME280 Library
in the search box and install the library. Also, install any dependencies that are currently not installed (usually the Adafruit Bus IO and the Adafruit Unified Sensor libraries).
Getting the CYD Board MAC Address
First, you need to know the MAC address of the CYD board so that the sender boards can send messages to it.
Upload the following code to the CYD Board.
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
#include <WiFi.h>
#include <esp_wifi.h>
void readMacAddress(){
uint8_t baseMac[6];
esp_err_t ret = esp_wifi_get_mac(WIFI_IF_STA, baseMac);
if (ret == ESP_OK) {
Serial.printf("%02x:%02x:%02x:%02x:%02x:%02x\n",
baseMac[0], baseMac[1], baseMac[2],
baseMac[3], baseMac[4], baseMac[5]);
} else {
Serial.println("Failed to read MAC address");
}
}
void setup(){
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.STA.begin();
Serial.print("[DEFAULT] ESP32 Board MAC Address: ");
readMacAddress();
}
void loop(){
}
After uploading, open the Serial Monitor at a baud rate of 115200. Press the onboard RST button. The board’s MAC Address will be printed in the Serial Monitor.
Preparing the Sender Boards
For this tutorial, we’ll send data to the CYD from two different boards. You can modify this project to display data from more boards.
Each board will be identified by an ID (a number that we’ll attribute to each board):
ID=1 for board1
ID=2 for board2
Wiring the BME280 Sensor
Each sender board will send environmental data from a BME280 sensor. Wire a BME280 sensor to each of your boards. We’ll use the ESP32 default I2C pins.
Learn more about I2C with the ESP32:
ESP32 I2C Communication: Set Pins, Multiple Bus Interfaces and Peripherals (Arduino IDE)
Not familiar with the BME280 with the ESP32? Read this tutorial:
ESP32 with BME280 Sensor using Arduino IDE (Pressure, Temperature, Humidity)
If you’re using a different board model, the default I2C pins migh different.
ESP32 ESP-NOW Sender Code
The following code reads the data from the BME280 sensor and sends it via ESP-NOW to the CYD board. Don’t forget to modify the code with your CYD board’s MAC address. Additionally, don’t forget to change the board ID for each of your boards.
/*********
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*********/
#include <esp_now.h>
#include <WiFi.h>
#include <Adafruit_BME280.h>
#include <Adafruit_Sensor.h>
// Set your Board ID (ESP32 Sender #1 = BOARD_ID 1, ESP32 Sender #2 = BOARD_ID 2, etc)
#define BOARD_ID 1
Adafruit_BME280 bme;
// REPLACE WITH YOUR ESP RECEIVER'S MAC ADDRESS
uint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
// Structure to send data, must match the receiver structure
typedef struct struct_message {
int id;
float temp;
float hum;
int readingId;
} struct_message;
// Create a struct_message called myData
struct_message myData;
unsigned long previousMillis = 0; // Stores last time temperature was published
const long interval = 10000; // Interval at which to publish sensor readings
unsigned int readingId = 0;
void initBME() {
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
float readTemperature() {
float t = bme.readTemperature();
return t;
}
float readHumidity() {
float h = bme.readHumidity();
return h;
}
esp_now_peer_info_t peerInfo;
// Callback when data is sent
void OnDataSent(const wifi_tx_info_t* mac_addr, esp_now_send_status_t status) {
char macStr[18];
Serial.print("Packet to: ");
// Copies the receiver mac address to a string
snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x",
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
Serial.print(macStr);
Serial.print(" send status:\t");
Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}
void setup() {
Serial.begin(115200);
initBME();
WiFi.mode(WIFI_STA);
if (esp_now_init() != ESP_OK) {
Technologies used
Hardware components
- ESP32
- ESP8266
- Arduino
- BME280
- SD Card
Software & tools
- Arduino IDE
What you get
- Working project / hardware kit, tested before delivery
- Complete source code with explanation
- Project demo and guidance for your viva
- Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed.
Payment is in two parts:
• 50% advance to start the project
• Remaining 50% before delivery
Note:
• Documentation and PPT are not included by default
• If you need documentation/PPT, it can be arranged for extra time and cost
We'll confirm the exact timeline and cost with you after reviewing your requirements.