LinkIt Smart 7688 (a compact controller board) is an open development board, based on the OpenWrt Linux distribution and MT7688. The board is designed especially for the prototyping of Rich Application IoT devices for Smart-Home. The board offers sufficient memory and storage to enable robust video processing. The platform also offers options to create device applications in Python, Node.js and C programming languages.This board is only a part of MediaTek LinkItTM Smart 7688 platform which includes other development boards.
Features as follow：
1. Pin-out for GPIO, I2C, I2S, SPI, UART, PWM and Ethernet Port.Build-in Mraa and UPM support.
2. Single input single output (1T1R) Wi-Fi 802.11 b/g/n.
3. USB host.
4. Micro SD slot.
5. OpenWrt Linux distribution
6. 580 MHz MIPS CPU,32MB Flash and 128MB DDR2 RAM.
LinkIt smart 7688 basic tutorial #1-#8 are aimed at helping you familiar with the features above.We assume that you had get started, and if you don’t ,you can browse MTK Labs or Seeed Studio WIKI first.Here are the link:
While UPM is a high level repository for sensors that use MRAA. The UPM repository provides software drivers for a wide variety of commonly used sensors and actuators. These software drivers interact with the underlying hardware platform (or microcontroller), as well as with the attached sensors, through calls to MRAA APIs.
The series of basic tutorial are based on Python 2.7.If you have any question or advice,please make a comment.
The purpose of LinkIt smart 7688 basic tutorial #1 is to help you understand GPIO and interrupt in Mraa library.Here we introduce Mraa GPIO output mode with lighting a LED , Mraa GPIO input mode and Mraa GPIO interrupt with checking a button.
Things you need
Linkit smart 7688 *1
Resistor 10K *1
3mm or 5mm LED *1
Jumper wire *1
USB cable *1
The picture shows the connection way of this tutorial. Please ensure the polarity of the LED (the long lead or the bent lead is positive).
Mraa is already installed in the system image of LinkIt Smart 7688, so you don't need to install it again. However if you want to update and upgrade the library, please refer to https://github.com/intel-iot-devkit/mraa for more information.
We can import Mraa library in python directly:
Still remember which pin we connect the LED to? It is connected to P9, which the GPIO 21 maps to ,according to the pinout diagram below. So we set GPIO 21 to output mode and call write(0) to set the pin state to LOW or call write(1) to set the pin state to HIGH.
import mraaimport time led = mraa.Gpio(21)#set GPIO21 to output modeled.dir(mraa.DIR_OUT)while(True): time.sleep(1) led.write(0) time.sleep(1) led.write(1)
Paste the code above into a new file and save it as led.py. Then run it :
Can you see the LED twinkling? Congratulation! It's a good start to your maker road. And if it does't success, please check the connection after stopping the script with CTRL+C .
We connect button to P8 pin, which matchs GPIO 20 in pin-out diagram. So we can set GPIO 20 to input mode, and call read() method to get states of the button.
import mraa import time button = mraa.Gpio(20)#set GPIO 20 to input mode button.dir(mraa.DIR_IN) while True: print "P8 state:", button.read() time.sleep(1)
Paste the code above into a new file and save it as button.py. Then run it :
Try to press the button and release it to see whether the states will change or not.
Finally, an interrupt service routine can be installed to P8 pin and invoked when the values of the input has changed. Call isr API with the trigger type you want to register and the function to be called. Note that the function runs in a different thread.
import mraaimport time #interrupt service routinedef button_callback(userdata): print "interrupt" led.write(1) led = mraa.Gpio(21)led.dir(mraa.DIR_OUT) button = mraa.Gpio(20)button.dir(mraa.DIR_IN)#isr mode , trigger types include EDGE_FALLING, EDGE_BOTH ,EDGE_NONE, EDGE_RISINGbutton.isr(mraa.EDGE_RISING,button_callback,None) while(True): time.sleep(1) led.write(0)
Paste the code above into a new file and save it as isrlight.py. Then run it :
When press the button ,the LED will light in this code. This is the most simple way to use interrupt. For more details about GPIO and interrupt ,please refer to https://github.com/intel-iot-devkit/mraa/blob/master/api/mraa/gpio.h