Pamoja.Sensors
0.1.17
dotnet add package Pamoja.Sensors --version 0.1.17
NuGet\Install-Package Pamoja.Sensors -Version 0.1.17
<PackageReference Include="Pamoja.Sensors" Version="0.1.17" />
<PackageVersion Include="Pamoja.Sensors" Version="0.1.17" />
<PackageReference Include="Pamoja.Sensors" />
paket add Pamoja.Sensors --version 0.1.17
#r "nuget: Pamoja.Sensors, 0.1.17"
#:package Pamoja.Sensors@0.1.17
#addin nuget:?package=Pamoja.Sensors&version=0.1.17
#tool nuget:?package=Pamoja.Sensors&version=0.1.17
Pamoja.Sensors
Datasheet-anchored decoders for the BME280, DS18B20, INA219, and ADS1115. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
dotnet add package Pamoja.Sensors
using Pamoja.Sensors;
This pulls in Pamoja.Native, the compiled engine. dotnet add package Pamoja is the whole framework in one package.
Example
The guide project's example, spliced here as it ran in CI.
From bindings/dotnet/samples/Pamoja.Guides/SensorsGuide.cs:
// 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.
byte[] thermometer = Ds18b20.BuildScratchpad(25.0625f, 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.
const uint CurrentLsb = 1_000;
ushort bus = Ina219.BusRegister(11_980);
short current = Ina219.CurrentRegister(10_000_000, CurrentLsb);
ushort power = Ina219.PowerRegister(119_800_000, CurrentLsb);
// Everything below is the node's own code. The thermometer checksums every read,
// so a reading is verified before it is believed.
Ds18b20Reading reading = Ds18b20.ParseScratchpad(thermometer);
Console.WriteLine($"temperature {reading.Celsius:F4} C");
Console.WriteLine($"resolution {reading.ResolutionBits} bits");
Console.WriteLine($"alarms {reading.AlarmHigh} / {reading.AlarmLow} C");
// The monitor computes nothing until it has been told what shunt it is across.
Console.WriteLine($"calibration 0x{Ina219.Calibration(CurrentLsb, 2):X4}");
Console.WriteLine($"bus {Ina219.BusMillivolts(bus)} mV");
Console.WriteLine($"current {Ina219.CurrentMicroamps(current, CurrentLsb) / 1_000} mA");
Console.WriteLine($"power {Ina219.PowerMicrowatts(power, CurrentLsb) / 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.
byte[] corrupted = [.. thermometer];
corrupted[0] ^= 1;
try
{
Ds18b20.ParseScratchpad(corrupted);
Console.WriteLine("corrupt read accepted, which should never happen");
}
catch (PamojaException error)
{
Console.WriteLine($"corrupt read rejected: {error.Message}");
}
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 type in this namespace.- The Sensor drivers guide, with the same example in Rust, TypeScript, and Python.
- Every capability, and the install page.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Pamoja.Native (>= 0.1.17)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Pamoja.Sensors:
| Package | Downloads |
|---|---|
|
Pamoja
The whole pamoja framework in one package: every capability of one memory-safe Rust core, behind an idiomatic C# facade, for IoT, robotics, and drones. |
|
|
Pamoja.Sensing
Sensing and actuation: The parts wired to a board: a thermometer that checks its own bytes, a servo pulse, and a stepper walking its coils. |
GitHub repositories
This package is not used by any popular GitHub repositories.