hc12-rs

Crates.iohc12-rs
lib.rshc12-rs
version0.5.0-rc1
created_at2025-06-05 17:51:09.744741+00
updated_at2025-06-21 15:08:56.375189+00
descriptionA strongly typed, and rusty builder for programming HC-12 radios
homepage
repositoryhttps://github.com/thelenlucas/hc12-rs/
max_upload_size
id1701990
size193,285
Lucas Thelen (thelenlucas)

documentation

README

hc12-rs

A builder-syntax programmer for hc01 HC-12 radio modules.

Motivation

The HC-12 is a fantastic small radio module used for embedded applications, typically used in hobbyist applications, as it does not require licensing in most jurisdictions. However, poor documentation and an unconventional parameter and settings system make it difficult to work with on occasion. This crate provides methods for programming and reconfiguring the module, without needing to touch serial devices manually every time.

The best-translated English manual for the module can be found here.

Capabilities

  • Re/Program HC-12 modules dynamically with error handling
  • Statically typed builder prevents invalid states
  • Use any embedded-hal/embedded-io-capable board
  • no-std and no-alloc capable

Usage


let mut hc12 = HC12::new(serial, programming_pin, &mut delay)
  .unwrap()
  .channel(Channel::new(15).unwrap())
  .power(Power::P8)
  .b4800()
  .fu3()
  .program(&mut timer_two)
  .unwrap()
  .into_transparent_mode()
  .unwrap();

hc12.write_all("Hello world!".as_bytes()).ok();

let mut hc12_low_power = hc12.into_programming_mode()
  .fu1()
  .unwrap()
  .into_transparent_mode()
  .unwrap();

hc12_low_power.write_all(b"Hello from the low power mode!").ok();

Feature Flags

  • defmt-03: Support for defmt logging macros

To-Dos

  • Interrogation of underlying module parameters
  • Unsafe no-assumptions interface
  • Async feature flags
Commit count: 20

cargo fmt