πŸ”§ DIY Wireless Sensor Hub With ESP32 + Arduino + NRF24L01

by Madhan Kumar Chiruguri in Circuits > Wireless

54 Views, 2 Favorites, 0 Comments

πŸ”§ DIY Wireless Sensor Hub With ESP32 + Arduino + NRF24L01

HUB.jpg

In this project, we design a wireless sensor hub using ESP32 and Arduino connected via NRF24L01 transceivers. The ESP32 serves as the main control hub with an OLED display and interactive menu system, while the Arduino-based sensor nodes handle environmental sensing, alert indication, and automatic notifications. This two-MCU system enables parallel task execution, separating user interface and load control from real-time alert response.

Supplies

b5e02d8c682745f9a7b0ef29279c35ce (1).jpg

Components Required

Main Hub Unit:

  1. ESP32 Wroom Dev Board
  2. Arduino Uno(ATMEGA328P)
  3. 2x NRF24L01 Module
  4. 0.96” OLED Display (I2C)
  5. 1x Buzzer
  6. 3x Push Buttons (Menu Config)
  7. 3x Toggle Switches (Load Controls)
  8. 2x 3.3v modules
  9. Resistors (10kΞ© for buttons)
  10. LED’s with Holders
  11. LM2596 DC-DC Step Down Buck Converter.
  12. Power Supply (12V, 1A adapter)
  13. 1N4007 Diode
  14. Junction Box Enclosure

You can get all the components from JLCMC.


βš™οΈ Features & Functionality

️ ESP32 Hub:

  1. Menu Config with Buttons: Select sensor nodes, toggle alert modes, view system status, set on and off timer.
  2. Switch Control: Toggle connected relays/lights/appliances via physical switches.
  3. OLED UI: Real-time display of sensor data and system state.
  4. NRF24 Communication: Receives sensor alerts wirelessly from multiple nodes.


Arduino(ATMEGA328P) – Real-Time Monitoring

The Arduino board acts as a dedicated alert node, responsible for monitoring key safety and automation components:

  1. Door Sensors: Detect open/close status using reed switches to monitor unauthorized access or entry.
  2. Gas Leakage Sensors: Continuously checks for gas leaks (e.g., LPG, methane) using MQ-series sensors.
  3. Automatic Doorbell: Detects presence using PIR or button press, triggering a doorbell alert.
  4. LED Indicators: Four LEDs light up based on which sensor was triggered (e.g., door, gas, motion).
  5. Buzzer Alerts: A loud buzzer activates when any sensor detects a fault or presence.

This node communicates all alerts wirelessly to the ESP32, enabling quick and centralized display or action.

Interface the NRF24L01 With the ESP32 Wroom.

1. HUB_CIRCUIT_ESP32.jpg
[NRF24L01]
GPIO 18 --------> SCK
GPIO 23 --------> MOSI
GPIO 19 --------> MISO
GPIO 5 --------> CSN
GPIO 4 --------> CE

Interface the OLED With the ESP32 Wroom.

2. HUB_CIRCUIT_ESP32.jpg
[ESP32] [OLED (I2C)]
GPIO 21 --------> SDA
GPIO 22 --------> SCL

Interface the Menu Buttons With the ESP32 Wroom.

3. HUB_CIRCUIT_ESP32.jpg
[Menu Buttons] GPIO 32, 33, 34 --> Buttons (Pulldown with 10kΞ©)
[Switches] GPIO 25, 26, 27 --> Switches for Load Control

Interface the Buzzer Along With 1N4007 Diode the ESP32 Wroom.

4. HUB_CIRCUIT_ESP32.jpg
[Buzzer] GPIO 15 --> Buzzer for Alert

Interface the NRF24L01 With the Arduino Uno(ATMEGA328P) IC.

1. HUB_CIRCUIT_ARDUINO.jpg
[NRF24L01]
D13 --------> SCK
D11 --------> MOSI
D12 --------> MISO
D10 --------> CSN
D9 --------> CE

Interface the LED’s With the Arduino Uno(ATMEGA328P) IC.

2. HUB_CIRCUIT_ARDUINO.jpg
[Alert LEDs]
D2, D3, D4, D5 --> LEDs (with 220Ξ© resistors)

Interface the Buzzer Along With the 1N4007 Diode to the Arduino Uno(ATMEGA328P) IC.

3. HUB_CIRCUIT_ARDUINO.jpg
[Buzzer]
D6 --> Buzzer (+) with Diode

πŸ’‘ Why Use Two MCUs?

Using both ESP32 and Arduino in tandem enables dedicated multitasking:

  1. ESP32 handles UI, OLED, user inputs, and load control switches.

  2. Arduino handles sensor checks, immediate alerts, and outputs (buzzer, LEDs).

This ensures smooth performance, better fault isolation, and real-time response without compromising interface usability.

πŸ” NRF24L01 Communication Logic

Arduino:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE 9
#define CSN 10
#define BUZZER A0
#define DOOR_STATUS_LED 8

RF24 radio(CE, CSN); // CE, CSN
const byte address[6] = "10001";

// Define data structure
struct data {
uint8_t nodeId;
uint8_t nodeState;
uint8_t doorState;
};

unsigned long previousMillis = 0;
bool buzzerState = false;
// bool wasDisconnected = false; // Flag to track disconnection state

void setup() {
Serial.begin(115200);
Serial.println("\nInitializing...");
pinMode(DOOR_STATUS_LED, OUTPUT);
pinMode(BUZZER, OUTPUT);
NRF24_Init();
}

void loop() {
if (radio.available()) {
struct data receiveData;
radio.read(&receiveData, sizeof(receiveData));
Serial.print("ID: ");
Serial.print(receiveData.nodeId);
Serial.print(", Status: ");
Serial.print(receiveData.nodeState);
Serial.print(", Door: ");
Serial.println(receiveData.doorState);
digitalWrite(DOOR_STATUS_LED, receiveData.doorState);
// digitalWrite(BUZZER, receiveData.doorState == 1 ? HIGH : LOW);
buzzer(receiveData.doorState, 100);
}
}

void NRF24_Init() {
if (!radio.begin()) {
Serial.println("❌ NRF24L01 Initialization Failed!");
return;
}
radio.openReadingPipe(1, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
Serial.println("βœ… NRF24L01 Initialized Successfully!");
}

void buzzer(int signal, int delayTime) {
if (signal == 1) {
if (millis() - previousMillis >= delayTime) {
previousMillis = millis();
buzzerState = !buzzerState;
digitalWrite(BUZZER, buzzerState);
}
} else {
digitalWrite(BUZZER, LOW);
}
}


ESP32 Hub:

As this is the door sensor alert, menu config is not required.
Coming soon in the next upcoming projects.

JLCMC

b5e02d8c682745f9a7b0ef29279c35ce (1).jpg

Sponsored by JLCMC: Your Go-To Partner for Mechanical Parts!

Introducing JLCMC, the newest addition to the trusted JLC family, delivering high-quality mechanical parts at the best prices in the market. With a legacy of excellence established by JLCPCB, JLCMC is here to provide reliable and affordable solutions for all your mechanical needs.

Why Choose JLCMC?


  1. A Trusted Name: JLCMC is built on the foundation of JLC services, a global leader in PCB manufacturing and prototyping. Their commitment to quality and customer satisfaction carries forward into their mechanical parts services.
  2. Unbeatable Prices: True to the JLC legacy, JLCMC offers mechanical parts at industry-leading prices, ensuring that your projects stay on budget without compromising on quality.
  3. Wide Range of Products: From precision-engineered components to custom solutions, JLCMC has everything you need to bring your ideas to life, whether you're a hobbyist or a professional.
  4. Global Trust: JLC services have earned the trust of millions of makers worldwide. With JLCMC, you get the same reliability, now in the realm of mechanical parts.

🎬 Conclusion

This DIY wireless sensor hub is a powerful example of how multi-MCU architecture can improve performance and system reliability. By using ESP32 for UI and control, and Arduino for sensor alerts, you get a robust, modular platform suitable for home automation, safety systems, and IoT projects.


πŸ”Ή Follow MK Inventions

πŸ“Œ YouTube: MKinventions

πŸ“Œ Facebook: MKinventions & Robotics

πŸ“Œ Instagram: @madhan_chiruguri

πŸ“Œ Hackster.io: mkinventions100

πŸ“Œ DF Robot: MKinventions Madhan

πŸ“Œ Instructables: Madhan Kumar Chiruguri

Stay tuned for more Home Automation projects! πŸš€

Tutorial Video