We're living in a very special tech era. It's possible to do almost anything using Internet: from shopping to virtually visit places really far away from you. Considering the rise of IoT, Internet becomes even more important, because now machines and devices can use Internet for several purposes (in other words: Internet now is not only for humans!). To sum up, Internet totally rules the world! But... if Internet connection fails, everything goes down too!
This is what this project's about: check Internet connection quality. So, using this project, it's possible to check if your Internet connection is good or not based on amount of downtimes counted during a certain period. Further, this information is uploaded to ThingSpeak and a Tweet is generated, making ThingSpeak and Twitter very good data sources of your Internet quality.
Also, it's important to say that Tweets will be sent by ThingSpeak (through an integration between Twitter and ThingSpeak). So, only HTTPS requisitions will be necessary for data uploading, dispensing any extra libraries. It makes this project a light-weight one for LinkIt Smart 7688 Duo.
Getting startedFirst of all, I strongly recommend expanding the Flash memory of LinkIt Smart 7688 Duo using a SD Card. The board has a good Flash size (32MB), but there's a small amount of memory for user (Linux and its applications, in this case, consume almost all 32MB). So, using an expanded memory, you'll have much more memory to develop so many things, making LinkIt Smart 7688 Duo even more incredible.
To expand the board's memory, I recommend this great tutorial, made by Akash Ravichandran.
Note: before following this tutorial, be sure to have an available SD Card (8GB) next to you.
After that, it'll be necessary to access board by SSH. To do that, I recommend following this tutorial (official MediaTek tutorial / getting started guide for LinkIt Smart 7688 Duo).
Note: if you use Windows, I strongly recommend you use PuTTy application for SSH communicating with board.
Few more things to set before codingBefore coding this project, there are a few things you need to set up. Basically, you'll need to create Twitter and a ThingSpeak accounts and integrate them. Follow the steps below to do it:
- Create a Twitter account
There's no secret here. Just go to Twitter's website and create an account for you.
- Create a ThingSpeak account and integrating with your Twitter's account
Go to ThingSpeak's website and create an account for you. After that, create a ThingSpeak Channel (click on Channels > My channels and follow screen instructions) and write down the Write API KEY of your channel. It'll be necessary further in this tutorial.
Keep ThingSpeak open and logged in, and open (and log into) Twitter's website in another tab of your browser. Click on ThingSpeak tab and click on Apps > ThingTweet. Write down the API Key shown in "Example API Endpoint" section (it's located in center-right sector of the page). It'll be necessary further in this tutorial. Then click on "Link Twitter Account" button and follow on-screen instructions to finish integration between Twitter and ThingSpeak.
Coding time!Now it's time for coding! Please pay attention to code's comments.
Notes:
1) To put the code into the board, I used nano text editor.
2) To run this project, simply execute the following command:
python NameOfYourPythonFile.py
3) After running this project, enjoy! Check your Twitter and ThingSpeak accounts to know more about your Internet connection
Booting 'n' RunningA really interesting thing to do is make this project start automatically when board boots. To do this, save your Python script in the root folder and follow these instructions:
- Create a file named DTMonitor (no extension) in /etc/init.d using the following command:
nano /etc/init.d/DTMonitor
- Paste the following content on the file:
#!/bin/sh /etc/rc.common
START=99
STOP=15
BIN="python /root/DTMonitor.py & 2> /dev/null"
PID="/tmp/run/DTMonitor.pid"
start() {
if ! start-stop-daemon -S -b -q -m -p $PID -x $BIN; then
exit 1
fi
}
stop() {
if ! start-stop-daemon -K -q -p $PID; then
exit 1
fi
}
- Give execution permission to this script by using this command:
chmod +x DTMonitor
- Go to root folder and execute the following command:
/etc/init.d/DTMonitor enable
- All set! Now just reboot your LinkIt Smart 7688 Duo and the project will start automatically!
I would like to thank Douglas Salin Zuqueto for helping me so much on auto-start script.
Comments