Wrong SCL / SDA (MICROPY_HW_I2C0_SCL) for PIMORONI_TINY2040
I am trying to get I2C working on my Tiny2040 board. Using the board as a responder in a responder/controller manner. I have some minimal code to set up the board using pin four as SDA and pin five as SCL as described in the GPIO diagrams below:
https://shop.pimoroni.com/products/tiny-2040
I am using https://github.com/epmoyer/I2CResponder/blob/main/i2c_responder.py with a minimal setup code that looks like the following on bus 0:
i2c_responder = I2CResponder(0, sda_gpio=0,scl_gpio=1,responder_address=0x41)
while 1:
if i2c_responder.read_is_pending():
i2c_responder.put_read_data(0x2)
And for testing, I tried on bus 1 as well against pin 6 and 7:
i2c_responder = I2CResponder(1, sda_gpio=6,scl_gpio=7,responder_address=0x41)
while 1:
if i2c_responder.read_is_pending():
i2c_responder.put_read_data(0x2)
I am using an RPI as a controller executing: sudo i2cdetect -y 1
Now the strange thing is:
- I get 0 response on bus 0 (i2cdetect detects no device)
- I get a signal on bus one and appear on my RPI (i2cdetect detects the device and I can query the value)
I was perusing the code and saw this:
https://github.com/micropython/micropython/blob/master/ports/rp2/boards/PIMORONI_TINY2040/mpconfigboard.h
#define MICROPY_HW_I2C0_SCL (4)
#define MICROPY_HW_I2C0_SDA (5)
Should it not be:
#define MICROPY_HW_I2C0_SCL **(5)**
#define MICROPY_HW_I2C0_SDA **(4)**
I tried to recompile the above with the mentioned change without much effect. Any thoughts?
TypeError:argument has wrong type
Hi, I am new with Python and currently trying to display values on a LED screen (it is a RiT but I intend to use the SSD1306 one which seems appropriate) using a I2C connection. Thus, I first do a : from machine import I2C. I also connected the SDA, SCL, GND and VCC of the screen to the corresponding ones on my Pycom device. However, when I try to init the I2C bus it does not work because apparently, the arguments of the parameters do not have the right type.
scl=Pin('P10',Pin.IN)
sda=Pin('P9',Pin.IN)
i2c=I2C.init(sda,scl)
This is the block of code which does not work. My question is : why do I get this error message when it is written on the I2C class documentation (which you can find here : https://docs.micropython.org/en/latest/library/machine.I2C.html) that sda and scl should be pin objects, which I did. Furthermore, if I just write : i2c=I2C(sda,scl) I got the following message : TypeError: can't convert Pin to it.
Thank you all for your help