STM32 B.Tech/Diploma Beginner

STM32 NRF24L01 Sensor Node with ESP32 NRF24L01 Gateway

Monitor sensor data wirelessly using NRF24L01 STM32 ESP32 Module. STM32F103C NRF24L01 BME280 Sensor Node with ESP32 NRF24L01 Wifi Gateway Code

  • Suitable forB.Tech/Diploma STM32 students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

Overview
In this project, we will monitor the sensor data wirelessly using the NRF24L01 STM32 Board & ESP32 Wifi Module. We will first make a Wireless Sensor Node. A sensor node is made up of four basic components such as sensing unit, processing unit, transceiver unit, and a power unit. The Sensing unit can be made up of any Sensor. I am using the BME280 Barometric Pressure Sensor. The processing unit is the STM32F103C Microcontroller and the transceiver unit is the NRF24L01 2.4 GHz Wireless transceiver Module which works as a transmitter unit. While considering the power unit, the device can be powered up using 3.7V Lithium-Ion Battery.
We will make Wifi Gateway using ESP32 Wifi Module & NRF24L01 Module. An IoT gateway performs several critical functions from translating protocols to encrypting, processing, managing, and filtering data. If you imagine an IoT ecosystem, a gateway sits between devices and sensors to communicate with the cloud. In this project, the gateway collects the sensor data from multiple sensor nodes, and using the wifi network it uploads the data to the cloud. The cloud server that we are using here is the Thingspeak Server. ThingSpeak is an open-source Internet of Things application and API to store and retrieve data from things using the HTTP and MQTT protocol over the Internet or via a Local Area Network.
In one of our previous project we made a gateway using ESP8266 & NRF24L01 & Sensor Node using Arduino & NRF24L01. You can check the project here:
NRF24L01 Gateway + Node
Bill of Materials
All the components required for making the gateway and sensor node is listed below. You can purchase all of the components from Amazon.
S.N.
Components Name
Quantity
Purchase Links

ESP32 Board

Amazon
AliExpress

STM32 Microcontroller

Amazon
AliExpress

NRF24L01 PA+LNA

Amazon
AliExpress

BME280 Barometric Pressure Sensor

Amazon
AliExpress

Power Supply 5V

Amazon
AliExpress

Connecting Wires

Amazon
AliExpress

Breadboard

Amazon
AliExpress
NRF24L01 Module
The
nRF24L01
is a wireless
transceiver module
, i.e. each module can both send & receive data. It works within the frequency of
2.4GHz
. This frequency falls under the
ISM band
and is legal to use in most countries for engineering projects. The modules when operated efficiently can cover a distance of
100 meters
The module operates at
3.3V
but its SPI pins are 5V tolerable. Each module has an
address range
of

and every module can communicate with 6 other modules hence mesh networking can be established with this module. The NRF24L01 module works with the help of
SPI communications
hence you can use NRF24L01 with any microcontroller with SPI Pins like STM32 or Arduino Boards.
Sensor Node Using NRF24L01 & STM32F103C
Let us see the Sensor Node Circuit. We can use any microcontroller with NRF24L01 for designing a Sensor Node. For example, STM32F103C Bluepill Board is the best option. Apart from the microcontroller, you can use any sensor and interface it with STM32 Board. I prefer BME280 Barometric Pressure Sensor for demonstration purpose.
The connection between STM32F103C Board, NRF24L01 Wireless Transceiver Module &
BME280 Sensor
is given below.
NRF24L01
VCC
…………………………………………
3.3V
of STM32F103C
NRF24L01
CSN
…………………………………………
PA4
of STM32F103C
NRF24L01
MOSI
…………………………………………
PA7
of STM32F103C
NRF24L01
GND
…………………………………………
GND
of STM32F103C
NRF24L01
CE
…………………………………………
PB0
of STM32F103C
NRF24L01
SCK
…………………………………………
PA5
of STM32F103C
NRF24L01
MISO
…………………………………………
PA6
of STM32F103C
You can also design a simple Sender and Receiver Circuit with a pair of NRF24L01 & STM32 Board. Check it here:
Interfacing NRF24L01 Transceiver Module with STM32
WiFi Gateway Using NRF24L01 & ESP32
The Gateway receives the data from the single or multiple Sensor Node using the NRF24L01 Transceiver Module. After receiving data it uploads the data to Server. For establishing a connection with the Server, the WiFi Network can be used. The ESP32 along with NRF24L01 is best preferred for designing the WiFi Gateway.
The connection between ESP32 Board & NRF24L01 Wireless Transceiver Module is given below.
NRF24L01
VCC
…………………………………………
3.3V
of ESP32
NRF24L01
CSN
…………………………………………
D5
of ESP32
NRF24L01
MOSI
…………………………………………
D23
of ESP32
NRF24L01
GND
…………………………………………
GND
of ESP32
NRF24L01
CE
…………………………………………
D4
of ESP32
NRF24L01
SCK
…………………………………………
D18
of ESP32
NRF24L01
MISO
…………………………………………
D19
of ESP32
Project PCB Gerber File & PCB Ordering Online
If you don’t want to assemble the circuit on breadboard and you want PCB for the project, then here is the PCB for you. The PCB Board for the ESP32 NRF24L01 Gateway & STM32 NRF24L01 Node is designed using
EasyEDA
online Circuit Schematics & PCB designing tool. The image of the Sender PCB is given below.
The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from
ALLPCB
at
1$
only.
Download Gerber File for Node PCB:
Sender PCB
Download Gerber File for Gateway PCB:
Receiver PCB
You can use this Gerber file to order high quality PCB for this project. To do that visit the
ALLPCB
official website by clicking here:
https://www.allpcb.com/
You can now upload the Gerber File by choosing the Quote Now option. From these options, you can choose the Material Type, Dimensions, Quantity, Thickness, Solder Mask Color and other required parameters.
After filling all details, select your country and shipping method. Finally you can place the order.
Library Installation
1. BME280 Library
The BME280 library provides a library for reading and interpreting Bosch BME280 environmental sensor data over I2C, SPI or Sw SPI. It reads the temperature, humidity, and pressure by including environment calculations.
Download BME280 Library
2. NRF24L01 Library
The STM32 Board doesn’t support
nRF24L01 RadioHead Library
(
#include <RH_NRF24.h>
). Hence we need to use RF24 Library. This library is designed to be maximally compliant with the intended operation of the chip & built against the standard SPI library. You can download the library from the following Github link. Add the library to the Arduino IDE.
Download NRF24L01 Library
Setting Up Thingspeak Server
ThingSpeak is an IoT analytics platform service that allows you to aggregate, visualize, and analyze live data streams in the cloud. You can send data to ThingSpeak from your devices, create instant visualization of live data, and send alerts.
We need to Setup Thingspeak dashboard to receive the data and display in graphical format. You can visit
Thingspeak
and create an account here.
Create a New Channel with the following Parameters as shown in the image below. After filling all these details, click on the Save channel.
Go to the API Key and copy the Write API Key. The API key is required in the Gateway Code.
Source Code/Program for Sensor Node

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24
radio
(
PB0
PA4
)
;
// CE, CSN on Blue Pill
const
uint64_t
address
=
0xF0F0F0F0E1LL
;
int
counter
=

;
float
temperature
;
float
humidity
;
float
altitude
;
float
pressure
;
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280
bme
;
struct
MyData
{
int
counter
;
float
temperature
;
float
humidity
;
float
altitude
;
float
pressure
;
}
;
MyData
data
;
void
setup
(
)
{
Serial
begin
(
115200
)
;
radio
begin
(
)
;
//Starting the Wireless communication
radio
openWritingPipe
(
address
)
;
//Setting the address where we will send the data
radio
setPALevel
(
RF24_PA_MIN
)
;
//You can set it as minimum or maximum depending on the distance between the transmitter and receiver.
r

Technologies used

ESP32ESP8266ArduinoSTM32MQTTThingSpeakWiFiBLEBME280I2CSPIArduino IDE

Hardware components

  • ESP32
  • ESP8266
  • Arduino
  • STM32
  • BME280

Software & tools

  • Arduino IDE
  • ThingSpeak
  • MQTT
  • EasyEDA

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.