Ameba Arduino: [RTL8710AF] I2C – Communicate With Arduino UNO Via I2C

Introduction of I2C

  • I2C uses two pins, one is for data transmission (SDA), the other is for the clock (SCL). Master uses the SCL to inform Slave of the upcoming data transmission, and the data is transmitted through SDA.The I2C example was named “Wire” in the Arduino example. Although Arduino admitted this name seems to be a mistake, yet the name “Wire” often appear in the examples of Arduino.
    (Detail of the name “Wire”: Link, section “Use full, everyday words.”)

Materials

  • #3 Ameba RTL8710 Board x 1
  • Arduino UNOx 1

Example

In this example, we use Ameba as the I2C Master Writer, and use Arduino as the I2C Slave Receiver.
When the I2C Slave receives string sent from I2C Master, it prints the received string.
  • Setting up Arduino Uno to be I2C Slave

First, select Arduino in the Arduino IDE in “Tools” -> “Board” -> “Arduino/Genuino Uno”:

 4-1
Open the “Slave Receiver” example in “Examples” -> “Wire” -> “slave_receiver”:
 
4-2
 

  • Setting up Ameba to be I2C Master


Open another Arduino IDE window, make sure to choose Ameba in the IDE: “Tools” -> “Board” -> “Ameba RTL8710”

 
4-3
 
Then open the “Master Writer” exmaple, “File” -> “Examples” -> “AmebaWire” -> “master_writer”
 4-4

  • Wiring


The Arduino example uses A4 as the I2C SDA and A5 as the I2C SCL. RTL8710 does not have pins on these places but on Arduino UNO SDA/SCL, the wiring figure is shown below

 
4-5
 
Open the Arduino IDE of the Arduino Uno, and open the Serial Monitor, “Tools” -> “Serial Monitor”.
In the Serial Monitor, you can see the messages printed from Arduino Uno. 
 4-6
 
Next, press the reset button on Arduino Uno. Now the Arduino Uno is waiting for the connection from I2C Master.
We press the reset button on Ameba RTL8710 to start to send messages. Then observe the Serial Monitor, you can see the messages show up every 0.5 second.
 4-7
 

Code Reference

You can find detailed information of this example in the documentation of Arduino:
https://www.arduino.cc/en/Tutorial/MasterWriter

First use Wire.begin()/Wire.begin(address) to join the I2C bus as a master or slave, in the Master case the address is not required.
https://www.arduino.cc/en/Reference/WireBegin
Next, the Master uses Wire.beginTransmission(address) to begin a transmission to the I2C slave with the given address:
https://www.arduino.cc/en/Reference/WireBeginTransmission
Uses Wire.write() to send data, and finally use Wire.endTransmission() to end a transmission to a Slave and transmits the bytes that were queued:
https://www.arduino.cc/en/Reference/WireEndTransmission
Please confirm that QQ communication software is installed