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.
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.
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.
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.