From 7c77870ff4d3408a5611b78cb34c274f212286b3 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Fri, 10 Aug 2018 14:08:35 +0200 Subject: content update --- _posts/2017-08-11-simple-iot-application.md | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to '_posts/2017-08-11-simple-iot-application.md') diff --git a/_posts/2017-08-11-simple-iot-application.md b/_posts/2017-08-11-simple-iot-application.md index 2288a7e..68d6e70 100644 --- a/_posts/2017-08-11-simple-iot-application.md +++ b/_posts/2017-08-11-simple-iot-application.md @@ -39,8 +39,6 @@ Schema below represents what we will try to achieve and how different parts corr ![Overview](/files/simple-iot-application-overview.svg) - - ## Simple Python API I have always been a fan of simplicity so we will be using [Bottle: Python Web Framework](https://bottlepy.org/docs/dev/). It is a single file web framework that seriously simplifies working with routes, templating and has built-in web server that satisfies our need in this case. @@ -49,8 +47,6 @@ First we need to install bottle package. This can be done by downloading ```bott If you are using Linux or MacOS then Python is already installed. If you will try to test this on Windows please install [Python for Windows](https://www.python.org/downloads/windows/). There may be some problems with path when you will try to launch ```python webapp.py``` so please take care of this before you continue. - - ### Basic web application Most basic bottle application is quite simple. Paste code below in ```webapp.py``` file and save. @@ -89,16 +85,11 @@ If this fails at any time please fix it before you continue, because nothing bel > We use 0.0.0.0 as default host so that this app is available over your local network. If you find your local ip (```ifconfig```) and try accessing this site with your phone (if on same network/router as your machine) this should work as well (example of such ip ```http://192.168.1.15:5000```). This is a must have because Arduino will be accessing this application to send it's data. - - ### Web application security There is a lot to be said about security and is a topic of many books. Of course all this can not be written here but to just establish some basic security → you should always use SSL with your application. Some fantastic free certificates are available by [Let's Encrypt - Free SSL/TLS Certificates](https://letsencrypt.org). With SSL certificate installed you should then make use of HTTP headers and send your "API key" via a header. If your key is send via header then this key is encrypted by SSL and send encrypted over the network. Never send your api keys by GET parameter like ```http://example.com/?api_key=somekeyvalue```. The problem that this kind of sending presents is that this key is visible in logs and by network sniffers. -There is a fantastic article describing some aspects about security: [11 Web Application Security Best Practices -](https://www.keycdn.com/blog/web-application-security-best-practices/). Please check it out. - - +There is a fantastic article describing some aspects about security: [11 Web Application Security Best Practices](https://www.keycdn.com/blog/web-application-security-best-practices/). Please check it out. ### Simple API for writing data-points @@ -179,8 +170,6 @@ Table structure is as simple as it can be. We have ts (timestamp) and value (val Ok, now that we have some sort of a working API with some basic security so unwanted people can not post data to your database can we proceed further and try to program Arduino to send data to API. - - ## Sending data to API with Arduino MKR1000 First of all you should have MKR1000 module and microUSB cable to proceed. If you have ever done any work with Arduino you should know that you also need [Arduino IDE](https://www.arduino.cc/en/Main/Software). On provided link you should be able to download and install IDE. Once that task is completed and you have successfully run blink example you should proceed to the next step. @@ -280,7 +269,6 @@ As seen from example you can notice that Arduino is generating random integer be Now that we have API under the hood and Arduino is sending demo data we can now focus on data visualization. - ## Data visualization Before we continue we should examine our project folder structure. Currently we only have two files in our project: @@ -495,8 +483,6 @@ If you navigate to ```http://0.0.0.0:5000``` you should see rendered chart as sh Complete application with all the code is available for [download](/files/simple-iot-application.zip). - - ## Conclusion I hope this clarifies some aspects of IOT application development. Of course this is a minimal example and is far from what can be done in real life with some further dive into other technologies. -- cgit v1.2.3