I2C at expansion board
-
Hello there,
im a bit confused about setting up the I2C Bus.
I can use my sensor at Pin9 and Pin10 without any problems, but i cant manage to set up any other Pins for I2C. I read that this should be working but i couldnt get it done by now. I use FW 1.8.6The Sensor seems not to exist when i connect it to any other Pins. (i.e. Pins 11 and 12)
Actually i use a class to control my sensor
import time
import pycom
from machine import I2Cclass DHT12():
def __init__(self,pinSDA='P9',pinSCL='P10',bd=100000): self.i2c = I2C(2, pins=(pinSDA,pinSCL)) self.i2c.init(I2C.MASTER, baudrate=bd) self.addr = self.i2c.scan()When i change pinSDA to P19 and pinSCL to P20
i get I2C bus error and a strange behaviour
Bild Link)Thanks in advance for any help on this topic.
-
@lopyusr Try this before you class or def
i2c = I2C(0, I2C.MASTER, baudrate=100000, pins=('P8','P9'))What are you init -ing?
Or maybe try this
def __init__(self, i2c, address=0x29): # where0x29 is your device I2C address self.i2c = i2c self._address = address -
@lopyusr said in I2C at expansion board:
self.i2c = I2C(2, pins=(pinSDA,pinSCL))
self.i2c.init(I2C.MASTER, baudrate=bd)Please try the following instread:
self.i2c = I2C(2, mode=I2C.MASTER, pins=(pinSDA,pinSCL),baudrate=bd)
self.i2c.init(I2C.MASTER, baudrate=bd)Please also remember that I2C bus nr. 2 is emulated in software while I2C bus 0 and 1 are hardware I2C ports, so you might not get reliable communication at this speed when using bus nr. 2
-
Im building a driver file. So im initing the sensor at given ports.
When i try
i2c = I2C(0,mode=I2C.MASTER,pins=('P9','P10'),baudrate=1000000)i get the following result

i2c = I2C(0,mode=I2C.MASTER,pins=('P20','P19'),baudrate=1000000)
results in

when i try i2c.scan() at this config i dont get a result.
-
@ledbelly2142 It all works fine until i try changing the Pins i cant figure out what im doing wrong at this point :/
-
This post is deleted! -
@ledbelly2142 Im using a DHT12 temperature and humidity sensor. I dont get the point with that battery reading code. I just wonder why it is working on the Pins 9 and 10 but not at any onthers :/ Yfyi i use the Expansion board also. Best regards for your help.
-
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login