IMS Class
- ID: ims
- Name: I2C Moisture Sensor
- Category: liquid light temp
- Manufacturer: catnip
- Link: https://www.tindie.com/products/miceuz/i2c-soil-moisture-sensor/
- Connection: i2c
I2C sensor which can be used to read: moisture light temperature
This sensor must run at 100 kHz
Item Index
Methods
IMS
-
i2c_bus
-
i2c_address
I2C Moisture Sensor constructor
Initialize I2C Moisture Sensor
Parameters:
-
i2c_bus
NumberTarget I2C bus
-
i2c_address
NumberTarget I2C address (default is 0x20)
Returns:
sensor context pointer
write
-
cmd
-
wr_data
Write I2C Moisture Sensor registers
Parameters:
-
cmd
IMS_WR_COMMANDWrite command
-
wr_data
NumberTarget data to write (only used for IMS_SET_ADDRESS)
read
-
cmd
Read I2C Moisture Sensor registers
Parameters:
-
cmd
IMS_RD_COMMANDRead command
Returns:
Data returned from sensor (1 or 2 bytes depending on CMD)
get_version
()
Number
Get sensor version
Returns:
Sensor version
get_moisture
()
Number
Get moisture reading from sensor
Returns:
Unitless, relative capacitance value (moisture)
get_light
()
Number
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.
Returns:
rd_data Unitless, relative value for brightness dark (0xFFFF) > light (0x0000)
get_temperature
()
Number
Get temperature reading from device
Returns:
rd_data Temperature in degrees Celsius
reset
()
Reset sensor
reset_i2c_address
-
address_new
Set I2C address AND reset sensor
Parameters:
-
address_new
NumberNew I2C for device
sleep
()
Put device into low-power mode. Device wakes on any I2C command.