upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
Go to the source code of this file.
Data Structures | |
struct | ims_context |
Functions | |
ims_context * | ims_init (int16_t i2c_bus, int16_t i2c_address) |
void | ims_close (ims_context *dev) |
upm_result_t | ims_read (const ims_context *dev, IMS_RD_COMMAND cmd, uint16_t *rd_data) |
upm_result_t | ims_write (const ims_context *dev, IMS_WR_COMMAND cmd, uint8_t wr_data) |
upm_result_t | ims_get_version (const ims_context *dev, uint16_t *rd_data) |
upm_result_t | ims_get_moisture (const ims_context *dev, uint16_t *rd_data) |
upm_result_t | ims_get_light (const ims_context *dev, uint16_t *rd_data) |
upm_result_t | ims_get_temperature (const ims_context *dev, uint16_t *rd_data) |
upm_result_t | ims_reset (const ims_context *dev) |
upm_result_t | ims_reset_i2c_address (ims_context *dev, uint8_t address_new) |
upm_result_t | ims_sleep (const ims_context *dev) |
ims_context* ims_init | ( | int16_t | i2c_bus, |
int16_t | i2c_address | ||
) |
Initialize sensor
i2c_bus | Target I2C bus |
i2c_address | Target I2C address (default is 0x20) |
void ims_close | ( | ims_context * | dev | ) |
Sensor close method. Cleans up any memory held by this device
sensor | context pointer |
upm_result_t ims_read | ( | const ims_context * | dev, |
IMS_RD_COMMAND | cmd, | ||
uint16_t * | rd_data | ||
) |
Read I2C Moisture Sensor registers
dev | Sensor context pointer |
cmd | Read command |
rd_data | Data returned from sensor (1 or 2 bytes depending on cmd) |
upm_result_t ims_write | ( | const ims_context * | dev, |
IMS_WR_COMMAND | cmd, | ||
uint8_t | wr_data | ||
) |
Write I2C Moisture Sensor registers
dev | Sensor context pointer |
cmd | Write command |
wr_data | Target data to write (only used for IMS_SET_ADDRESS) |
upm_result_t ims_get_version | ( | const ims_context * | dev, |
uint16_t * | rd_data | ||
) |
Get sensor version
dev | Sensor context pointer |
rd_data | Sensor version |
upm_result_t ims_get_moisture | ( | const ims_context * | dev, |
uint16_t * | rd_data | ||
) |
Get moisture reading from sensor
dev | Sensor context pointer |
rd_data | Unitless, relative capacitance value (used to determine moisture) |
upm_result_t ims_get_light | ( | const ims_context * | dev, |
uint16_t * | rd_data | ||
) |
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.
dev | Sensor context pointer |
rd_data | Unitless, relative value for brightness dark (0xFFFF) —> light (0x0000) |
upm_result_t ims_get_temperature | ( | const ims_context * | dev, |
uint16_t * | rd_data | ||
) |
Get temperature reading from device
dev | Sensor context pointer |
rd_data | Temperature in degrees Celsius * 10 ie, 256 = 25.6 C |
upm_result_t ims_reset | ( | const ims_context * | dev | ) |
Reset sensor
dev | Sensor context pointer |
upm_result_t ims_reset_i2c_address | ( | ims_context * | dev, |
uint8_t | address_new | ||
) |
Set I2C address AND reset sensor
dev | Sensor context pointer |
address_new | New I2C for device |
upm_result_t ims_sleep | ( | const ims_context * | dev | ) |
Put device into low-power mode. Device wakes on any I2C command.
dev | Sensor context pointer |