libsparkypi 0.1.0

control 433 Mhz devices with a Raspberry Pi
Documentation

libsparkypi

simple library to control 433 Mhz target devices using a Raspberry Pi and a 433 Mhz transmitter module using the excellent rppal crate

A fully working example with a command line interface can be found here:

https://github.com/elkasztano/sparkypi

Usage:

  1. Add to Cargo.toml:
[dependencies]
rppal = "0.14.1"
libsparkypi = "0.1.0"

Example:

use libsparkypi::Transmission;
use rppal::gpio::Gpio;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
    let gpio = Gpio::new()?;

    let mut output_pin = gpio.get(17)?.into_output();

    let mut my_transmission = Transmission::new();

    my_transmission.sequence.push_str("s000000010101000101011001");
    my_transmission.pulse_length = 170;
    my_transmission.repeats = 5;

    println!("{:?}", &my_transmission);

    my_transmission.send_to(&mut output_pin);

    Ok(())
}

The above example will transmit the binary sequence '000000010101000101011001' with a leading sync bit and a pulse length of 170 microseconds 5 times. The data pin of the transmitter module is connected to GPIO pin 17 on the Raspberry Pi.

Notes

  • There are many different protocols for 433 Mhz data transmission. What I have implemented here corresponds to 'protocol1' in the 'rc-switch' library for the Arduino ecosystem.
  • Additional transmission protocols may be implemented in the future.
  • libsparkypi does not rely on wiringpi, which seems to be deprecated.