Energy-Efficient Alert Propagation System

Group Project – Demonstration Website

View on GitHub

Arduino Architecture

The firmware is split into two cooperating sketches:

The flow-level view is captured in the diagrams below, while the rest of this page documents the concrete behavior that appears in the code.

Node Flow

Gateway Loop Flow


Sensor Node Firmware (ESP-Node.ino)

Hardware and libraries

Power and timing strategy

Sensor publishing flow

  1. Read temperature and humidity from the DHT11.
  2. Skip transmission if the temperature has not changed since the previous send (lastSentTemp).
  3. Populate the packed struct:
    • int nodeID
    • float temp
    • float hum
  4. Send via esp_now_send to the hard-coded gateway MAC 0xF0F5BDFB26B4.
  5. Update lastSentTemp only on successful send.

LED handling


Gateway Firmware (ESP-Gateway.ino)

Connectivity and peers

MQTT topics

Data handling pipeline

  1. OnDataRecv copies the packed sensor_data struct and records temperature, humidity, last update timestamp, and active state per node.
  2. Every 5 seconds (publishInterval = 5000), publishToNodeRED() emits a JSON payload of the form { "d": { node1_temp, node1_hum, ... }, "alarm": bool, "threshold": value } on EnvPublish4482 when MQTT is connected.
  3. Threshold updates arrive as JSON on ThreshCheck4482 and directly adjust TEMP_THRESHOLD.
  4. checkTemperatureThreshold() sets alarmActive if any active node exceeds the current threshold within the last 30 seconds.

LED strategy

Reliability aspects


Data and LED Flow Summary

  1. Nodes wake, sample, and send only when the temperature changes, minimizing airtime and energy use.
  2. Gateway ingests ESP-NOW frames, mirrors LED status back to the sender, and updates MQTT clients with the aggregated view.
  3. Node-RED consumes EnvPublish4482, displays dashboards, and can publish threshold or LED override commands that immediately influence gateway logic.
  4. LED commands remain synchronized due to the periodic gateway broadcast and the node’s 10-second listening window after each send.

These behaviors correspond to the flowcharts above and the detailed Node-RED accompaniment documented in docs/node_arch.md.