UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

IMS Class

Module: ims

I2C sensor which can be used to read: moisture light temperature
This sensor must run at 100 kHz
ims.png

Methods

IMS

(
  • i2c_bus
  • i2c_address
)
Number

I2C Moisture Sensor constructor
Initialize I2C Moisture Sensor

Parameters:

  • i2c_bus Number

    Target I2C bus

  • i2c_address Number

    Target I2C address (default is 0x20)

Returns:

Number:

sensor context pointer

write

(
  • cmd
  • wr_data
)

Write I2C Moisture Sensor registers

Parameters:

  • cmd IMS_WR_COMMAND

    Write command

  • wr_data Number

    Target data to write (only used for IMS_SET_ADDRESS)

read

(
  • cmd
)
Number

Read I2C Moisture Sensor registers

Parameters:

  • cmd IMS_RD_COMMAND

    Read command

Returns:

Number:

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

get_version

() Number

Get sensor version

Returns:

Number:

Sensor version

get_moisture

() Number

Get moisture reading from sensor

Returns:

Number:

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:

Number:

rd_data Unitless, relative value for brightness dark (0xFFFF) > light (0x0000)

get_temperature

() Number

Get temperature reading from device

Returns:

Number:

rd_data Temperature in degrees Celsius

reset

()

Reset sensor

reset_i2c_address

(
  • address_new
)

Set I2C address AND reset sensor

Parameters:

  • address_new Number

    New I2C for device

sleep

()

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