So I am trying to run a simple I2C scan program in Micropython that scans for the I2C device I have connected to my XBee3 and then simply prints out that it saw the I2C device during the scan.
I’m using the MCP23017 DIP device… here is the pdf with the port schematic:
Here is the xbee3 hardware pdf, I am using the THT module… page 27 has the pin outs.
My hardware connections are as follows:
MCP Vss pin 10 to GND
MCP Vdd pin 09 to 3.3V XBee supply pin 1(on xbee THT)
MCP A0,A1,A2 pins 15, 16, 17 to GND
MCP reset pin 18 to 3.3V
MCP SCK pin 12 to XBee pin 19 SCK
MCP SDA pin 13 to XBee pin 7 SDA
XBee connected to computer and connection confirmed to be all good.
the code I am using:
from machine import I2C
print(” | XBee MicroPython I2C Scanner Sample |“)
Instantiate an I2C peripheral.
i2c = I2C(1)
Scan for I2C slaves connected to the interface and print their address.
for address in i2c.scan():
print(“- I2C device found at address: %s” % hex(address))
That’s it. I have checked all the GND lines, have checked voltages at connections with my multimeter.
So my question is as follows:
My setup doesn’t find anything in the scanning process… or at least the program only prints out the print statements and that’s it. Anything that I am clearly forgetting to implement? Not sure why my program doesn’t work to have the xbee scan and “see” the I2C device.
What firmware version are you working with and what setting are not at default values?
it looks like…
firmaware: 100A (latest)
settings that are not at default values:
CE: Join Network 
JV: Enabled 
PS: Enabled 
AP: MicroPython REPL 
D6: Digital Out, Low 
D7: Digital Out, Low 
D0: Digital Out, Low 
D1: I2C SCL 
D2: Digital Out, Low 
D4: Digital Out, Low 
D5: Digital Out, Low 
D9: Digital Out, Low 
P1: I2C SDA 
im reading .70 volts at the SDA and SCL lines… if that means anything to u.
You do need to have the proper libraries loaded. I would also suggest using an XBIB-CU-TH board and connect one of the I2C sensors we do have for it. That will allow you to see it functioning.
Imported a sample xbee micropython I2C project from the pycharm IDE. it has “from machine import I2C” as its only import. The MCP23017 would need libraries imported too or?..
And I would use the XBIB-CU-TH board but I dont have it. I am using the grove dev board. Either way an externally connected I2C device should work just the same here… in theory.
Yes, they would all need to be in the library folder on the XBee and would need to be imported.
I am not sure if the grove boards headers go to the correct pins. The other board they do have a header that is for that interface.
pull up resistors… not sure about the libraries but I added the pull up resistors, one from SDA to Vcc and the other from SCL to Vcc. i2c.scan() found the device :D.
@edunn106, You might want to copy this comment to an answer to your question, and then select that answer as “correct” so that it’s clear you’ve come up with a solution to your problem. And if anyone searching in the future finds your question they’ll clearly see what the solution was.