Skip to content

Use RPI with Sensehat to monitor humidity, temperature, barometric pressure. View data and graphs on a web browser. Optionally Upload data to Weather Underground Personal Weather Station

License

Notifications You must be signed in to change notification settings

pageauc/enviro-pi

Repository files navigation

Enviro-Pi

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

Quick Install

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

To Run/Test

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.

Setup enviro-pi.py and enviro-web.py as background tasks

./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

Note

./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.

Web Interface

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.

On the Enviro-Pi Web Page

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

Setup Weather Underground Personal Weather Station

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

Hardware Requirements

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 ;-) SenseHat Ribbon Cable

Edit Configuraton

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.

Screenshots

Status MacOS screenshot Charts MacOS screenshot Statistics Android screenshot

How to Query sqlite database

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.

License and Authors

Copyright 2016 Pavol Odlevak

Using Chart.js
and Moment.js available under the MIT license.

The application was inspired by the following resources:

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.

About

Use RPI with Sensehat to monitor humidity, temperature, barometric pressure. View data and graphs on a web browser. Optionally Upload data to Weather Underground Personal Weather Station

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published