GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - joamu03/temperature-monitoring-station: Embedded temperature monitoring station featuring real-time sensor acquisition, threshold alert validation, data logging, and serial telemetry visualization. Includes modular source code and a comprehensive technical engineering report.

BranchesTags
Open more actions menu

Latest commit

 

History

5 Commits
5 Commits

Folders and files

NameName
Last commit message
Last commit date
assets
assets
 
 
data
data
 
 
docs
docs
 
 
firmware/StandardFirmata
firmware/StandardFirmata
 
 
src
src
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

Temperature Monitoring and Tracking Station

Python C Arduino Networking License

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).


Executive Summary

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:

  1. Part A — Multi-Threaded Hardware Station (src/station/temperature_station.py): Interfaces with an Arduino UNO running StandardFirmata over 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.
  2. 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.
  3. 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.

Hardware Architecture & Mathematical Models

Electronic Circuit & Pinout

Component Arduino UNO Pin Mode Description
Temperature Sensor / Potentiometer A0 Analog Input Normalized voltage reading $[0.0, 1.0]$ scaled to $[0, 100],^\circ\text{C}$
Control Push-Button D6 Digital Input Pull-down configuration for cycle timing & graceful shutdown
Green LED D8 Digital Output Indicates Low temperature trend (below $-5%$ of moving average)
Yellow LED D9 Digital Output Indicates Stable temperature trend (within $\pm 5%$ of moving average)
Red LED D10 Digital Output Indicates High temperature trend (above $+5%$ of moving average)

Arduino UNO Circuit Schematic
Figure 1: Arduino UNO electronic schematic showing traffic-light LEDs, push-button, and analog sensor input.

Physical Breadboard Implementation
Figure 2: Physical breadboard prototype using a 0V–5V potentiometer on pin A0 to simulate analog thermal excursions.


Mathematical Formulation

1. Moving-Average Trend Classification (Part A)

Given a sequence of temperature readings $\lbrace T_1, T_2, \dots, T_k \rbrace$ sampled at period $T_s \in [2.5, 10.0],\text{s}$ (default $T_s = 3.5,\text{s}$), the sliding moving average over window size $N = 5$ is:

$$ \bar{T}_N(k) = \frac{1}{N} \sum_{i=k-N+1}^{k} T_i, \quad k \ge N $$

With a percentage deadband threshold $\delta = 5$, the active trend state is classified as:

$$ \text{Trend}(T_k) = \begin{cases} \text{Undefined}, & k < N \quad (\text{All 3 LEDs ON}) \\ \text{High}, & T_k > \left(1 + \dfrac{\delta}{100}\right)\bar{T}_N(k) \quad (\text{Red LED ON}) \\ \text{Low}, & T_k < \left(1 - \dfrac{\delta}{100}\right)\bar{T}_N(k) \quad (\text{Green LED ON}) \\ \text{Stable}, & \left(1 - \dfrac{\delta}{100}\right)\bar{T}_N(k) \le T_k \le \left(1 + \dfrac{\delta}{100}\right)\bar{T}_N(k) \quad (\text{Yellow LED ON}) \end{cases} $$

2. Push-Button Cycle Reconfiguration Law (Part A)

When the push-button on pin D6 is held for duration $t_{\text{hold}}$ (flashing all LEDs for $50,\text{ms}$ once per elapsed second), the sampling period $T_s$ is updated upon release according to:

$$ T_s^{\text{new}} = \begin{cases} \text{Terminate System}, & t_{\text{hold}} < 1.0,\text{s} \\ 2.5,\text{s}, & 1.0,\text{s} \le t_{\text{hold}} \le 2.5,\text{s} \\ t_{\text{hold}}, & 2.5,\text{s} < t_{\text{hold}} \le 10.0,\text{s} \\ 10.0,\text{s}, & t_{\text{hold}} > 10.0,\text{s} \end{cases} $$

Multi-Threaded Execution Flowchart
Figure 3: Concurrent execution flowchart across the Button Monitor, Sensor Acquisition, and LED Controller threads.

3. Real-Time Statistical Metrics (Part B)

Over $n$ cumulative readings sorted in ascending order $x_{(1)} \le x_{(2)} \le \dots \le x_{(n)}$ via recursive QuickSort ($\mathcal{O}(n \log n)$ average time complexity), the C analytics engine evaluates:

Arithmetic Mean:

$$ \mu = \frac{1}{n} \sum_{i=1}^{n} x_i $$

Exact Median:

$$ \text{Median} = \begin{cases} x_{((n+1)/2)}, & \text{if } n \text{ is odd} \\ \dfrac{x_{(n/2)} + x_{(n/2 + 1)}}{2}, & \text{if } n \text{ is even} \end{cases} $$

Population Standard Deviation:

$$ \sigma = \sqrt{\frac{1}{n} \sum_{i=1}^{n} (x_i - \mu)^2} $$

Modal Interval:

Partitions the measurement domain $[0, 100],^\circ\text{C}$ into $100$ unit intervals $[j-1, j]$ grouped into $\sqrt{100} = 10$ macro-buckets of width $10$, locating the modal bin in at most $20$ comparisons per sample.

QuickSort Partitioning Diagram
Figure 4: Recursive QuickSort partitioning around a pivot element.


Repository Structure

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

Installation & Setup

Prerequisites

  • 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.ino to a physical Arduino UNO)

1. Clone the Repository

git clone https://github.com/joamu03/temperature-monitoring-station.git
cd temperature-monitoring-station

2. Create and Activate a Virtual Environment

Windows (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.txt

3. Compile the C Statistical Analysis Engine (Part B)

gcc -Wall -Wextra -O2 src/analytics/statistics_engine.c -o statistics_engine -lm

Usage Guide

Option A: Running with Physical Arduino UNO Hardware

  1. Open firmware/StandardFirmata/StandardFirmata.ino in the Arduino IDE and upload it to your Arduino UNO.
  2. Verify the serial port in src/config.py (default: COM5, or override via environment variable ARDUINO_PORT=COM3).
  3. Start the monitoring station:
    python -m src.station.temperature_station

Option B: Running with the Hardware-Free Sensor Simulator

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

Running Part B: Real-Time C Statistical Engine

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

Running Part C: TCP/IPv4 Telemetry Server & Real-Time Plot Client

  1. Start the TCP telemetry server:
    python -m src.telemetry.telemetry_server --host 0.0.0.0 --port 15000
  2. 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

Real-Time Telemetry Plot
Figure 5: Live Matplotlib telemetry chart with trend-colored segments (Red = High, Orange = Stable, Green = Low) and the 5-sample moving average curve.


Running Automated Tests

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

Technical Report

The complete academic technical report is available in docs/Technical_Report.pdf alongside its LaTeX source docs/Technical_Report.tex.


Authors

  • Ángel Chen
  • Alessandro Comisso
  • Joaquín Muñoz (@joamu03)

Mechatronics Engineering — National University of Cuyo (UNCUYO)


License

This project is licensed under the MIT License. See LICENSE for full details.

About

Embedded temperature monitoring station featuring real-time sensor acquisition, threshold alert validation, data logging, and serial telemetry visualization. Includes modular source code and a comprehensive technical engineering report.

Topics

automationdata-adquisitionembedded-systemsengineeringinstrumentationmechatronicssensorsserial-communicationtelemetrytemperature-monitoring

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402809 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.