|
upm
1.6.0
Sensor/Actuator repository for libmraa (v1.9.0)
|
API for the Catnip Electronics I2C moisture sensor. More...
I2C sensor which can be used to read: moisture light temperature
This sensor must run at 100 kHz
Public Member Functions | |
| IMS (int16_t i2c_bus, int16_t i2c_address=IMS_ADDRESS_DEFAULT) | |
| virtual | ~IMS () |
| void | write (IMS_WR_COMMAND cmd, uint8_t wr_data) |
| uint16_t | read (IMS_RD_COMMAND cmd) |
| uint16_t | get_version () |
| uint16_t | get_moisture () |
| uint16_t | get_light () |
| float | get_temperature () |
| void | reset () |
| void | reset_i2c_address (uint8_t address_new) |
| void | sleep () |
| IMS | ( | int16_t | i2c_bus, |
| int16_t | i2c_address = IMS_ADDRESS_DEFAULT |
||
| ) |
| void write | ( | IMS_WR_COMMAND | cmd, |
| uint8_t | wr_data | ||
| ) |
Write I2C Moisture Sensor registers
| cmd | Write command |
| wr_data | Target data to write (only used for IMS_SET_ADDRESS) |
| std::runtime_error | if I2C write command fails |


| uint16_t read | ( | IMS_RD_COMMAND | cmd | ) |
Read I2C Moisture Sensor registers
| cmd | Read command |
| std::runtime_error | if I2C read command fails |


| uint16_t get_version | ( | ) |
Get sensor version
| std::runtime_error | if I2C read command fails |


| uint16_t get_moisture | ( | ) |
Get moisture reading from sensor
| std::runtime_error | if I2C read command fails |


| uint16_t get_light | ( | ) |
Get light reading from LED on device. The technical data for the I2C moisture sensor specifies a 3 second wait. Loop for 3 seconds checking the GET_BUSY register. IF the sensor is NOT ready after 3 seconds, assume there is NO light and return a max uint16_t (dark) value.
| std::runtime_error | if I2C write/read command fails |


| float get_temperature | ( | ) |
Get temperature reading from device
| std::runtime_error | if I2C read command fails |


| void reset | ( | ) |
Reset sensor
| std::runtime_error | if I2C write command fails |


| void reset_i2c_address | ( | uint8_t | address_new | ) |
Set I2C address AND reset sensor
| address_new | New I2C for device |
| std::runtime_error | if I2C write command fails |


| void sleep | ( | ) |
Put device into low-power mode. Device wakes on any I2C command.
| std::runtime_error | if I2C write command fails |


1.8.11