A modular, real-time Temperature Monitoring, Statistical Analytics, and Remote TCP/IPv4 Telemetry Station integrating an Arduino UNO hardware acquisition interface (pyFirmata), a high-performance C statistical engine using dynamic memory and QuickSort, and a Python TCP/IPv4 client-server visualization pipeline (matplotlib & numpy).
Designed for real-time environmental and industrial thermal supervision, this system decouples physical sensor acquisition, low-level statistical processing, and remote visualization into three interoperable subsystems:
- Part A — Multi-Threaded Hardware Station (
src/station/temperature_station.py): Interfaces with an Arduino UNO runningStandardFirmataover serial. It coordinates three concurrent threads to acquire analog temperature measurements, classify thermal trends against a sliding moving average, actuate a 3-LED traffic-light indicator, dynamically reconfigure the sampling period via a physical push-button, and persist measurements to disk. A standalone hardware-free simulator (src/station/sensor_simulator.py) is also provided for testing without physical Arduino hardware. - Part B — Real-Time Statistical Analysis Engine in C (
src/analytics/statistics_engine.c): Monitors file modification events on the station's IPC status file (data/current_reading.txt), stores observations in dynamically resized heap memory (malloc/realloc), sorts samples via recursive QuickSort, and computes in real time: sample count, historical minimum/maximum with timestamps, arithmetic mean, exact median, modal unit interval, and standard deviation. - Part C — TCP/IPv4 Telemetry Server & Real-Time Visualization Client (
src/telemetry/): Streams UTF-8 encoded temperature and trend packets over TCP/IPv4 sockets from the acquisition host to remote monitoring clients, rendering a live, color-coded Matplotlib chart overlaid with a 5-sample moving average curve.
| Component | Arduino UNO Pin | Mode | Description |
|---|---|---|---|
| Temperature Sensor / Potentiometer | A0 |
Analog Input | Normalized voltage reading |
| Control Push-Button | D6 |
Digital Input | Pull-down configuration for cycle timing & graceful shutdown |
| Green LED | D8 |
Digital Output | Indicates Low temperature trend (below |
| Yellow LED | D9 |
Digital Output | Indicates Stable temperature trend (within |
| Red LED | D10 |
Digital Output | Indicates High temperature trend (above |
Figure 1: Arduino UNO electronic schematic showing traffic-light LEDs, push-button, and analog sensor input.
Figure 2: Physical breadboard prototype using a 0V–5V potentiometer on pin A0 to simulate analog thermal excursions.
Given a sequence of temperature readings
With a percentage deadband threshold
When the push-button on pin D6 is held for duration
Figure 3: Concurrent execution flowchart across the Button Monitor, Sensor Acquisition, and LED Controller threads.
Over
Arithmetic Mean:
Exact Median:
Population Standard Deviation:
Modal Interval:
Partitions the measurement domain
Figure 4: Recursive QuickSort partitioning around a pivot element.
temperature-monitoring-station/
├── assets/
│ ├── arduino_schematic.png # Circuit schematic diagram
│ ├── hardware_prototype.png # Physical Arduino UNO + breadboard prototype
│ ├── quicksort_diagram.png # QuickSort recursive partitioning diagram
│ ├── realtime_plot_demo.png # Real-time Matplotlib telemetry visualization
│ └── system_flowchart.png # Multi-threaded station execution flowchart
├── data/
│ └── .gitkeep # Runtime IPC & log files (current_reading.txt, temperature_log.txt)
├── docs/
│ ├── Technical_Report.pdf # Final compiled Technical Report in English
│ └── Technical_Report.tex # Academic LaTeX source of the Technical Report
├── firmware/
│ └── StandardFirmata/
│ ├── LICENSE.txt # Firmata firmware license
│ └── StandardFirmata.ino # Official Firmata sketch for Arduino UNO
├── src/
│ ├── __init__.py
│ ├── config.py # Centralized hardware, timing, file, and network constants
│ ├── analytics/
│ │ └── statistics_engine.c # Part B: Real-time statistical analysis engine in C
│ ├── station/
│ │ ├── __init__.py
│ │ ├── sensor_simulator.py # Hardware-free sensor simulator for testing Parts B & C
│ │ └── temperature_station.py # Part A: Multi-threaded Arduino Firmata controller
│ └── telemetry/
│ ├── __init__.py
│ ├── telemetry_client.py # Part C: Real-time TCP/IPv4 Matplotlib plotting client
│ └── telemetry_server.py # Part C: TCP/IPv4 telemetry streaming server
├── tests/
│ ├── __init__.py
│ └── test_station_logic.py # Unit test suite for trend logic, IPC formatting, and telemetry
├── .gitignore
├── LICENSE # MIT License
├── README.md
└── requirements.txt # Exact Python dependencies
- Python: 3.10 or higher
- C Compiler:
gcc(MinGW-w64 / MSYS2 on Windows, or GCC/Clang on Linux/macOS) - Arduino IDE (optional, only required when uploading
StandardFirmata.inoto a physical Arduino UNO)
git clone https://github.com/joamu03/temperature-monitoring-station.git
cd temperature-monitoring-stationWindows (PowerShell):
python -m venv .venv .\.venv\Scripts\Activate.ps1 pip install -r requirements.txt
Linux / macOS:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtgcc -Wall -Wextra -O2 src/analytics/statistics_engine.c -o statistics_engine -lm
- Open
firmware/StandardFirmata/StandardFirmata.inoin the Arduino IDE and upload it to your Arduino UNO. - Verify the serial port in
src/config.py(default:COM5, or override via environment variableARDUINO_PORT=COM3). - Start the monitoring station:
python -m src.station.temperature_station
If no Arduino board is connected, run the built-in simulator to generate real-time measurements in data/current_reading.txt and data/temperature_log.txt:
python -m src.station.sensor_simulator --cycle 1.5
In a second terminal (while Part A or the simulator is running), launch the compiled C engine:
./statistics_engine data/current_reading.txt 100
Sample output:
[20.00, 23.00, 37.00, 48.00, 48.00, 57.00, 71.00, 75.00, 75.00, 93.00]
Total readings processed: 10
Date: 2025-11-05
Time: 13:26:16
Minimum: 20.00 deg C, Date: 2025-11-05, Time: 13:26:07
Maximum: 93.00 deg C, Date: 2025-11-05, Time: 13:26:09
Mean: 54.70 deg C
Mode interval: [75, 76] deg C
Median: 52.50 deg C
Standard Deviation: 22.75 deg C
- Start the TCP telemetry server:
python -m src.telemetry.telemetry_server --host 0.0.0.0 --port 15000
- In another terminal (on the same machine or a remote workstation on the LAN), launch the interactive Matplotlib client:
python -m src.telemetry.telemetry_client --host 127.0.0.1 --port 15000 --max-readings 100
Figure 5: Live Matplotlib telemetry chart with trend-colored segments (Red = High, Orange = Stable, Green = Low) and the 5-sample moving average curve.
Execute the unit test suite verifying ADC scaling, moving-average window gating, trend classification, push-button duration thresholds, IPC file formatting, and TCP payload serialization:
python -m unittest discover -s tests -v
The complete academic technical report is available in docs/Technical_Report.pdf alongside its LaTeX source docs/Technical_Report.tex.
- Ángel Chen
- Alessandro Comisso
- Joaquín Muñoz (@joamu03)
Mechatronics Engineering — National University of Cuyo (UNCUYO)
This project is licensed under the MIT License. See LICENSE for full details.