From ae24d9a8869c497537839f330384cbadb2cf687c Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Tue, 31 Oct 2023 10:17:43 +0100 Subject: Updated theme --- public/simple-iot-application.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'public/simple-iot-application.html') diff --git a/public/simple-iot-application.html b/public/simple-iot-application.html index 669613b..e4ce2fa 100755 --- a/public/simple-iot-application.html +++ b/public/simple-iot-application.html @@ -28,7 +28,7 @@ and not well optimized and there are much better ways in handling some aspects of the application but that requires much deeper knowledge of technology that is not needed for an example like this.

Development steps

  1. Simple Python API that will receive and store incoming data.
  2. Prototype C++ code that will read "sensor data" and transmit it to API.
  3. Data visualization with charts → extends Python web application.

Step 1. and 3. will share the same web application. One route will be dedicated to API and another to serving HTML with chart.

Schema below represents what we will try to achieve and how different parts -correlates to each other.

Overview

Simple Python API

I have always been a fan of simplicity so we will be using Bottle: Python Web +correlates to each other.

Overview

Simple Python API

I have always been a fan of simplicity so we will be using Bottle: Python Web Framework. 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.

First we need to install bottle package. This can be done by downloading @@ -144,8 +144,8 @@ This software also allows you to set headers → for basic security with API_KEY )

To run this simply go to folder containing python file and run python webapp.py from terminal. If everything goes ok you should have simple API available via POST method on /api route.

After testing the service with Restlet Client you should be able to view your -data in a database file data.db.

REST settings example

You can also check the contents of new database file by using desktop client -for SQLite → DB Browser for SQLite.

SQLite database example

Table structure is as simple as it can be. We have ts (timestamp) and value +data in a database file data.db.

REST settings example

You can also check the contents of new database file by using desktop client +for SQLite → DB Browser for SQLite.

SQLite database example

Table structure is as simple as it can be. We have ts (timestamp) and value (value from Arduino). As you can see timestamp is generated on API side. If you would happen to have atomic clock on Arduino it would be then better to generate and send timestamp with the value. This would be particularity useful if we @@ -430,15 +430,15 @@ this part are listed below the code.

 </html>
 

Now the folder structure should look like:

simple-iot-app/

Ok, lets now start application and start feeding it data.

  1. python webapp.py
  2. connect Arduino MKR1000 to power source
  3. open browser and go to http://0.0.0.0:5000

If everything goes well you should be seeing new data-points rendered on chart every 5 seconds.

If you navigate to http://0.0.0.0:5000 you should see rendered chart as -shown on picture below.

Application output

Complete application with all the code is available for +shown on picture below.

Application output

Complete application with all the code is available for download.

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.

If you would like to continue exploring IOT world here are some interesting -resources for you to examine:

Any comment or additional ideas are welcomed in comments below.


Posts from blogs I follow around the net