Code Monkey home page Code Monkey logo

sensehat-weather's Introduction

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 on hackster.io and modified to run as a cron task.

Setup

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

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

crontab -e

Copy the following line into crontab. This schedules the task to run every 5 mins.

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

sensehat-weather's People

Contributors

yxtay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sensehat-weather's Issues

No module names oauth2client.service_account

Was originally following a guide on Hackster.io but gave problems, saw this code was newer so hoped it was updated with Googles oauth approach but still getting an error. Any ideas?

pi@raspberrypi:~/Documents/sensehat-weather $ sudo python sensehat_weather.pyTraceback (most recent call last):
  File "sensehat_weather.py", line 8, in <module>
    from oauth2client.service_account import ServiceAccountCredentials
ImportError: No module named oauth2client.service_account
pi@raspberrypi:~/Documents/sensehat-weather $

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.