I2C Master-Slave
Posted: Tue Mar 24, 2020 8:24 am
Hi all,
i´m starting to work with Micropython and i´m having some questions about it.
I was trying to test the I2C communication in my Pyboard, and for that, I joined the sda pins (X10, Y10) together, and also for the scl(pins X9 and Y9), and I was trying to configure one as master and the other as slave, but its not working.
-------------------------------------------------------------
i2c = I2C(1)
i2c = I2C(1, I2C.MASTER)
i2c.init(I2C.MASTER, baudrate=400000)
i2c1 = I2C(2)
i2c1.init(I2C.SLAVE, addr=0x11)
i2c.scan()
[]
i2c.send('abc', addr=0x11)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 110] ETIMEDOUT
I also configured the pull-up resistance for that:
------------------------------------------------
scl = Pin('X9', Pin.IN, Pin.PULL_UP)
sda = Pin('X10', Pin.IN, Pin.PULL_UP)
------------------------------------------------------
When I scan it, its empty, and i am getting always an error in sending...Could you help me with this, i am configuring something wrong?
Thanks so much in advance!!!
i´m starting to work with Micropython and i´m having some questions about it.
I was trying to test the I2C communication in my Pyboard, and for that, I joined the sda pins (X10, Y10) together, and also for the scl(pins X9 and Y9), and I was trying to configure one as master and the other as slave, but its not working.
-------------------------------------------------------------
i2c = I2C(1)
i2c = I2C(1, I2C.MASTER)
i2c.init(I2C.MASTER, baudrate=400000)
i2c1 = I2C(2)
i2c1.init(I2C.SLAVE, addr=0x11)
i2c.scan()
[]
i2c.send('abc', addr=0x11)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 110] ETIMEDOUT
I also configured the pull-up resistance for that:
------------------------------------------------
scl = Pin('X9', Pin.IN, Pin.PULL_UP)
sda = Pin('X10', Pin.IN, Pin.PULL_UP)
------------------------------------------------------
When I scan it, its empty, and i am getting always an error in sending...Could you help me with this, i am configuring something wrong?
Thanks so much in advance!!!