jsy_mk_194

Crates.iojsy_mk_194
lib.rsjsy_mk_194
version1.0.2
sourcesrc
created_at2023-12-03 16:47:28.516399
updated_at2024-03-05 14:35:59.658249
descriptionRewrite of power reader JSY-MK-194. Tested on ESP32
homepagehttps://github.com/emeric-martineau/jsy_mk_194
repositoryhttps://github.com/emeric-martineau/jsy_mk_194
max_upload_size
id1056998
size1,123,761
Emeric MARTINEAU (emeric-martineau)

documentation

README

Rust crate for JSY-MK-194

What is JSY-MK-194?

JSY-MK-194 is hardware to get some informations about current, voltage, frequency of AC current.

You found this hardware easly on some chiness website.

JSY-MK-194

Test hardware

This crate has only tested on ESP32-WROOM-32 microcontroler.

Example

First, you need provide implementation of some trait (hardware abstract):

use jsy_mk_194::*;

struct MyUartImpl {
    // Some necessary fields
}

impl Uart for MyUartImpl {

    fn read(&mut self, buf: &mut [u8], _timeout: u32) -> Result<usize, error::UartError> {
        // Do something
    }

    fn write(&mut self, bytes: &[u8]) -> Result<usize, error::UartError> {
        // Do something
    }
}

struct MyDelayImpl {
    // Some necessary fields
}

impl DelayMs<u16> for MyDelayImpl {
    fn delay_ms(&mut self, _ms: u16) {
        // Do something
    }
}

Then, you need call read() method:

let mut jsy_my_194 = jsy_my_194::new(my_uart_impl, my_delay_impl);
let _ = jsy_my_194.read();

print!("First channel power: {}", jsy_my_194.channel1.power());

That's all!

Changelog

1.0.1

  • Rewrite module to be more easy to understand
  • Add new public read_with_timeout method to allow user set his timeout

License

The code is released under MIT License to allow every body to use it in all conditions. If you love open-source software and this crate, please give some money to HaikuOS or ReactOS.

Commit count: 10

cargo fmt