Skip to content

Locally operated sensor data collection station in Python

License

Notifications You must be signed in to change notification settings

tapiocode/simple-sensor-station

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple sensor data station

A Python implementation of a system that simply collects and shows measurement BLE broadcasts it has received from any nearby RuuviTag sensors, and possibly others in future versions. The web interface is served on a local address.

The data is stored into a local SQLite database ./readings.db. The frontend is written in plain CSS/JS with everything statically included, which means there is no need to compile or install dependencies.

The script runs concurrently the following subcomponents:

This version has been tested on macOS (Macbook Air M1) and Raspberry Pi OS (Raspberry Pi Zero W 2).

Web interface

The responsive interface should adapt to majority of devices and screen configurations.

Screenshots of different widths

Features

  • Automatically pick up detected tags and show the measurements
  • Automatically recover if server is temporarily unreachable
  • Data is refreshed in 5 second intervals
  • Time is shown relative to current time ("X ago" format)
  • Window/tab title also shows the temperature
  • Sensor stays selected over reloads (only selected MAC stored in sessionStorage)
  • Sensors can be named (max 255 characters)

Installation

Initialize venv (Python virtual environment) in the directory:

# On some systems the command starts "python3"
python -m venv .venv

Activate virtual environment and install dependencies from requirements.txt:

source .venv/bin/activate
pip install -r requirements.txt

Run the system:

./main.py

The script creates the database file (unless it exists), and starts listening to BLE broadcasts until it is shut down.

Once running, the web interface can be seen at http://localhost:8080, or with local IP http://<local-ip>:8080.

Self-hosted frontend resources

Some frontend resources have been statically included to simplify installation and dependency management.

Future developments

  • Add chart graphics to visualize trends (sparkline)
  • Add an API for receiving sensor data over the web
  • Add support for other sensors as well (for example, Raspberry Pi Pico)
  • Add threshold levels that trigger given actions (for example, min/max level that changes text to red)
  • Localizations, Fahrenheit

Licence

MIT

About

Locally operated sensor data collection station in Python

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published