Monitor temperature, humidity, barometric pressure trends with a Raspberry Pi and SenseHat. Data is stored in a sqlite3 database. Default updates are every 5 minutes.
A webserver allows viewing data trends status, charts and statistics from a web browser on your local network.
Includes optional feature to upload data to the Weather Underground Personal Weather Station web site.
This project is a modified version originally from https://github.com/odlevakp/enviro-pi
IMPORTANT - It is suggested you do a Raspbian sudo apt-get update and sudo apt-get upgrade before curl install. You should have a recent RPI OS distro. Bullseye or later.
Step 1 With mouse left button press copy icon on right side of box below.
Step 2 On RPI putty SSH or terminal session right click, select paste then Enter to download and run script.
curl -L https://raw.github.com/pageauc/enviro-pi/master/setup.sh | bash
This will install and setup the ~/enviro-pi directory
From SSH or Terminal Session input the following command to test run enviro-pi.py.
cd ~/enviro-pi
./enviro-pi.py
Monitor log activity to ensure correct operation.
Note if sense hat display is enabled
- Red up arrow indicates temp rise since last reading.
- Blue down arrow temperature decreased since lasr reading.
- Red/blue stripes no change.
- pixel in top left indicates upload status. Green last upload successful. Red last upload failed.
./run.sh help
./run.sh install
./run.sh status
./run.sh start
./run.sh status
Example of Help screen below For more information on supervisor See Docs
./run.sh ver 2.0 written by Claude Pageau
Control enviro-pi.py enviro-web.py
Usage: ./run.sh [Option]
Options:
start Start supervisor service
stop Stop supervisor service
status Status of supervisor service
install Install symbolic links for supervisor service
uninstall Uninstall symbolic links for supervisor service
upgrade Upgrade files from Github Repo
help Display Usage message and Status
Example: ./run.sh status
./run.sh install command above will setup systemd supervisor symbolic links.
This will auto start enviro-web.py and enviro-pi.py on boot.
See run.sh help for other options. Eg start, stop, upgrade. Reboot to test autostart.
To Access enviro-pi web interface See ./run.sh help.
From a computer on your local network, Type or copy/paste url link into web browser url box.
Press top menu Status button to view current data. Press Refresh Page button to update data.
If no data displayed check sensehat hardware and setup.
After startup, allow 15-20 minutes to accumulate chart data (default updates are every 5 minutes).
Press Charts button to display historical data, Press green box pull down to select time range,
then
Press Load/Refresh Charts button to update graphs for selected range.
Graphs will update automatically after that but you can always refresh with the Load Charts button
enviro-pi.py has an optional feature to upload your data to the Weather Undergound Personal Weather Station. To setup your Raspberry Pi and Sense Hat to upload data
- Create/login to an account at https://www.wunderground.com/login?action=member-devices
- Add New Device and select Raspberry Pi from pulldown.
- Setup device name and location per web site instuctions.
- When device registration is complete you will receive a Station ID and a Station Key.
- login to your raspberry pi and cd to enviro-pi folder.
- nano config.py and edit weather station settings to add your STATION_ID AND STATION_KEY.
- Edit STATION_UPLOAD_ON = True
- Ctrl-x y to save changes and exit nano
To test
./run.sh stop
./enviro-pi.py
Review logs to ensure uploads are successful. If OK restart enviro-pi.py and weather.py
./run.sh start
- Raspberry Pi 2, 3, 4 suggest using Raspbian Buster or Stretch.
- RPI SenseHat board
- 40 pin GPIO Ribbon Cable (optional)
If you put your SenseHat on top of your Pi, the temperature readings will be inaccurate due to the heat coming from the pi - that's what the optional ribbon cable is for: To use your SenseHat with a ribbon cable, you can carefully remove the GPIO header on the bottom of the hat. It won't go easy the first time, just remember, you are removing the bottom one ;-)
User Variables are stored in the config.py file. Edit this file to change variables per comments
cd ~/enviro-pi
nano config.py
Press ctrl-x y to exit and save nano changes.
The writer process is storing environmental readings in a local SQLite database. You can use the CLI client to make additional queries on the recorded dataset.
cd ~/enviro-pi
sqlite3 enviro-pi.db
sqlite> .headers on
sqlite> .mode column
sqlite> SELECT * FROM sensehat;
sqlite> SELECT MAX(humidity),
datetime(epoch, 'unixepoch', 'localtime') as date
FROM sensehat;
ctrl-d to exit sqlite3 console.
Note Time is stored in the epoch
column as time since epoch.
Column temp_prs
stores temperature from pressure, not used in the web interface.
Copyright 2016 Pavol Odlevak
Using Chart.js
and Moment.js available under the MIT license.
The application was inspired by the following resources:
- Sense-hat API documentation
- w3schools - for HTML menus, templates and CSS.
- ChartJS - Awesome charts used to display environment readings.
- Flask - Web server used to display data, inspired by this blog example.
- Python sqlite tutorial
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.