MPU-MCU UART Connection

The communication between MPU and the MCU on LinkIt Smart 7688 Duo development board is through a Serial port. The MCU communicates with OpenWrt Linux over UART. The table below illustrates the communication between the MCU and the MPU:

In ArduinoSerial1In Linux/dev/ttyS0
Corresponding PinsD0 and D1Pin MUXUART0 (GPIO12 and GPIO13)

An example is provided to demonstrate how to to establish communication between the MCU and the MPU by writing to and reading from the UART.

Blink — programming an Arduino sketch

The MCU implementation is an Arduino sketch. In this example, the sketch listens for the command sent from the MPU (Linux) and switches the on-board LED accordingly.

First, connect the board to your PC, then open Arduino IDE and copy and paste the following sketch code into the IDE:

void setup() {
    Serial.begin(115200);  // open serial connection to USB Serial port (connected to your computer)
    Serial1.begin(57600);  // open internal serial connection to MT7688AN
                           // in MT7688AN, this maps to device
    pinMode(13, OUTPUT);
void loop() {
    int c =;      // read from MT7688AN
    if (c != -1) {
        switch(c) {
          case '0':                // turn off D13 when receiving "0"
             digitalWrite(13, 0);
          case '1':                // turn off D13 when receiving "1"
             digitalWrite(13, 1);

Set the correct COM port from the IDE (check your Device Manager) by clicking Tools then Port. Upload the sketch to the board. Note the board is not blinking yet – you’ll need to write a program on the Linux side to finish the setup.

Blink — developing on Linux

You can program on the Linux side in C/C++, Python or Node.js. In this example, Python is used to send commands to the MCU (Arduino) to blink an on-board LED.

Use a text editor of your choice and create a new file, then copy the following code and save it.

import serial
import time
s = None
def setup():
    global s
    # open serial COM port to /dev/ttyS0, which maps to UART0(D0/D1)
    # the baudrate is set to 57600 and should be the same as the one
    # specified in the Arduino sketch uploaded to ATmega32U4.
    s = serial.Serial("/dev/ttyS0", 57600)
def loop():
    # send "1" to the Arduino sketch on ATmega32U4.
    # the sketch will turn on the LED attached to D13 on the board
    # send "0" to the sketch to turn off the LED
if __name__ == '__main__':
    while True:

Execute this Python program in the system console – the program writes strings of “1”s and “0”s to the /dev/ttyS0 port that maps to Serial1 interface in Arduino. The Arduino sketch that was uploaded in the previous section will receive the string and then blink the on-board LED accordingly. Note that the baud rate settings of this program must be the same as in the Arduino sketch.