CloudIoTPy
CloudIoTPy is a modular Python library providing a unified API for AWS IoT Core and Azure IoT Hub, built-in offline store-and-forward, and seamless Sensirion sensor integration via the SensorPy submodule.
Install / Use
/learn @dpourreau/CloudIoTPyREADME
CloudIoTPy
A multi-cloud IoT client library that provides a unified interface for connecting IoT devices to different cloud providers (AWS, Azure), with integrated sensor data collection and offline storage capabilities.
Features
- Unified Cloud Interface: Seamlessly connect to AWS IoT Core and Azure IoT Hub with a consistent API.
- Offline Storage: Built-in store-and-forward capability using either SQLite or JSON storage.
- Sensor Integration: Direct integration with sensor_py for reading data from Sensirion sensors.
Sensor Integration & Customization
CloudIoTPy ships with out-of-the-box support for Sensirion sensors via the sensor_py submodule, but you can:
1. Enable & Wire Supported Sensors
-
In
configs_json/cloud_config.json, set the flags under"sensor"totruefor any of the built-in sensors:"sensor": { "enable_stc31c": true, "enable_shtc3": true, "enable_sps30": true, … } -
Physically connect each enabled sensor exactly as described in
sensor_py/docs/SENSOR_CONNECTION_GUIDE.md(I²C/UART pins, power rails, etc.). -
No code changes needed—
SensorReadingServicewill use the defaultSensorManagerfrom the submodule.
2. Provide Your Own SensorManager
If you have other sensors or want a custom integration:
-
In the
sensor_py/submodule, create or extendsensor_manager.pywith a class implementing:class SensorManager: def initialize(self) -> None: """Set up your sensors (e.g. open I²C/UART ports).""" def read_data(self) -> Dict[str, Any]: """ Return a dict of readings, e.g. {"temperature": 22.5, "humidity": 55.2}. """ -
Enable your sensors in the JSON config. Add the flags under the
"sensor"section ofconfigs_json/cloud_config.json(e.g."enable_shtc3": true,"enable_sps30": true, etc.). -
Edit
cloudiotpy/sensors_integration/sensor_reading_service.pyto import yourSensorManagerinstead of the default, and read the same "sensor" flags from the loaded config to decide which sensors to initialize and poll. -
If your data format or rate differs, tweak
cloudiotpy/preprocessor/telemetry_preprocessor.pyto adjust batching, thresholding, or filtering rules.
For full details on wiring and the built-in Sensirion drivers (STC31-C, SHTC3, SPS30), check out the SensorPy submodule’s README and docs/SENSOR_CONNECTION_GUIDE.md.
Documentation
For more detailed documentation, please see the docs/ directory, which includes:
- Configuration System - In-depth guide to the multi-layered configuration
- Offline Storage - Complete reference for the offline storage capabilities
Project Structure
CloudIoTPy/
│── README.md
│── install.sh # Installation script
│── setup.py
│── pyproject.toml
│── main.py # Entry point
│
├── cloudiotpy/
│ ├── __init__.py
│ ├── common/
│ │ ├── __init__.py
│ │ ├── logging_setup.py
│ │ └── exceptions.py
│ ├── config/
│ │ ├── __init__.py
│ │ ├── config_loader.py
│ │ └── cloud_config_manager.py
│ ├── iot/
│ │ ├── __init__.py
│ │ ├── iot_client.py
│ │ ├── iot_manager.py
│ │ └── providers/
│ │ ├── __init__.py
│ │ ├── aws_client.py
│ │ └── azure_client.py
│ ├── offline_storage/
│ │ ├── __init__.py
│ │ ├── offline_storage.py
│ │ ├── offline_storage_json.py
│ │ ├── offline_storage_sqlite.py
│ │ └── offline_storage_service.py
│ ├── sensors_integration/
│ │ ├── __init__.py
│ │ └── sensor_reading_service.py
│ └── preprocessor/
│ ├── __init__.py
│ └── telemetry_preprocessor.py
│
├── sensor_py/ # SensorPy Git submodule for sensor integration
├── configs_json/
│ └── cloud_config_template.json # Example config template
├── docs/
│ ├── index.md
│ ├── configuration_system.md
│ ├── error_handling.md
│ └── offline_storage.md
├── tests/
│ ├── run_tests.py
│ ├── config/
│ │ ├── test_cloud_config_manager.py
│ │ └── test_config_loader.py
│ └── offline_storage/
│ ├── test_offline_storage.py
│ ├── test_offline_storage_json.py
│ └── test_offline_storage_sqlite.py
Installation
Prerequisites
Make sure you have:
- Python 3.8+
- Git (for cloning the repo and its submodules)
- GCC & Make (to build the native
sensor_pydrivers) - Linux system with I²C/UART support (for hardware sensors)
1. Clone the Repository
git clone --recursive git@github.com:dpourreau/CloudIoTPy.git
cd CloudIoTPy
2. Install with the Script
Use the bundled install.sh to set up a virtualenv, build drivers, and install everything you need:
-
Standard install
./install.sh -
With development dependencies
./install.sh --dev
This will automatically install:
awsiotsdk– AWS IoT Device SDK v2azure-iot-device,azure-identity– Azure IoT Hub SDKssqlite3(built-in)sensor_pydrivers
3. Post-Installation & Running
-
Configure
- Copy
configs_json/cloud_config_template.json→configs_json/cloud_config.json - Edit your credentials, endpoint, paths, etc.
- For detailed setup, follow the AWS IoT Core guide or Azure IoT Hub guide.
- Copy
-
Run
# If the script didn’t already activate it: source venv/bin/activate # In the project root: python3 main.py
Licensing
This project is licensed under the MIT License.
Included Submodules and Licensing
This repository uses Git submodules that are also open source:
SensorPy— Licensed under the MIT License. Seesensor_py/LICENSE.- Internally includes:
pm-gas-sensor-drivers— Uses source code from Sensirion AG, licensed under the BSD 3-Clause License. Seesensor_py/pm-gas-sensor-drivers/LICENSE.
- Internally includes:
