Hello all - I’m playing with the SparkFun Optical Tracking Sensor and trying to test it with an XRP robot running MicroPython
I’ve read the setup documentation and found a post on this Community Forum and have been able to connect to the I2C bus and verify (by pinging) that the sensor is online.
However, I get inconsistent results. Sometimes my program works and i can see the output of the scan and the code indicts that the sensor is connected. At other times, however, the code indicates that there are no devices on the bus and that the sensor is not online.
Power cycling my XRP/Raspberry Pi does not seem to reliably fix the problem.
Does anyone have tips on how I can improve the reliability of my connection to the I2C device?
Here’s my code
import qwiic_i2c
import qwiic_otos
my_bus = qwiic_i2c.get_i2c_driver(sda=4, scl=5, frequency=100000)
myOtos = qwiic_otos.QwiicOTOS(23, my_bus)
scan_list = my_bus.scan()
print(“Bus scan:”, scan_list)
ping_result = my_bus.ping(23)
print(“Device is connected:”, ping_result)
Sometimes this works, and it is pretty consistent (i.e., I can run the program multiple times in a row with success)
Bus scan: [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]
Device is connected: True
Other times the device is offline and power cycling the board and disconnecting and reconnecting the USB connection between my laptop and the device does not help clear the issue.
Bus scan: []
Device is connected: False
Is there something that I need to do to improve the consistency of my connections?
Thanks in advance.