Skip to content

While accesing sensors on the RP2040 give results that are not as expected when not using the REPL #33

Closed
@jposada202020

Description

@jposada202020

While accessing two sensors in this case:
BH1750
MMA8451

This is seeing mostly in the RP2040. Have tested with the SAMD51 and the nRF52840 without seeing this issue.

Error

>>> import test_two_sensors
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "test_two_sensors.py", line 12, in <module>
  File "/lib/adafruit_mma8451.py", line 120, in __init__
ValueError: No I2C device at address: 1d

test code

import time
import board
import adafruit_mma8451
import adafruit_tca9548a
import adafruit_bh1750

# import test_two_sensors

i2c = board.I2C()
tca = adafruit_tca9548a.TCA9548A(i2c)
sensor2 = adafruit_bh1750.BH1750(tca[4])
sensor = adafruit_mma8451.MMA8451(tca[1])


while True:
    x, y, z = sensor.acceleration
    print("Acceleration: x={0:0.3f}m/s^2 y={1:0.3f}m/s^2 z={2:0.3f}m/s^2".format(x, y, z))
    time.sleep(1)
    print("%.2f Lux" % sensor2.lux)
    time.sleep(1)

Other Information

  • The test is done using a file and not in writing the instructions in the REPL.
  • This behavior is seeing with other sensors as MPL3115A2. My tests are not conclusive if the BH1750 are in fault or is the RP2040, or the REPL.
  • Sometimes, while testing the first test will be ok, but then it will not work again, not even unplugging the RP2040 from the USB connection

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions