https://github.com/yxtay/sensehat-weather
Weather Station with Sense HAT on Raspberry Pi.
https://github.com/yxtay/sensehat-weather
raspberry-pi sense-hat weather-station
Last synced: 13 days ago
JSON representation
Weather Station with Sense HAT on Raspberry Pi.
- Host: GitHub
- URL: https://github.com/yxtay/sensehat-weather
- Owner: yxtay
- Created: 2017-03-21T14:04:46.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-02-12T20:14:17.000Z (3 months ago)
- Last Synced: 2025-05-08T01:11:36.647Z (13 days ago)
- Topics: raspberry-pi, sense-hat, weather-station
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Weather Station with Sense HAT on Raspberry Pi
Records temperature, humidity and pressure data periodically into Google Spreadsheet with a scheduled cron task.
Based on
[Mini Weather Station](https://www.hackster.io/idreams/make-a-mini-weather-station-with-a-raspberry-pi-447866)
on hackster.io and modified to run as a cron task.## Setup
```bash
# clone the repo
git clone https://github.com/yxtay/sensehat-weather.git && cd sensehat-weather# install dependencies
pip install -r requirements.txt --user
```## Download OAuth credentials file for Google API
Follow the `gspread` documentation instructions to obtain OAuth credentials from Google Developers Console.
http://gspread.readthedocs.io/en/latest/oauth2.html
Download the credentials json file and copy it into the project directory in your Raspberry Pi.
```bash
# assuming credentials file is in the current directory
scp credentials.json [email protected]:sensehat-weather/
```## Create Google Sheet
Create a Google Spreadsheet and name it as you desire.
Rename the default worksheet as you desire.
Open up the credentials json file in the previous step
and note the email address under the `client_email` field.
Share the spreadsheet with that email address.## Schedule cron task
Open crontab in the Raspberry Pi.
```bash
crontab -e
```Copy the following line into crontab.
This schedules the task to run every 5 mins.```bash
*/5 * * * * cd $HOME/sensehat-weather && python sensehat_weather.py
```## Usage
Use optional arguments if your configurations are different from defaults.
```
usage: sensehat_weather.py [-h] [--credentials-json CREDENTIALS_JSON]
[--spreadsheet SPREADSHEET] [--worksheet WORKSHEET]
[--log LOG]Take readings from SenseHat and add to Google Spreadsheet.
optional arguments:
-h, --help show this help message and exit
--credentials-json CREDENTIALS_JSON
path to Google OAuth credentials json file (default: credentials.json)
--spreadsheet SPREADSHEET
name of Google Spreadsheet to save SenseHat readings (default: sensehat-weather)
--worksheet WORKSHEET
name of worksheet to save SenseHat readings (default: data)
--log LOG path of log file (default: main.log)
```## Logs
By default logs are written to `main.log` in the project directory.