modulino
A hardware-agnostic, no_std Rust driver for Arduino Modulino breakout boards.
Overview
This crate provides drivers for the Arduino Modulino family of breakout boards, designed to work with any microcontroller that implements the embedded-hal 1.0 I2C traits.
Supported Modules
| Module | Description | Default Address |
|---|---|---|
Buttons |
Three buttons with LEDs | 0x3E |
Buzzer |
Piezo speaker | 0x1E |
Pixels |
8 RGB LEDs (APA102) | 0x36 |
Distance |
ToF sensor (VL53L4CD) | 0x29 |
Movement |
IMU (LSM6DSOX) | 0x6A/0x6B |
Knob |
Rotary encoder with button | 0x3A/0x3B |
Thermo |
Temperature/humidity (HS3003) | 0x44 |
Joystick |
Analog joystick with button | 0x2C |
LatchRelay |
Latching relay | 0x02 |
Vibro |
Vibration motor | 0x38 |
Usage
Add this to your Cargo.toml:
[]
= "0.1"
Example: RGB LEDs
use ;
// Create a Pixels instance with your I2C bus
let mut pixels = new?;
// Set the first LED to red at 50% brightness
pixels.set_color?;
// Set all LEDs to blue
pixels.set_all_color?;
// Apply the changes
pixels.show?;
Example: Buttons
use Buttons;
let mut buttons = new?;
loop
Example: Buzzer
use ;
let mut buzzer = new?;
// Play a tone at 440 Hz for 500ms
buzzer.tone?;
// Play a musical note
buzzer.play_note?;
// Stop the tone
buzzer.no_tone?;
Example: Temperature & Humidity
use Thermo;
let mut thermo = new;
// Read temperature and humidity (requires a delay provider)
let measurement = thermo.read?;
println!;
println!;
Example: Distance Sensor
use Distance;
let mut distance = new?;
// Start continuous ranging
distance.start_ranging?;
// Read distance in millimeters
let mm = distance.read_distance_blocking?;
println!;
Example: Rotary Encoder
use Knob;
let mut knob = new?;
// Set a range for the encoder value
knob.set_range;
loop
Example: Joystick
use Joystick;
let mut joystick = new?;
// Set custom deadzone
joystick.set_deadzone;
loop
Example: Vibration Motor
use ;
let mut vibro = new?;
// Vibrate at medium power for 500ms
vibro.on?;
// Or use a custom power level (0-100)
vibro.on_with_power?;
Example: Relay Control
use LatchRelay;
let mut relay = new?;
// Turn on the relay
relay.on?;
// Check state
if relay.is_on? == Some
// Turn off
relay.off?;
Example: IMU (Accelerometer/Gyroscope)
use Movement;
let mut movement = new?;
// Read acceleration (in g)
let accel = movement.acceleration?;
println!;
// Read angular velocity (in dps)
let gyro = movement.angular_velocity?;
println!;
Features
defmt: Enabledefmtformatting for error types (useful for embedded debugging)
[]
= { = "0.1", = ["defmt"] }
Hardware Requirements
All Modulino devices communicate over I2C at 100kHz. They use the Qwiic/STEMMA QT connector standard for easy daisy-chaining.
Custom I2C Addresses
Some modules can have their address changed. You can specify a custom address when creating a driver:
use ;
// Use default address
let buttons = new?;
// Use custom address
let buttons = new_with_address?;
Minimum Supported Rust Version (MSRV)
This crate requires Rust 1.75 or later.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
This library is inspired by the Arduino Modulino MicroPython library.