Step 1: What do we need

Picture of What do we need

3.png

4.png

5.png

6.png

7.png

Show All Items

Step 2: Wiring

Picture of Wiring

10.png

Now, we should connect the Grove Modules to the Arduino Breakout for LinkIt Smart 7688 Duo just as the picture shows below.

Step 3: Setup the Linkit Smart 7688 Duo

Picture of Setup the Linkit Smart 7688 Duo
The software work of the router consists of 5 parts, compatible with the previous router, control the relay from Mediatek Cloud Sandbox(MCS), upload the Grove Sensors to MCS, a website to write something for printer to print out, the code on ATmega32U4.

I assume you have been familiar with Linkit Smart 7688 Duo, if not, please clickhere to get started. Then go to the MT7688 terminal by SSH or serial.

Modify the configure file to change MT7688 into router mode.

vi /etc/config/network

Change the configure interface ‘lan’ and ‘wan’ as below shows.

config interface 'lan'

option proto 'static'

option netmask '255.255.255.0'

option ipaddr '192.168.100.1'

config interface 'wan'

option ifname 'eth0'

option proto 'dhcp'

We use the yunbridge for communicating between MT7688 and ATmega32U4, so, enable the yunbridge.

> uci set yunbridge.config.disabled='0'

> uci commit

Requests is the only Non-GMO HTTP library for Python, safe for human consumption. Requests allows you to send organic, grass-fed HTTP/1.1 requests, without the need for manual labor, I use it to communicate with MCS.

I use flask web framework for this Web APP, Flask is a lightweight Python web framework based on Werkzeug, Jinja 2 and good intentions. You can clickhttp://flask.pocoo.org/ to learn more information.

Next, install Python dependencies.

pip install requests flask Flask-WTF wtforms

Step 4: Configure the MediaTek Cloud Sandbox

Picture of Configure the MediaTek Cloud Sandbox

13.png

MediaTek Cloud Sandbox (MCS) is a cloud based data service platform for Internet of Things devices. If you don’t have an account please clickhttps://mcs.mediatek.com/oauth/en/signup to sign up.

MCS has already provided some useful tutorials, you can create the prototype and test device in MCS step by step following here.

Then in my project I create a new prototype for Linkit Smart 7688 named LinkitRouter, and add three data channels for this prototype they’re Button Temperature and Humidity just as picture below shows.

Now, you’ll get the Device ID, Device Key and 3 Data Channel ID, you can find the information in the test device detail page, and we will need them later.

Step 5: Upload the Arduino Code

Picture of Upload the Arduino Code

1. Download demo code at https://github.com/Lee-Kevin/20.IoTRouter

2. Click “Download zip” button on right side of webpage to download all codes.

3. Decompress the downloaded zip files to“C:\Users\Administrator\Documents\Arduino\” and remove “-master” in decompressed file name.

4. Launch Arduino IDE.

5. Click Sketch =>Add file to add routerBox_Arduino.ino file from“C:\Users\Administrator\Documents\Arduino\20.IoTRouter\RouterArduinoCode\routerBox_Arduino.ino”

6. Click Tools =>Board and select “Linkit Smart 7688 Duo” and chose the right port, as shown in the picture below.

7. Press CTRL +U to upload codes to your board. Wait a while, there will be saying “Done uploading”.

8. Congratulations, you have already completed the whole of the work on Arduino.

Step 6: Download the code from Github

Picture of Download the code from Github

16.png

17.png

18.png

Now, we have already install the requirements, download the code from github.

cd ~ & git clone https://github.com/Lee-Kevin/20.IoTRouter

Navigate to 20.IoTRouter and you can find there’re 3 folders, RouterArduinoCode, RouterScript and Drawings. RouterArduinoCode is the code that should be run on Arduino, RouterScript is the Python code should to be run on Linkit Smart 7688. Now we mv the RouterScript to /root/.

cd 20.IoTRouter/ & mv RouterScript/ /root/

Navigate to /root/RouterScript/ and edit the UpdateSensor.py and relay.py using vi editor.

cd ~ & cd /root/RouterScript/

vi UpdateSensor.py

vi relay.py

Change the deviceID, deviceKey and...

Read more »