diff options
| -rw-r--r-- | .jekyll-metadata | bin | 32386 -> 32623 bytes | |||
| -rw-r--r-- | _config.yml | 2 | ||||
| -rw-r--r-- | _posts/2017-08-11-simple-iot-application.md | 16 |
3 files changed, 2 insertions, 16 deletions
diff --git a/.jekyll-metadata b/.jekyll-metadata index 7ac85dd..edcad04 100644 --- a/.jekyll-metadata +++ b/.jekyll-metadata | |||
| Binary files differ | |||
diff --git a/_config.yml b/_config.yml index 290fe7b..05b90b0 100644 --- a/_config.yml +++ b/_config.yml | |||
| @@ -13,7 +13,7 @@ domain: https://mitjafelicijan.com/ | |||
| 13 | description: Embedded systems developer and fanatical fan of science fiction | 13 | description: Embedded systems developer and fanatical fan of science fiction |
| 14 | twitter: "@mitjafelicijan" | 14 | twitter: "@mitjafelicijan" |
| 15 | avatar: assets/avatar.gif | 15 | avatar: assets/avatar.gif |
| 16 | cache_version: 20180803 | 16 | cache_version: 20180810 |
| 17 | theme_color: "#c242f4" | 17 | theme_color: "#c242f4" |
| 18 | 18 | ||
| 19 | kramdown: | 19 | kramdown: |
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 | |||
| 39 | 39 | ||
| 40 |  | 40 |  |
| 41 | 41 | ||
| 42 | |||
| 43 | |||
| 44 | ## Simple Python API | 42 | ## Simple Python API |
| 45 | 43 | ||
| 46 | 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. | 44 | 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 | |||
| 49 | 47 | ||
| 50 | 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. | 48 | 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. |
| 51 | 49 | ||
| 52 | |||
| 53 | |||
| 54 | ### Basic web application | 50 | ### Basic web application |
| 55 | 51 | ||
| 56 | Most basic bottle application is quite simple. Paste code below in ```webapp.py``` file and save. | 52 | 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 | |||
| 89 | 85 | ||
| 90 | > 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. | 86 | > 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. |
| 91 | 87 | ||
| 92 | |||
| 93 | |||
| 94 | ### Web application security | 88 | ### Web application security |
| 95 | 89 | ||
| 96 | 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. | 90 | 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. |
| 97 | 91 | ||
| 98 | There is a fantastic article describing some aspects about security: [11 Web Application Security Best Practices | 92 | 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. |
| 99 | ](https://www.keycdn.com/blog/web-application-security-best-practices/). Please check it out. | ||
| 100 | |||
| 101 | |||
| 102 | 93 | ||
| 103 | ### Simple API for writing data-points | 94 | ### Simple API for writing data-points |
| 104 | 95 | ||
| @@ -179,8 +170,6 @@ Table structure is as simple as it can be. We have ts (timestamp) and value (val | |||
| 179 | 170 | ||
| 180 | 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. | 171 | 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. |
| 181 | 172 | ||
| 182 | |||
| 183 | |||
| 184 | ## Sending data to API with Arduino MKR1000 | 173 | ## Sending data to API with Arduino MKR1000 |
| 185 | 174 | ||
| 186 | 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. | 175 | 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 | |||
| 280 | 269 | ||
| 281 | Now that we have API under the hood and Arduino is sending demo data we can now focus on data visualization. | 270 | Now that we have API under the hood and Arduino is sending demo data we can now focus on data visualization. |
| 282 | 271 | ||
| 283 | |||
| 284 | ## Data visualization | 272 | ## Data visualization |
| 285 | 273 | ||
| 286 | Before we continue we should examine our project folder structure. Currently we only have two files in our project: | 274 | 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 | |||
| 495 | 483 | ||
| 496 | Complete application with all the code is available for [download](/files/simple-iot-application.zip). | 484 | Complete application with all the code is available for [download](/files/simple-iot-application.zip). |
| 497 | 485 | ||
| 498 | |||
| 499 | |||
| 500 | ## Conclusion | 486 | ## Conclusion |
| 501 | 487 | ||
| 502 | 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. | 488 | 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. |
