User manual

MediaTek LinkIt™ Smart 7688 Developer's Guide
© 2015, 2016 MediaTek Inc.
Page 80
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
This is a Python interface for the Firmata protocol used on the MPU. You can install it
by typing pip install PyMata in the console. At the time of writing, LinkIt Smart 7688
Duo supports version
pymata-2.1.
Note: The LinkIt Smart 7688 Duo needs to be in Station mode in order to use pip to install the
pyFirmata and PyMata interface, please see section 4.3.2, “Station Mode” for details on how to set
station mode.
6.6.4. PyFirmata Approach
Uploading The Arduino Firmata Sketch
This section describes setting up Arduino to listen for Firmata commands from the Serial
port.
1) Open the Arduino IDE 1.6.5
2) In Arduino IDE, open the example File > Examples > Firmata > StandardFirmata
This built-in example is for Arduino Uno, which uses
Serial as Serial port.
However, LinkIt Smart 7688 Duo uses
Serial1 to communicate with OpenWrt.
Therefore, you’ll need to change the listening port of this example from
Serial to Serial1.Find the following line in the example:
Firmata.begin(57600);
3) And change it to:
Serial1.begin(57600);
Firmata.begin(Serial1);
4) Upload the sketch. After uploading the sketch, Arduino is ready to receive commands
from the Linux side.
Running Your Blink Example Using pyFirmata
After pyFirmata is installed, you’re ready to run a blink example.
1) In the console, create a python file called blink_with_firmata.py
2) Open the file and copy and paste the following example code. This example code is
modified to work for LinkIt Smart 7688 Duo. For example:
from pyfirmata import Arduino, util
from time import sleep
board = Arduino('/dev/ttyS0')
print "Start blinking D13"
while True:
board.digital[13].write(1)
sleep(0.5)