pamoja-sensors
Datasheet-anchored decoders for eleven parts: the BME280, BMP280, DS18B20, HDC1080, INA219, INA226, ADS1115, OPT3001, SCD4x, SHT3x, and TMP117. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
pip install pamoja-sensors
from pamoja import sensors
This pulls in pamoja-native, the compiled engine. pip install pamoja is the whole framework in one package.
Example
The script the test suite runs, spliced here as it ran.
From bindings/python/guides/sensors.py:
from pamoja.core import PamojaError
from pamoja.sensors import ds18b20, ina219
# Stand-ins for the two parts. On a running node the thermometer's nine bytes come off
# the 1-Wire bus and the monitor's registers off I2C; here the library builds what each
# would send, so the program runs with nothing plugged in.
thermometer = ds18b20.build_scratchpad(25.0625, 12, 75, -10)
# The monitor is set up for 1 mA per count across a 2 milliohm shunt, the load its
# datasheet's worked design example describes: 11.98 V, 10 A, and 119.8 W.
CURRENT_LSB = 1_000
bus = ina219.bus_register(11_980)
current = ina219.current_register(10_000_000, CURRENT_LSB)
power = ina219.power_register(119_800_000, CURRENT_LSB)
# Everything below is the node's own code. The thermometer checksums every read, so a
# reading is verified before it is believed.
reading = ds18b20.parse_scratchpad(thermometer)
print(f"temperature {reading.celsius:.4f} C")
print(f"resolution {reading.resolution_bits} bits")
print(f"alarms {reading.alarm_high} / {reading.alarm_low} C")
# The monitor computes nothing until it has been told what shunt it is across.
print(f"calibration 0x{ina219.calibration(CURRENT_LSB, 2):04X}")
print(f"bus {ina219.bus_millivolts(bus)} mV")
print(f"current {ina219.current_microamps(current, CURRENT_LSB) // 1_000} mA")
print(f"power {ina219.power_microwatts(power, CURRENT_LSB) // 1_000} mW")
# A bit flipped on a long 1-Wire run fails the checksum, so the node repeats the read
# instead of logging a temperature a couple of degrees off.
corrupted = bytearray(thermometer)
corrupted[0] ^= 1
try:
ds18b20.parse_scratchpad(bytes(corrupted))
print("corrupt read accepted, which should never happen")
except PamojaError as error:
print(f"corrupt read rejected: {error}")
The same capability in every language
| Language | Package | Reference |
|---|---|---|
| Rust | pamoja-sensors |
reference, docs.rs, install |
| TypeScript | @pamoja/sensors |
reference, install |
| Python | pamoja-sensors |
reference, install |
| C# | Pamoja.Sensors |
reference, install |
Documentation
pamoja.sensorsreference, every class and function in this module.- The Sensor drivers guide, with the same example in Rust, TypeScript, and C#.
- Every capability, and the install page.
License
MIT
Release files for pamoja-sensors 0.1.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pamoja_sensors-0.1.18.tar.gz | 18.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pamoja_sensors-0.1.18-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.4 kB
Release files / pamoja_sensors-0.1.18.tar.gz
| Download URL | pamoja_sensors-0.1.18.tar.gz |
|---|---|
| Size | 18.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ebcf72a5be59db5b5544cd4d67cdb9d2fe515d9a441bbd4d7afba97f15e4d02d
|
|
BLAKE2b-256 checksum How to use checksums |
31bb2b438eca7cd91ff7394f7a3b0cb6885b0ff8d69bc45c82312f930d508360
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pamoja_sensors-0.1.18-py3-none-any.whl
| Download URL | pamoja_sensors-0.1.18-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
145e30d6db9c9da2044d2afef5f51e6c11174c32e0f1662852a465e91c9f97ce
|
|
BLAKE2b-256 checksum How to use checksums |
ecb31c7f5d7a6725ee659c5fc30c42f7e433eabe1d4c08dc41efa3cdbe23c150
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|