lowpassns
Lightweight no_std Low-Pass Filter for Embedded Systems
lowpassns is a small, efficient, and robust first-order low-pass filter crate for no_std Rust environments. Designed for embedded systems like RP2040 or STM32, it smooths sensor readings or signals in real-time while being memory- and CPU-efficient.
GPL-2.0-or-later licensed to ensure open and free usage in both hobbyist and commercial projects.
Table of Contents
๐ Features
- โ
Pure
no_std: Zero standard library dependencies, perfect for bare-metal and RTOS. - โก Flexible Floating-Point: Default
f64, optionalf32feature for memory-constrained devices. - ๐ง Lightweight: Minimal stack usage, O(1) per update.
- ๐ก๏ธ Stable & Safe: Handles zero/negative dt safely, clamps tiny dt for embedded portability.
- ๐ Smooth Filtering: Simple first-order low-pass behavior for sensor smoothing or signal conditioning.
- โ๏ธ Resettable State: Filter value can be reset at any time.
๐ ๏ธ Installation
Add to your Cargo.toml:
[]
= { = "https://github.com/jorgeandrecastro/lowpassns.git" }
= { = "https://github.com/jorgeandrecastro/lowpassns.git", = ["f32"] }
๐ Quickstart
LowPass1;
{
// Initial value = 0.0, time constant ฯ = 0.1 s
= LowPass1::new(0.0, 0.1);
= 0.01; // 10 ms timestep
100 {
= 1.0; // example sensor input
= filter.update(input, dt);
// output smoothly approaches input
}
// Reset the filter state
}
๐ API Reference
| Method | Signature | Description |
| -------- | ----------------------------------------------------- | ---------------------------------------- |
| `new` | `LowPass1::new(initial: Float, tau: Float)` | Creates a new low-pass filter. |
| `update` | `update(&mut self, input: Float, dt: Float) -> Float` | Updates the filter state for a timestep. |
| `reset` | `reset(&mut self, value: Float)` | Resets the filter state. |
= f64 (default) or f32 via feature flag.
โก Performance & Optimization
constant time O(1) per update
zero allocations
10 kHz control loops on MCUs
๐งช Testing
โ๏ธ License
2026 Jorge Andre Castro.
modify, and distribute. Any derivative works must also be GPL-2.0-or-later.