0% found this document useful (0 votes)
29 views3 pages

Gateway Module Firmware Document

The Gateway Module Firmware Document outlines the functionality of a gateway module that receives sensor data from measurement modules via ESP_NOW and sends it to Notehub Cloud. It details the hardware components, software development environment, and the process of receiving and formatting sensor data for transmission. Additionally, it describes the configuration of the Notecard for managing data communication intervals and health checks.

Uploaded by

ronald.sanchez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Gateway Module Firmware Document

The Gateway Module Firmware Document outlines the functionality of a gateway module that receives sensor data from measurement modules via ESP_NOW and sends it to Notehub Cloud. It details the hardware components, software development environment, and the process of receiving and formatting sensor data for transmission. Additionally, it describes the configuration of the Notecard for managing data communication intervals and health checks.

Uploaded by

ronald.sanchez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Gateway Module Firmware Document

Introduction
Gateway module acts as a ESP_Now receiver node in a network containing a group of
Measurement Modules, which listens to the line (WIFI ESP_NOW) and receives sensors data
from them and sends them to the Notehub Cloud through a NoteCard and Note Carrier.

Hardware
Hardware containing the GatewayModule are:
NoteCard: NOTE-NBGL-500
Note Carrier: SparkX Qwiic Cellular
Development Board: Spark Fun Esp32-S2 Think Plus

Software Development Environment and config


The firmware is developed in VisualStudio Code IDE with PlatformIO in Arduino framework and
c and cpp language.

ESP_NOW Receive
Sensor data from measurement modules is received by initializing ESP_NOW in the [Link].
setup () function, which invokes the espnowSetup () function. This function initializes WIFI for
ESP_NOW communication and also activates the callback function to receive messages as an
interrupt. The call-back function is
void onReceive(const uint8_t *mac_addr, const uint8_t *data, int data_len)
In [Link] file. This function extracts received data from each Measurement
Module and saves it in the following structure format:

typedef struct measured_data{


int DeviceId;
float tempThermocouple;
float tempSHT30;
float humiditySHT30;
float electricCurrent;
float pulseCountedMin;
float flow;
}measured_data;
NoteHub Messages
Sensor data messages received from Measurement Modules via ESP_Now should be
rearranged in a format suitable for Enerinno Dashboard. This is done by invoking
insertSensorDataToHyper() function in [Link](). This function checks if a new message
is received from a Measurement Module, then adds it or replaces it in the array

SensorDataPair HyperSensorsData[600];
Of this struct:
typedef struct SensorDataPair
{String index;
float value;
bool sentStatus;
}SensorDataPair;

The elements of the above struct are determined in the following way:
Index = "&0X"+String(([Link]-1)*6)+Offset
The Offset depends on the measured quantity as:
0 : for Electric Current
1: for temperature form thermocouple
2: for temperature from SHT30 sensor
3: for humidity from SHT30 sensor
4: for digital pulse counted

The final message format to be sent to Notehub is a json message of collection :


"[Link]&0X103": 51.25
“GatewayModule MAC Address +&0x +Idex (as described above)“: sensor value
For all sensor values in the network not sent yet.
The message is sent to Notehub in [Link]() by calling the function SendToNoteHub()
which is called in a scheduled time interval, now every 5 minutes.
Notecard Configuration
The Notecard setup is done as follows:
[Link]("Sending request [Link] ");
JAddStringToObject(req, "product", "[Link]:enerinno");
JAddStringToObject(req, "mode", "periodic"); // Use 'periodic' mode
JAddNumberToObject(req, "inbound", 15); // Check inbound messages every 15 minutes
JAddNumberToObject(req, "outbound", 15); // Sync outbound messages every 15 minutes
JAddStringToObject(req, "health", "periodic"); // Enable periodic health checks
JAddNumberToObject(req, "health-interval", 60); // Set health check interval to 1 hour

Which is done in
void Note_Card::setupNoteCard() function.
This function is defined and declared in Note_Card.cpp and Note_Card.h files. The setup
function for NoteCard is invoked in [Link]().

You might also like