pamoja-power 0.1.17

Power-aware scheduling for the pamoja device SDK: duty cycling and an energy-aware governor, no_std-friendly.
Documentation

pamoja-power

Power-aware scheduling for the pamoja device SDK: duty cycling and an energy-aware governor, no_std-friendly.

The same capability in every language

Language Package Reference
Rust pamoja-power reference, docs.rs, install
TypeScript @pamoja/power reference, install
Python pamoja-power reference, install
C# Pamoja.Power reference, install

Power-aware scheduling for the pamoja SDK.

A node on a battery or a solar panel lives or dies by how much it sleeps. This crate holds the scheduling math that keeps such a node alive, with no runtime and no hardware assumptions, so the same decisions can be made on a microcontroller and verified on a server:

  • DutyCycle - trade wakefulness for battery life with a repeating wake/sleep schedule, and read back the duty fraction as a power proxy.
  • PowerPlan - an energy-aware governor that stretches the sampling interval as the battery drains, picking a PowerMode from the state of charge and easing off when the panel is charging.

The state of charge fed to a PowerPlan is noisy in the field, so smoothing it first (for example with a Smoother from pamoja-kit) keeps the governor from flapping between modes at a threshold.

The crate is no_std and allocation-free.

Examples

use core::time::Duration;
use pamoja_power::{PowerMode, PowerPlan};

let plan = PowerPlan::new(
    Duration::from_secs(60), // sample each minute when healthy
    Duration::from_secs(600), // back off to ten minutes to conserve
    Duration::from_secs(3600), // once an hour when critically low
);

assert_eq!(plan.mode(0.8), PowerMode::Active);
assert_eq!(plan.interval(0.1), Duration::from_secs(3600));

License

MIT - part of the pamoja workspace: one memory-safe Rust core with bindings for every language.