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/ ... e.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
TypeError:argument has wrong type
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: TypeError:argument has wrong type
As the error message suggests, your pin names should be integer, not strings. All Pin names in micropython are the gpio numbers of the corresponding cpu gpio. I don't know if "P10" in your case is pin 10, that depends on your board, as every manufacturer labels his board as he wants but generally P10 could be pin 10. Just look it up in the documentation of your specific product or test is by setting a pin as output and HIGH and connect an LED to the pin and you'll find the one that drives the led.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Re: TypeError:argument has wrong type
@alexmerchant You are still in the wrong forum and writing for the wrong Micropython dialect. You are using a SiPy board form Pycom. The forum for these board is at https://forum.pycom.io/. There is also the link to the matching documentation https://docs.pycom.io/