Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

Help with MPL3115A2 and Raspberry Pi Pico
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Help with MPL3115A2 and Raspberry Pi Pico

by antoniopared on Tue Oct 26, 2021 1:43 pm

Hello,

this is my first project with microcontrollers, and i'd like to ask for help in figuring out what i am doing wrong. i connected an MPL3115A2 to a Raspberry Pi Pico running CircuitPython 7.

here is my code:

Code: Select all | TOGGLE FULL SIZE
import board
import adafruit_mpl3115a2
import busio
import time

scldata = board.GP7
sdadata = board.GP6

i2c = busio.I2C(scldata, sdadata)

sensor = adafruit_mpl3115a2.MPL3115A2(i2c)


and here is the output:

Code: Select all | TOGGLE FULL SIZE
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Traceback (most recent call last):
  File "code.py", line 11, in <module>
  File "/lib/adafruit_mpl3115a2.py", line 149, in __init__
  File "/lib/adafruit_mpl3115a2.py", line 194, in _poll_reg1
  File "/lib/adafruit_mpl3115a2.py", line 171, in _read_u8
  File "/lib/adafruit_mpl3115a2.py", line 167, in _read_into
OSError: [Errno 116] ETIMEDOUT

Code done running.

Press any key to enter the REPL. Use CTRL-D to reload.


am i missing something? thanks!

antoniopared
 
Posts: 4
Joined: Tue Oct 26, 2021 1:31 pm

Re: Help with MPL3115A2 and Raspberry Pi Pico

by adafruit_support_carter on Thu Oct 28, 2021 11:42 am

Code looks OK. It may be something hardware related. Please post a photo of your setup showing how everything is connected.

adafruit_support_carter
 
Posts: 21865
Joined: Tue Nov 29, 2016 2:45 pm

Re: Help with MPL3115A2 and Raspberry Pi Pico

by antoniopared on Thu Oct 28, 2021 1:03 pm

hello, thank you for the reply. please see below photo and let me know if i need to post a different angle. thank you!

20211029_004346.jpg
20211029_004346.jpg (140.54 KiB) Viewed 86 times

antoniopared
 
Posts: 4
Joined: Tue Oct 26, 2021 1:31 pm

Re: Help with MPL3115A2 and Raspberry Pi Pico

by adafruit_support_carter on Thu Oct 28, 2021 1:20 pm

Thanks. That looks generally OK. Does it show up OK in an I2C scan?
https://learn.adafruit.com/scanning-i2c ... cuitpython

You'll want to continue to setup your I2C bus same as you have been (the guide is generic). So keep this past as is:
Code: Select all | TOGGLE FULL SIZE
scldata = board.GP7
sdadata = board.GP6

i2c = busio.I2C(scldata, sdadata)

adafruit_support_carter
 
Posts: 21865
Joined: Tue Nov 29, 2016 2:45 pm

Re: Help with MPL3115A2 and Raspberry Pi Pico

by antoniopared on Fri Oct 29, 2021 8:45 am

here is my code now,

Code: Select all | TOGGLE FULL SIZE
import busio
import board
import adafruit_mpl3115a2
import time

scldata = board.GP7
sdadata = board.GP6

i2c = busio.I2C(scldata, sdadata)


while not i2c.try_lock():
    pass

try:
    while True:
        print("I2C addresses found:", [hex(device_address)
              for device_address in i2c.scan()])
        time.sleep(2)

finally:  # unlock the i2c bus when ctrl-c'ing out of the loop
    i2c.unlock()


and it outputs this messge:

Code: Select all | TOGGLE FULL SIZE
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
I2C addresses found: ['0x60']
I2C addresses found: ['0x60']
I2C addresses found: ['0x60']
I2C addresses found: ['0x60']
Traceback (most recent call last):
  File "code.py", line 19, in <module>
KeyboardInterrupt:

Code done running.


but if i add these two lines at the end:

Code: Select all | TOGGLE FULL SIZE
    sensor = adafruit_mpl3115a2.MPL3115A2(i2c)
    print (sensor)


the same error will occur:

Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "code.py", line 28, in <module>
  File "/lib/adafruit_mpl3115a2.py", line 149, in __init__
  File "/lib/adafruit_mpl3115a2.py", line 194, in _poll_reg1
  File "/lib/adafruit_mpl3115a2.py", line 171, in _read_u8
  File "/lib/adafruit_mpl3115a2.py", line 167, in _read_into
OSError: [Errno 116] ETIMEDOUT


should i try adding a 10k resistor on both the SDA and SCL lines?

antoniopared
 
Posts: 4
Joined: Tue Oct 26, 2021 1:31 pm

Re: Help with MPL3115A2 and Raspberry Pi Pico

by adafruit_support_carter on Fri Oct 29, 2021 10:30 am

OK, set this up and was able to recreate this issue right away. Seeing all same behavior you are - I2C scan works, but get ETIMEDOUT. Not sure what is happening. Opened a new issue for this here:
https://github.com/adafruit/Adafruit_Ci ... /issues/19

adafruit_support_carter
 
Posts: 21865
Joined: Tue Nov 29, 2016 2:45 pm

Re: Help with MPL3115A2 and Raspberry Pi Pico

by antoniopared on Fri Oct 29, 2021 11:40 am

wow thank you so much for looking and ooening the github issue! i will keep an eye on it as well... :-)

antoniopared
 
Posts: 4
Joined: Tue Oct 26, 2021 1:31 pm

Please be positive and constructive with your questions and comments.