Skip to main content

Modbus sensor communication library

Project description

AtmosPyre

Python interface for Modbus-based environmental sensors.

📖 Full documentation

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

pip install atmospyre

Development mode:

git clone https://git.iws.uni-stuttgart.de/measurements/atmospyre.git
cd atmospyre
pip install -e ".[dev]"

Requirements: Python 3.10+, minimalmodbus, multipledispatch, schedule

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

atmospyre-0.1.0b1.tar.gz (56.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

atmospyre-0.1.0b1-py3-none-any.whl (70.7 kB view details)

Uploaded Python 3

File details

Details for the file atmospyre-0.1.0b1.tar.gz.

File metadata

  • Download URL: atmospyre-0.1.0b1.tar.gz
  • Upload date:
  • Size: 56.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for atmospyre-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 502efec8782050eedc71e6950fbc71e0c0d3c80434816d802842f369bb3dc868
MD5 77246b5473cfd6f7247046c4b000b98b
BLAKE2b-256 c39a96d252e072670ae01d66d0e994ca56321a93f6016bdc99771257a0ca002c

See more details on using hashes here.

File details

Details for the file atmospyre-0.1.0b1-py3-none-any.whl.

File metadata

  • Download URL: atmospyre-0.1.0b1-py3-none-any.whl
  • Upload date:
  • Size: 70.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for atmospyre-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 e7721dc9c350bb9688a76abb1ef2244d2156ffe69df3814157ea38422bb2d6fa
MD5 dcd19808adfd290c431a8de8e9d19d5d
BLAKE2b-256 e09f64b83b739819dc356a3cbe13625daf8306d92c5d147f93e18be9beb04cd0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page