Modbus sensor communication library
Project description
AtmosPyre
Python interface for Modbus-based environmental sensors.
Why AtmosPyre?
Write sensor drivers in ~100 lines of Python instead of buying expensive vendor software. AtmosPyre provides a consistent API for adding new sensors.
- 💰 No proprietary software licenses needed
- 🔧 Add new sensors quickly
- 🎯 Single API for all sensors
- 📝 Clear documentation and examples
Installation
From PyPI
Recommended installation
For most users, install with the recommended backends:
pip install atmospyre[recommended]
This includes minimalmodbus for Modbus communication and schedule for scheduling.
Minimal installation
Install only the core library (you'll need to install backends separately):
pip install atmospyre
Specific backends
Choose specific backends based on your needs:
# Just Modbus backend
pip install atmospyre[minimalmodbus]
# Just scheduling backend
pip install atmospyre[schedule]
# Combine multiple backends
pip install atmospyre[minimalmodbus,schedule]
# All available backends
pip install atmospyre[all]
From source (cloned repository)
If you've cloned the repository:
# Clone the repository
git clone https://git.iws.uni-stuttgart.de/measurements/atmospyre.git
cd atmospyre
# Install with recommended backends
pip install .[recommended]
# Or install in editable mode for development
pip install -e .[dev]
# Or minimal installation (core only)
pip install .
Available extras
minimalmodbus- Modbus communication backendschedule- Scheduling backendrecommended- Recommended setup for most users (minimalmodbus + schedule)all- All available backendsdev- Development dependencies (includes pytest, coverage tools, and backends)
Requirements
AtmosPyre requires Python 3.10+ and the following dependencies:
- multipledispatch (≥0.6.0) - Type-based dispatch for sensor tags
The currently implemented and tested backends are:
- minimalmodbus (≥2.0.0) - Modbus RTU communication
- schedule (≥1.2.2) - Job scheduling
These are automatically installed when you pip install atmospyre[recommended].
Example: Multi-Sensor Data Logging
This example demonstrates setting up multiple sensors on the same serial port and logging their data at different intervals:
Hardware Setup:
- GMP252 CO₂ sensor at address 121 (19200 baud, 2 stop bits)
- AlphaTRACER radon sensor at address 122 (19200 baud, 1 stop bit)
- Both connected to
/dev/ttyACM0
The sensors automatically share the port without conflicts.
import time
from atmospyre.sensors.implementations.co2 import gmp252
from atmospyre.sensors.implementations.radon import alphatracer
from atmospyre.sensors import Stopbits
from atmospyre.loggers import SensorLogger
from atmospyre.loggers.strategies.writers import CSVWriter
from atmospyre.loggers.strategies.savers import JSONMetadataSaver
from atmospyre.scheduler.logger_scheduler import LoggerScheduler
from atmospyre.scheduler.schedule.schedule_backend import ScheduleTag
def main():
# CO2 Sensor - Vaisala GMP252
co2_sensor = gmp252.GMP252(
port='/dev/ttyACM0',
slave_address=121
)
# Radon Sensor - RadonTech AlphaTRACER
radon_sensor = alphatracer.AlphaTRACER(
port='/dev/ttyACM0',
slave_address=122,
baudrate=19200,
stopbits=Stopbits.ONE
)
# CO2 Logger - logs every 10 seconds
co2_logger = SensorLogger(
sensor=co2_sensor,
tags=[gmp252.CO2, gmp252.MEASURED_TEMPERATURE],
interval_seconds=10,
output_path="./CO2Probe",
writer=CSVWriter(),
metadata_saver=JSONMetadataSaver()
)
# Radon Logger - logs every 10 minutes
radon_logger = SensorLogger(
sensor=radon_sensor,
tags=[alphatracer.RADON_LIVE],
interval_seconds=600,
output_path="./RadonProbe",
writer=CSVWriter(),
metadata_saver=JSONMetadataSaver()
)
# Scheduler Setup
scheduler = LoggerScheduler(
scheduler_dispatch_tag=ScheduleTag(),
log_path="./scheduler_logs"
)
scheduler.add_logger(logger=co2_logger)
scheduler.add_logger(logger=radon_logger)
# Run
print("Starting multi-sensor data logging...")
print(f" - CO2 sensor: logging every 10 seconds to ./CO2Probe")
print(f" - Radon sensor: logging every 600 seconds to ./RadonProbe")
print("Press Ctrl+C to stop.\n")
try:
while True:
scheduler.run_pending()
time.sleep(1)
except KeyboardInterrupt:
print("\n\nStopping data logging...")
if __name__ == "__main__":
main()
Supported Sensors
- Vaisala GMP252 — CO₂ and temperature
- RadonTech AlphaTRACER — Radon concentration
Quick Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file atmospyre-1.0.0.tar.gz.
File metadata
- Download URL: atmospyre-1.0.0.tar.gz
- Upload date:
- Size: 58.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
425f52f35b6dee590b400009047c7ba68a36f35c12043d0ddb941266bdf7f854
|
|
| MD5 |
d35c89e6524c9667fe1e65021a547afe
|
|
| BLAKE2b-256 |
af03416d87422789e9ccc3f08c688d935ba5dcd53a9085ebb9c19497c1a98f3e
|
File details
Details for the file atmospyre-1.0.0-py3-none-any.whl.
File metadata
- Download URL: atmospyre-1.0.0-py3-none-any.whl
- Upload date:
- Size: 73.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e196133de0e0202b0bce69d63992c1c00b9e0d0228cb603767587af2afd141b7
|
|
| MD5 |
44cdbc8585920cc1d4318b82e70617d6
|
|
| BLAKE2b-256 |
43325a02fd6831fb6d4025a0081b630ff9a2c66310aa83d3569b9ba6bb7eb8d1
|