Close

Address setting

A project log for Green Detect

Wireless Sensor Network Platform (WSN) , for enviromental monitoring

sergio-ghirardelliSergio Ghirardelli 10/05/2022 at 20:500 Comments

The Green Detect network can include 60 nodes, each of which has its own communication address.

The address in the ESP-NOW network is the Mac Address of the ESP8266 and is unique for each microcontroller.

In order to facilitate communication between the various modules, I decided to manually preset the address, in order to establish a common root for all modules belonging to the network.

In practice, the first 5 bytes are the same for all nodes, while the value of the sixth byte has an initial value of 0x00.

The numbers assigned to the first 5 bytes are decided by the user who writes them only once directly into the Arduino IDE sketch to be loaded into all the microcontrollers on the network.

Address setting

The last byte is the one that will identify the node within the network: this number is the sensor address that is programmed by the user directly on the module board.

The first module on the network (the one that initiates data synchronization) must have address # 1. The subsequent modules must have a progressive address (2... 3 ... 4….) up to a maximum of 60.

Therefore each intermediate module ( with address #n) is automatically set to receive data from node # n-1 and to transmit data to node # n + 1.

How to set the address?

The easiest way would have been to install dip switches in which to set the address directly, but to get to 60, I needed 6 bits, so I occupied 6 digital inputs only for the address!

It would have been a waste, which would have prevented me from using ESP8266.

So I decided to do this:

I used 2 buttons and 2 LEDs.

I have created a "program" mode that can be activated by pressing the 2 buttons (SW1 and SW2) simultaneously.

The first programming step is for setting the module address.

User can press SW1 to increment the ones and press SW2 to increment the tens (second button).

The number of blinks of the LEDs is the feedback that indicates to the user how many ones and how many tens.

When the user press again both buttons, the address programming step is over.

The address value is stored on microcontroller flash memory at the end of program mode.

Last module setting

The last module of the network communicates directly with the gateway to which I have decided to give address # 99.

So the last node on the network must not transmit data to # n + 1, but to address # 99.

To set a module as the last one, I decided to add a step to the program mode, in which the user can set the module as "last" by pressing SW2 (led 2 blinks quickly) or as "not last" by pressing Sw1 (led 1 blinks quickly)

In the next log I will describe the next programming step, the one to set the sensor type.

Discussions