Tomsik
Posts: 6
Joined: Fri Feb 21, 2020 6:44 am

IoT WebServer

Fri Feb 21, 2020 7:02 am

Hello, I'm a beginner with raspberry but I have experience in programming embedded device, especially STM32 microcontrollers.
I've got an idea, I need to do a gateway for publishing some data to web from my IoT devices. I have IoT devices that transmit data to one node. The node has data from all devices in memory and another device can read these data through SPI, the node is SPI slave.

In nowadays I've implemented it that Raspberry read SPI data and write to ThingSpeak server (by python), but I want to have own web server.
I intend to use Raspberry. Raspberry will read data from SPI. But on another hand, I need implemented web server with database for storing these data.
I have just experience with Python and SPI. I don't know how to make Web Server and how to write the data to a database.
How can I start with that, please?

User avatar
neilgl
Posts: 2033
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: IoT WebServer

Fri Feb 21, 2020 9:56 am

You could install mariadb to write the values into a database. See
https://mariadb.com/resources/blog/how- ... o-mariadb/
For the webserver, use Apache2 or nginx (or flask etc. etc.)
You will need a lot of security set up if you are going on to the public internet.

Tomsik
Posts: 6
Joined: Fri Feb 21, 2020 6:44 am

Re: IoT WebServer

Fri Feb 21, 2020 10:03 am

I forgot to mention that WebServer and Database should be in standard HDD or maybe SSD.

tpyo kingg
Posts: 809
Joined: Mon Apr 09, 2018 5:26 pm
Location: N. Finland

Re: IoT WebServer

Fri Feb 21, 2020 10:30 am

Tomsik wrote:
Fri Feb 21, 2020 7:02 am
I have just experience with Python and SPI. I don't know how to make Web Server and how to write the data to a database.
How can I start with that, please?
You might also look at Flask and sqlite.

How many megabyes, gigabytes, or terabytes of data are you talking about and how complex are the records?

PhatFil
Posts: 1665
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: IoT WebServer

Fri Feb 21, 2020 10:46 am

If your collecting masses of data like temperatures every few seconds for real time analysis and reaction for pid controlled heating for example, long term archiving of every record may not be ideal, and rather than working on complex selective deletion of redundant data perhaps you may want to consider using influxDB which is a 'post'-relational dbs in that its designed to handle datasets and automatically delete redundant data maintaining a representative hourly/daily average if a particular data set warrants it.

https://www.youtube.com/watch?v=JdV4x92 ... ex=18&t=0s
May explain better than i have.

Tomsik
Posts: 6
Joined: Fri Feb 21, 2020 6:44 am

Re: IoT WebServer

Fri Feb 21, 2020 11:11 am

tpyo kingg wrote:
Fri Feb 21, 2020 10:30 am
Tomsik wrote:
Fri Feb 21, 2020 7:02 am
I have just experience with Python and SPI. I don't know how to make Web Server and how to write the data to a database.
How can I start with that, please?
You might also look at Flask and sqlite.

How many megabyes, gigabytes, or terabytes of data are you talking about and how complex are the records?
I think I will store tens of MBytes per year.

User avatar
neilgl
Posts: 2033
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: IoT WebServer

Fri Feb 21, 2020 12:36 pm

For myself, I use MQTT, telegraf, influxdb, grafana and openhab2 all running on one pi. Sensors are temperatures, voltages, PIR movement detectors, and smart plugs & smart lights.

Return to “Beginners”