A real-time data collection system built around a wireless sensor network (WSN). Three Arduino-based sensor nodes transmit simulated sensor readings over 433 MHz radio to a single base station, which aggregates, validates, and reports on the incoming data stream in real time.
Built for MREN 178 (Team 04) by Dushyant Saini, Callum Smith, Luka Sijakovski, and Jeffrey Zhao.
The system emulates the core challenges of a real IoT/monitoring deployment — packet loss, burst traffic, duplicate transmissions, and node dropouts — and demonstrates the data structures and algorithms needed to handle them reliably on constrained hardware.
- 3 sensor nodes (Arduino Uno) each transmit a simulated reading over an HC-12 radio transceiver at a fixed interval (3000 / 3200 / 3400 ms)
- 1 base station (Arduino Uno) receives, buffers, and processes all incoming packets, then outputs live diagnostics and a periodic report over Serial and as CSV
[Sensor Node 1] --\
[Sensor Node 2] ---> HC-12 (433 MHz) ---> [Base Station] ---> Serial Monitor / CSV log
[Sensor Node 3] --/
Incoming packets at the base station are pushed into a 4-slot fixed-length circular queue, then dequeued and processed one at a time on the main loop. This decouples packet reception from processing, so bursts of traffic from multiple nodes don't cause dropped packets. The queue uses modulo arithmetic to wrap indices, so no shifting or copying is ever needed. Peak queue depth is tracked and reported every 15 seconds as evidence the buffer is absorbing bursts correctly.
Each node's state (last reading, rolling average, sequence number, packet/anomaly counts, timestamps, connection status) is stored in an array indexed directly by node ID, giving O(1) lookup and update with no search required — important for a real-time system with tight per-packet processing budgets.
Every incoming packet is checked for:
- Anomalies — out-of-range values or values that deviate too far from the node's rolling average
- Duplicates — repeated sequence numbers
- Missed packets — gaps in sequence numbers
- Timeouts — a node is flagged
MISSINGafter 10 seconds of silence, and logged asRECONNECTwhen it resumes
Every 15 seconds the base station prints a performance report (uptime, packets processed/dropped, queue peak, average processing time, free RAM) and a CSV block summarizing each node's status, suitable for pasting into a spreadsheet for analysis.
NODE:<id>,SEQ:<seq>,TS:<timestamp>,VAL:<value>
Simulated sensor values: 92% normal range (20.0–35.0), 5% out-of-range anomaly (80–120), 3% error code (−99.0).
====================
WSN Base Station
====================
[N1] V=24.5 Avg=24.5 S=1 OK P=1 us=162
[N2] V=97.0 Avg=97.0 S=1 ANOMALY P=1 us=170
[MISS] N1 x1 (missed packet detected)
[ALERT] N3 MISSING. (node went silent for 10s)
[RECONNECT] N3 back after 14s. (node came back online)
[BURST] 3 packets in 1s — queue buffering active.
====================
[REPORT]
Uptime(s) : 45
Processed : 12
Dropped : 0
Queue peak: 2
Avg us : 165
Free RAM : 1390
[NODE SUMMARY]
N1|OK |P=5 M=1 A=1 V=24.5 Avg=26.2 Up=45s
N2|ANOMALY |P=4 M=0 A=2 V=97.0 Avg=55.1 Up=42s
N3|MISSING |P=3 M=0 A=0 V=28.1 Avg=27.4 Up=38s
--- CSV ---
Node,Status,Packets,Missed,Anomalies,LastVal,AvgVal,Uptime_s
1,OK,5,1,1,24.5,26.2,45
2,ANOMALY,4,0,2,97.0,55.1,42
3,MISSING,3,0,0,28.1,27.4,38
--- END CSV ---
src/
├── SensorNodeConfigurationCode/ # Sensor node firmware (flash to 3 Arduinos)
├── BaseStationCalibrationCode/ # Base station firmware (flash to 1 Arduino)
└── CalibrationCode/ # One-time HC-12 module calibration sketch
docs/
└── INSTALL.pdf # Full hardware wiring + setup guide
| Qty | Component | Notes |
|---|---|---|
| 4 | Arduino Uno R3 | 1 base station, 3 sensor nodes |
| 4 | HC-12 wireless transceiver | 433 MHz, all set to CH001 @ 9600 baud |
| 20 | Jumper wires (M-F) | HC-12 connections |
| 4 | USB Type-A to Type-B cable | Upload + monitoring |
HC-12 wiring (identical for all 4 Arduinos): VCC → 5V, GND → GND, TXD → Pin 10, RXD → Pin 11, SET → unconnected.
Full step-by-step instructions (calibration, upload order, wiring diagram, troubleshooting) are in docs/INSTALL.pdf. Short version:
- Calibrate every HC-12 module using
src/CalibrationCode/CalibrationCode.ino(one Arduino at a time). - Flash the sensor nodes: open
SensorNodeConfigurationCode.ino, setNODE_IDto1,2, or3andTX_INTERVALto3000,3200, or3400respectively, then upload to each of the 3 node Arduinos. - Flash the base station: upload
BaseStationCalibrationCode.inoto the 4th Arduino and keep it connected to your laptop. - Power the 3 sensor nodes, open the Serial Monitor on the base station at 9600 baud, and reset it — packets should start arriving within seconds.
Requirements: Arduino IDE 1.8+, SoftwareSerial (bundled with the IDE, no extra install needed).
MIT — see LICENSE.