I2C device not detected
-
Hello,
I've just started with pycom after moving from the Particle.io platform.
I'm trying to get I2C to work. But my Wipy does not detect any of my devices. My setup is as follows:
Directly connects to my Grove SGP30 gas sensor:
I'm using the following code:
from machine import I2C #I2C setup print("setup i2c") i2c = I2C(0) i2c.init(I2C.MASTER, baudrate=400000, pins=('P9','P10')) print(i2c) slaveList = i2c.scan() print(slaveList)
This returns:
setup i2c I2C(0, I2C.MASTER, baudrate=400000) []
My SCD30 CO2 sensor gives me the same result.
Could you please assist.
Kind regards,
Tibor
-
@robert-hh I tried using a pull-up resistor, however, after doing so I lose signal from my other gas sensor.
I have already found the problem. The SCD30 likes to operate at a baudrate of 50.000 (as recommended in their documentation) instead of the 400.000 i was using.
Thanks for all the help!
-
@tiborrr the value is not very critical. I typically use 4.7 kOhm.
-
I don't think that need to enable them as on my particle devices it was working fine
I do have issues scanning for my I2C devices. Does this have something to do with this?
from scd30 import SCD30 from machine import I2C #I2C setup print("setup i2c") i2c = I2C(0) i2c.init(I2C.MASTER, baudrate=400000) #CO2 sensor setup #co2sensor = SCD30(i2c, 61) while True: print(i2c.scan()) time.sleep(1)
This sometimes returns my sensor but most of the times it doesn't
See the result below:
>>> setup i2c [] [] [] [] [] [] [] [] [97] [] [] [] [] [] [] [] [] [] [97]
-
On my SiPy Board with expansion Board I use:
i2c = I2C(0, pins=('P10','P9'))
i.e. reversing your pin configuration.
-
@tiborrr Some devices may have internal pull up resistors that can be enabled, however they may not be enough. Some breakout boards can include these already so you'd need to check their documentation.
-
@robert-hh wow this costed me sooo much time :(. @pycom please mention this in the I2C manual. I cannot imagine that I'm the only one who falls into this trap.
@thinginnovations in the past on my Particle devices the sensors worked on 3.3V. Why should I use an additional pullup resistor?
-
@tiborrr The pins the yellow and white cable go to on the Expansion board picture are P22 and P23, not P9 and P10. The P9 == G16, P10 == G17.
The three numbering schemes of Pycom are confusing. See also https://github.com/pycom/pycom-micropython-sigfox/blob/Dev/esp32/boards/WIPY/pins.csv
-
Did you add pull-up resistors to the SDA and SCL lines?