Community
cancel
Showing results for 
Search instead for 
Did you mean: 
GGera4
New Contributor I
1,327 Views

Impossible to plug more than one sensor on I2c Arduino breakout

Jump to solution

Hi,

I hope this is not due to bad wiring or understanding of I2c, I have read many posts and as far as I can understand it I have followed the best practices. Here is my problem I would like to plug on the same bus :

Pressure sensor fromhttp://www.mikroe.com/click/altitude/ http://www.mikroe.com/click/altitude/ mpl3115a2http://cache.nxp.com/files/sensors/doc/data_sheet/MPL3115A2.pdf?pspll=1 http://cache.nxp.com/files/sensors/doc/data_sheet/MPL3115A2.pdf?pspll=1Temp/humidityhttps://www.adaf... https://www.adafruit.com/products/1899htu21d

https://www.adafruit.com/datasheets/1899_HTU21D.pdf https://www.adafruit.com/datasheets/1899_HTU21D.pdf

My config is :

>>> mraa.getVersion()

'v0.9.4-4-g8e8ed7d'

>>> mraa.getPlatformName ()

'Intel Edison'

>>> mraa.getPlatformVersion ()

'arduino'

>>>

For each sensor individually things work perfectly here is the output of python commands using upm :

>>> import mraa

>>> import pyupm_htu21d

>>> bus = 6

>>> tempAddress = 0x40

>>> temp = pyupm_htu21d.HTU21D(bus, tempAddress)

>>> temp.resetSensor ()

>>> temp.sampleData()

0

>>> RH = temp.getCompRH()

>>> temperature = temp.getTemperature()

>>> hygro = temp.getHumidity ()

!>>> print '\t%.3f\t\t'%temperature + '%.3f\t\t'%hygro + '%.3f'%RH

21.790 36.968 37.449

and

>>> import pyupm_mpl3115a2

>>> bus = 6

>>> pressAdress = 0x60

>>> press = pyupm_mpl3115a2.MPL3115A2(bus, pressAdress)

>>> press.sampleData()

0

>>> temperatureP = press.getTemperature()

>>> pressure = press.getPressure()

>>> pressea = press.getSealevelPressure()

>>> alt = press.getAltitude()

>>> print '\t%.3f\t\t'%temperatureP + '%.3f\t\t'%pressure + '%.3f\t\t'%pressea + '%.3f'%alt

22.062 98498.500 98498.500 238.029

My true altitude is 184 m and preasure read at the nearest weather station (few hundred meters) is 1005.7 HPa which seems to correspond properly with my readings.

Then I ty to wire both sensors on the same bus, as recommended on most (all) posts I add pullup resistors on both SCL and SDA.

I have checked with 3.3v and 5v power suply and even without pullup resistors th result is exactly the same : I get weird results like this :

>>> temp.resetSensor ()

>>> temp.sampleData()

0

>>> RH = temp.getCompRH()

>>> temperature = temp.getTemperature()

>>> hygro = temp.getHumidity ()

>>> print '\t%.3f\t\t'%temperature + '%.3f\t\t'%hygro + '%.3f'%RH

-46.850 -6.000 4.777

>>> press.sampleData()

Traceback (most recent call last):

File "", line 1, in

File "/usr/lib/python2.7/site-packages/pyupm_mpl3115a2.py", line 223, in sampleData

return _pyupm_mpl3115a2.MPL3115A2_sampleData(self)

RuntimeError: UPM Runtime Error: i2cWriteReg:mraa_i2c_write() failed

>>> temperatureP = press.getTemperature()

Traceback (most recent call last):

File "", line 1, in

File "/usr/lib/python2.7/site-packages/pyupm_mpl3115a2.py", line 277, in getTemperature

return _pyupm_mpl3115a2.MPL3115A2_getTemperature(self, bSampleData)

RuntimeError: UPM Runtime Error: i2cWriteReg:mraa_i2c_write() failed

>>> pressure = press.getPressure()

Traceback (most recent call last):

File "", line 1, in

File "/usr/lib/python2.7/site-packages/pyupm_mpl3115a2.py", line 261, in getPressure

return _pyupm_mpl3115a2.MPL3115A2_getPressure(self, bSampleData)

RuntimeError: UPM Runtime Error: i2cWriteReg:mraa_i2c_write() failed

>>> pressea = press.getSealevelPressure()

>>> alt = press.getAltitude()

>>> print '\t%.3f\t\t'%temperatureP + '%.3f\t\t'%pressure + '%.3f\t\t'%pressea + '%.3f'%alt

22.062 98498.500 98498.500 238.029

Last values look good but they are not, they correspond to the previous readings.

I may do something wrong but I really need to have more than one casensor on my bus..... Any help would be highly appreciated.

Tanks.

Tags (1)
1 Solution
Sergio_A_Intel
Employee
100 Views

Hi,

Take a look at the following thread http://electronics.stackexchange.com/questions/135078/multiple-i2c-slaves-on-intel-edison-i2c-6-bus microcontroller - Multiple I2C slaves on Intel Edison I2C-6 Bus - Electrical Engineering Stack Exchange . Here are described several reasons why the I2C bus might not work when using more than one device. There are also some suggestions you can try.

Additionally, you can also try to use a different power supply for the sensors instead of the 5V port of the board. The sensors might need a higher current than what the board can provide.

Sergio

View solution in original post

2 Replies
Sergio_A_Intel
Employee
101 Views

Hi,

Take a look at the following thread http://electronics.stackexchange.com/questions/135078/multiple-i2c-slaves-on-intel-edison-i2c-6-bus microcontroller - Multiple I2C slaves on Intel Edison I2C-6 Bus - Electrical Engineering Stack Exchange . Here are described several reasons why the I2C bus might not work when using more than one device. There are also some suggestions you can try.

Additionally, you can also try to use a different power supply for the sensors instead of the 5V port of the board. The sensors might need a higher current than what the board can provide.

Sergio

View solution in original post

GGera4
New Contributor I
100 Views

Hi Alvarado,

Thanks for the answer and the thread. I will check the resistors and change values to see what happens. Sensors are 3.3 v and not 5v I tried to put 5V on the SCL and SDA lines with 10 kΩ pull ups with no effect. Unfortunately I have no oscilloscope to verify the details mentionned on the tread.

In github upm forum rwaldron and Propanu suggested that this problem was due to the lack of "repeated start" with mraa lib https://github.com/intel-iot-devkit/upm/issues/359 Cannot use 2 sensors on I2c bus · Issue # 359 · intel-iot-devkit/upm · GitHub which seems to be confirmed by CMata_Intel in this thread :

I will buy other sensors and try to line them tu rule out this "repeated start" issue waiting that mraa provides the capability and check if changing resistors value on the bus change things.

Thanks for the help I'll let you know if I succeed identifying and solving the poblem.

Reply