Home > other >  The realtek RTL8722 run MicroPython on single chip microcomputer, with I2C to send and receive data
The realtek RTL8722 run MicroPython on single chip microcomputer, with I2C to send and receive data

Time:03-23

I2C is very common on a micro controller module, it just needs two wires can achieve maximum transmission speed of 3.4 Mbps, it USES the master-slave mode, a host can connect up to 128 at the same time from the machine, so often used in data transmission between the microcontroller and sensor, here we use ameba as host to connect from machine Arduino UNO, sent and received to verify the I2C,

Before connecting, please upload the following code to the Arduino UNO, "Examples - & gt; Wire - & gt; Slave_receiver
"Next, as shown in the following to connect, here we choose PA_26 as SDA pin, PA_25 as SCL.



By a line by line, please copy and paste the following code to the REPL, to observe the code effect,

 
From the machine import Pin, I2C
I2c=i2c (SCL="PA_25", sda="PA_26 freq=100000) # configure i2c with pins and freq. Of 100 KHZ
I2c. Scan ()
I2c. Writeto (8, 123) send # 1 byte to slave with 8 address
I2c. Readfrom (# 8, 6) receive 6 bytes from slave
  • Related