pyupm_ims module

class pyupm_ims.IMS(i2c_bus, i2c_address=32)[source]

Bases: object

API for the Catnip Electronics I2C moisture sensor.

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

C++ includes: ims.hpp

get_light()[source]

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. rd_data Unitless, relative value for brightness dark (0xFFFF)> light (0x0000)

std::runtime_error: if I2C write/read command fails

get_moisture()[source]

uint16_t get_moisture()

Get moisture reading from sensor Unitless, relative capacitance value (moisture)

std::runtime_error: if I2C read command fails

get_temperature()[source]

float get_temperature()

Get temperature reading from device rd_data Temperature in degrees Celsius

std::runtime_error: if I2C read command fails

get_version()[source]

uint16_t get_version()

Get sensor version Sensor version

std::runtime_error: if I2C read command fails

read(cmd)[source]

uint16_t read(IMS_RD_COMMAND cmd)

Read I2C Moisture Sensor registers

cmd: Read command

Data returned from sensor (1 or 2 bytes depending on CMD)

std::runtime_error: if I2C read command fails

reset()[source]

void reset()

Reset sensor

std::runtime_error: if I2C write command fails

reset_i2c_address(address_new)[source]

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

sleep()[source]

void sleep()

Put device into low-power mode. Device wakes on any I2C command.

std::runtime_error: if I2C write command fails

write(cmd, wr_data)[source]

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