CiferTech

0 %
CIFER
👨‍💻 Working on IoT Project
🌱 Currently learning Ai/ML
C/C++
Python
C#
Embedded sys Board
Arduino
ESP32/ESP8266
RaspberryPI
Learning Process
Ai
ML

IoT NODE ESP-NOW Based Project

بهمن 19, 1400

In this project information from multiple ESP8266 boards via the ESP-NOW communication protocol with a one-to-Many scenario. several ESP boards send the data we want to one board. There is no such thing as a transmitter or receiver in ESP-NOW documents. Each ESP8266 board can be a transmitter or a receiver. However, we will use these terms to describe the status of each board in the project. Visit CiferTech for more tutorials, and be sure to follow my Instagram page to support me.

IoT NODE ESP-NOW Based Project

 

ESP-Now protocol

ESP-NOW  is a wireless communication protocol developed by  Espressif and capable of packet transmission. This protocol enables multiple devices to easily communicate with each other and transfer information optimally between each other. This protocol is similar to the 2.4 GHz wireless connection, often used in wireless mice. Therefore, it is necessary to pair the devices before communicating. This means that the connection is stable after the devices are paired with each other. In other words, if one of your ESPs suddenly shuts down or resets, the connection is established automatically when you restart.

 

Advantages of ESP-NOW protocol 

  • Data transfer up to 250 bytes.
  • Benefit from an encrypted communication.
  • Use  Call Back to notify different layers if data transfer is successful or not.

ESP-NOW protocol limitations  :

  • Maximum limit of 250payload  bytes.
  • Maximum support for 10   encrypted SoftAPs.
  • The maximum number of backups in unencrypted mode is 20.

 

 

The scenario of this project

In this project, we will use the scenario of one Master and several Slaves. In this case, an ESP sends different or identical commands to other ESPs, the idea being that with this scenario you can control several different devices that have an ESP with one ESP32.

 

Project Description

In this project, we used two ESP8266 boards, version 01, which are assembled in a personalized PCB, in one of the boards, or in other words, our nodes, an OLED display is installed to display the received items, and in the other board. A DHT11 sensor is installed to measure temperature and humidity. This way we will be able to collect more data by increasing the nodes.

IoT NODE ESP-NOW Based Project

 

 

Items needed

  1. ESP board based on ESP8266 chip
  2. DHT11 sensor
  3. 10k resistance
  4. Oled display

 

ESP8266 MAC address

Before we learn how to get these MACs, it’s best to learn the meaning and concept of MACs and why they exist at all! Well, if a device is to be connected to the Internet, it will be assigned a total of two addresses, first the ip, which is a logical address, and then the MAC address, which is the physical address for our device and is practically a fingerprint. Today’s smart devices. Also abbreviated MAC letters are Media Access Control. MAC addresses consist of 48 bits with hexadecimal digits and are found with a structure like this xx: xx: xx: xx: xx: xx and each xx is equal to 8 bits or one byte. Look at the picture below! The first 24 bits are specified by the manufacturer of the style card, and the second 24 bits show the number of devices that can be numbered.

 

 

To communicate between  ESP32 boards, we need to know their MAC address, because, in the process of transferring data or pairing each board, it checks the identity of the other board. And each ESP32 has its own MAC address to be authenticated. To get this MAC address, upload the following code in your ESP32. After uploading the code, you can see your MAC address in the Arduino IDE monitor serial. Save the MAC address because we need it in the main project.

 

PCB

In order to establish connections in this project, we use a PCB designed with the help of Altium Designer. This circuit includes the connections required for OLE modules and DHT11 sensor, as well as the power input and serial output to program the board. There is also a relay in this circuit that will not work due to a bug in this version of the PCB.

 

IoT NODE ESP-NOW Based Project IoT NODE ESP-NOW Based Project

 

 

 

 

 

 

 

 

 

 

 

Slave ESP code

The receiver can identify each sender with its unique MAC address. However, processing different MAC addresses on the receiver side can be a bit difficult to identify which board sent which message. Therefore, to make this process easier, we identify each ESP board with a unique number or id. For example, if we use a sender board in this project, its number will be 1, and if another board is added, we will add the ID number in the same way.
 

 

  • This part of the code is the MAC address of the Master board that is entered on all Slave boards.

 

  • In the description, we mentioned that if the number of slaves increases, an ID will be specified for each board, in this line of code, you must make the relevant changes. In fact, each Slave board has its own unique ID.
  • This section deals with the data structure in the ESP-NOW network we use, the first option is the specific id for each board and the other two are for storing our data in this project, which in our scenario is related to temperature and humidity values.
 
IoT NODE ESP-NOW Based Project
 
 
If you encounter any problems in the process of launching and carrying out this project, do not hesitate to ask your question at the end of this post. I will answer your problem as soon as possible. Also, if there is a problem in the code or the execution steps, you can inform in this way.

 

Posted in ESP8266, اینترنت اشیا (iot)Tags:
Write a comment
© 2019 CiferTech. All rights reserved