Filter results by

Sensors with ARTIK IDE

ARTIK modules provide connection capability for analog inputs and various digital input and outputs, as well as I2C and SPI connections. For the ARTIK 530 and 710 development kits, we offer a special board with a variety of sensors to make testing and development easier. Other board kits do not have matching headers to attach this board.

Here we talk first about the sensor board and some ways to check its function through the command line. Then we show you the easy way, using the ARTIK IDE and its pre-built sensor demo application.

ARTIK Sensor Board

The ARTIK 530 and 710 Interface board provides an option for attaching a Sensor Board, which you can buy through Digi-Key.


Sensor boardSIP-ASRNXS004
Plugs onto Interface board

Sensors:
- 6-axis motion detection 
- Barometric pressure
- Humidity/Temperature
- Temperature
- Hall effect (magnetic)
- Proximity & Color

I2C Port Expander:
- 4 connectors for external I2C
- Level shifter
- 5V/3.3V/1.8V selectable
Device Function Model Access
method
Datasheet
MEMs barometric pressure sensor LPS25HB I2C bus 1 0x5D ST Micro </a
Humidity/Temperature sensor HTS221 I2C bus 1 0x5F ST Micro
Temperature sensor S-5851AAA-M6T1U I2C bus 1 0x48* SII Semiconductor
Proximity & Color sensor CM36655 I2C bus 1 0x60
INT on GPIO pin [1]
Capella Microsystems
Hall Effect sensor S-5712CCDL1-I4T1U GPIO pin [2] =0 when magnet near SII Semiconductor
6-axis motion detector
(3 accelerometer,
3 gyroscope)
LSM6DSM SPI bus, INT on GPIO pin [0] ST Micro
I2C Port Expander /
level translator
NLSX4373MUTAG Use J21 to select voltage ON Semiconductor

*The U8 temperature sensor arrives unconnected. Refer here for details.

Barometric Pressure Sensor

The barometric pressure sensor is wired to respond on I2C bus 1 address 0x5D. Its register map from the datasheet is shown. Registers 0x20, 0x21, and 0x28-2A are of interest.

Read the current barometric pressure as follows.

  1. Identify it as the correct device.
    i2cget -f -y 1 0x5D 0x0F
    You should get 'BD'

  2. Write CTRL_REG2 to reboot and reset the device.
    i2cset -f -y 1 0x5D 0x21 0xC4

  3. Write CTRL_REG1 to put the device in active mode and acquire new data every 1s.
    i2cset -f -y 1 0x5D 0x20 0x90

  4. Read pressure count.
    i2cget -f -y 1 0x5D 0x2A high byte
    i2cget -f -y 1 0x5D 0x29 middle byte
    i2cget -f -y 1 0x5D 0x28 low byte

    Use 4096 counts per hectopascal (hPa) to convert. For example:

    	3f ba 2e

    is 4176430 decimal. Divide by 4096 counts/hPa to obtain 1019 hPa, or 30.18 inches of mercury on a U.S. barometric scale.

Humidity / Temperature Sensor

The humidity/temperature sensor is wired to respond on I2C bus 1 address 0x5F. Its register map from the datasheet is shown. Each device is uniquely calibrated and requires you to interpolate each raw value read using stored values – 14 registers in all!

As a result, we won't be reading back final temperature and humidity values, only the raw measured ones. Refer to the ST Micro datasheet for the calibration theory. Search online for the part number to find coding examples in C++ and Python.

Read the device values as follows.

  1. Identify it as the correct device.
    i2cget -f -y 1 0x5F 0x0F
    You should get 'BC'

  2. Write CTRL_REG2 to reboot and reset the device.
    i2cset -f -y 1 0x5F 0x21 0x80

  3. Write CTRL_REG1 to put the device in active mode and acquire new data every 1s.
    i2cset -f -y 1 0x5F 0x20 0x81

  4. Read raw humidity value.
    i2cget -f -y 1 0x5F 0x29 high byte
    i2cget -f -y 1 0x5F 0x28 low byte

  5. Read raw temperature value.
    i2cget -f -y 1 0x5F 0x2B high byte
    i2cget -f -y 1 0x5F 0x2A low byte

    You can divide by 8 to get the uncalibrated Celsius temperature. For example:

    	00 bc

    is 188 decimal, divided by 8 is 23.5 C, or 74.3 F

Temperature Sensor

The U8 temperature sensor has no on-board I2C connection. However, it is configured to respond on I2C address 0x48. You can wire its SCL and SDA lines from J13 over to J19 to I2C bus 1 on the translated side of the I2C expander – but make sure you first put a jumper on J21 to select an appropriate level shifter voltage (typically 3.3V).

Read the device values as follows.

  1. Enable the device by writing 0 to its Configuration register at index 01.
    i2cset -f -y 1 0x48 0x1 0

  2. Read the raw temperature value in hex at index 00 as a word (two bytes).
    i2cget -f -y 1 0x48 0x0 w
    (returns bits[3:0]+0000 – bits[11:4])

  3. Swap the hex bytes to get MSB – LSB order.

  4. Right-shift the 16-bit value to return the final 12-bit Celsius temperature.

For example, a returned raw value of:

 0x6019 

refers to the low byte of '0x60' and high byte of '0x19'.

– Swapped, it becomes 0x1960

– Right-shifted, it becomes 0x196

– Converted to decimal, it becomes 406

– Multiplied by .0625 count / degree C, you arrive at the final value of 25.4 C.

Hall Effect Sensor

The Hall effect sensor has no programmability. It simply triggers its output connected to GPIO pin [2], which is sysfs GPIO 130, when a magnet is placed nearby. To test:

  1. Request control of the desired GPIO.
    echo 130 > /sys/class/gpio/export

  2. Configure the GPIO to be an input.
    echo in > /sys/class/gpio/gpio130/direction

  3. Read its value.
    cat /sys/class/gpio/gpio130/value

Try this last step repeatedly, placing a magnet near the sensor and then drawing it away, to see the difference in the return value.

  • 1: no magnet
  • 0: magnet detected

Proximity and Color Sensor

The CM36655 device is related to the CM36653 device, for which sample code can be found here.

ARTIK IDE Sensor Demo

You're ready to try out an ARTIK IDE development project!

Go to ARTIK IDE – Linux Projects and follow the instructions. When you get to the screen that lets you choose the application you want to develop, choose Sensor.

You'll find that code is provided for all sensors except for the Hall Effect sensor, which is left for you to implement. Have fun!

Last updated on: