I use a maix bit as a slave and run the following code on it.
from machine import I2C count = 0 def on_receive(data): print("on_receive:",data) def on_transmit(): count = count+1 print("on_transmit, send:",count) return count def on_event(event): print("on_event:",event) i2c = I2C(I2C.I2C0, mode=I2C.MODE_SLAVE, scl=28, sda=29, addr=0x24, addr_size=7, on_receive=on_receive, on_transmit=on_transmit, on_event=on_event) while True: pass
At the same time I use a raspberry pico as a master. And I connect PIN8 of the pico to PIN29 of the maix bit, PIN9 of the pico to PIN28 of the maix, GROUND of the pico to GROUND of the maix bit and 3V3 of the pico to 3V3 of the maix bit. I run the following code on the pico.
from machine import Pin, I2C import time i2c = I2C(0, scl=Pin(9), sda=Pin(8), freq=100000) while True: device = i2c.scan() print(device) time.sleep(3)
But I does get these working. Can anyone give some advices? Thanks.