[SOLVED] Accessing i2c sensors directly

Hi, is it possible to access the sensors directly using i2c?

According to https://github.com/matrix-io/matrix-documentation/blob/master/docs/Reference/overview.md, i2c sensors are wired to both the fpga and the raspberry pi. At least i2c is accessible from the extension header according to https://github.com/matrix-io/matrix-documentation/blob/master/docs/Reference/pinout.md.

I had a quick look at you driver and noticed that you use the wishbone bus so you get all the sensor data from the fpga; even the i2c ones. Btw, are we supposed to get a ST HTS221 on the MATRIX creator? The silkscreen-labeled humidity sensor I got on my board looks very different. I also see that you are pulling the temperature from the RPi CPU which is a joke to say the least (see https://github.com/matrix-io/matrix-creator-malos/blob/master/src/driver_humidity.cpp).

Thank you for your help!

Hi @DurandA.

Yes, You could acces to the sensors directly using Raspberry I2C. But you need to follow the next steps:

1- Avoid reading sensors process from SAM3S MCU, now all sensors are reading from SAM3S. https://github.com/matrix-io/matrix-creator-mcu. Also you could reset MCU with:

sudo echo 18 > /sys/class/gpio/export 2>/dev/null
sudo echo out > /sys/class/gpio/gpio18/direction
sudo echo 0 > /sys/class/gpio/gpio18/value

2- Activate the I2C driver in your Raspbian with raspi-config command. Then use the i2cdetect tool to get all addresses of sensors. It looks like:

sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- 1c -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- 38 39 -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 5f 
60: 60 -- -- -- -- -- -- -- -- -- 6a -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

Best Regards,

Kevin

Hi @DurandA,

You do have a ST HTS221 in the board, the silkscreen of UV and humidity sensors are swapped, so the humidity sensor you are looking for is the one with the UV label.
Regarding the temperature measurement we have two sensors that can provide temperature readings. The HTS221 humidity sensor and the NXP MPL3115A2 Pressure sensor. The code you saw using the Raspberry Pi CPU temperature is related to a simple calibration performed to the temperature from the humidity sensor using both the temperature form the sensor and the CPU temp from the Pi that is the main source of heat that affects the readings when you are trying to get the room temperature.

Yoel