fungus332
Posts: 2
Joined: Fri Dec 10, 2021 11:24 pm

How to tweak existing web server for BME280 sensor so that it *saves* historical weather data?

Sat Feb 04, 2023 6:15 am

I followed this tutorial for making a web server for displaying weather data from my BME280 temp/humidity/pressure sensor board. It's great, but is there any way to modify the code to save weather data from previous days/months? You can adjust how many data points are saved and how often the sensor is accessed, but it's all only saved in the tab where the server is being accessed from, so it's lost if you close it.

I set up a Raspberry Pi weather station in the past where data was fed into Grafana which was perfect, it just sucks that you have to pay for what could easily be done locally as this tutorial partially accomplishes:

https://www.donskytech.com/raspberry-pi ... and-flask/

Any ideas or links would be appreciated. I don't have coding skills but I can work with existing code, thanks! :)

itsmedoofer
Posts: 608
Joined: Wed Sep 25, 2013 8:43 am
Location: Canterbury, Kent, UK

Re: How to tweak existing web server for BME280 sensor so that it *saves* historical weather data?

Sat Feb 04, 2023 7:39 am

Hi,

You maybe able to adapt/use this, I've using it on my envirohat for nearly a couple of years now.

https://github.com/nophead/EnviroPlusWeb

memjr
Posts: 2764
Joined: Fri Aug 21, 2020 5:59 pm

Re: How to tweak existing web server for BME280 sensor so that it *saves* historical weather data?

Sat Feb 04, 2023 10:46 am

Yes, there are many ways to accomplish that, including learning to do the easy task. But the better way to do it is not by having the site save the data, but to read the data from wherever your save it to, a database of some sort, influxdb being a good choice for it, and it is free.

Speaking of free, Grafana is open source, so free to you too if you host it yoursel.

You don't need the cloud managed version, but even that has a free account option.
Last edited by memjr on Sat Feb 04, 2023 6:44 pm, edited 1 time in total.

User avatar
DougieLawson
Posts: 42379
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: How to tweak existing web server for BME280 sensor so that it *saves* historical weather data?

Sat Feb 04, 2023 10:53 am

Add

Code: Select all

dtovelay=i2c-sensor,bme280
to /boot/config.txt and reboot.

That gets you /sys/bus/iio/devices/iio:device0/* with a bunch of files below that which have the values from your BME280.

It really is the easiest way to access a temp/humidity/pressure sensor.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

User avatar
neilgl
Posts: 5845
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: How to tweak existing web server for BME280 sensor so that it *saves* historical weather data?

Sat Feb 04, 2023 11:39 am

Maybe modify his bme_module.py to save the values it reads from the bme280 to a database (with a timestamp) e.g. mariadb

fungus332
Posts: 2
Joined: Fri Dec 10, 2021 11:24 pm

Re: How to tweak existing web server for BME280 sensor so that it *saves* historical weather data?

Wed Feb 15, 2023 9:45 pm

Thanks so much for the help everyone, it's really appreciated! Ended up solving it. :D

Return to “Python”