Run benita
on your Raspberry Pi
(currently tested on RPi 3), hookup your sensors to the I2C bus, and start coding!
Initialize pre-configured sensors, just say which i2cdev
path, and which I2C Address
to call on.
At the moment, conductivity, temperature, and ph sensors are available.
The simplest way to start talking to a sensor is to use the new(path, address)
associated function on the device.
extern crate benita;
use benita::config::SensorConfig;
use benita::errors::*;
use benita::ph::device::PhSensor;
fn main() {
// Create a sensor directly with the i2cdev path, and the integer value
// of the I2C address for our sensor.
let ph_sensor = PhSensor::new("/dev/i2cdev-0", 100)?;
// use the sensor to issue a command request and display the response.
let response = ph_sensor.get_device_info()?;
println!("Sensor Info: {}", response);
// custom code goes here...
}
extern crate benita;
use benita::config::SensorConfig;
use benita::errors::*;
use benita::ph::device::PhSensor;
fn main() {
// Same goes for...
// First, create a sensor configuration with the i2cdev path, and the
// integer value of the I2C address for our sensor.
let ph_config = SensorConfig::new("/dev/i2cdev-0", 99);
// Second, we can start working with our sensor device.
let ph_sensor = PhSensor::from_config(ph_config)?;
// use the sensor to issue a command request and display the response.
let response = ph_sensor.get_reading()?;
println!("Current pH: {}", response);
// custom code goes here...
}