Giter Site home page Giter Site logo

piweather's Introduction

piweather

Raspberry Pi & SSD1306 OLED project

This project uses a Raspberry Pi B, a Wireless USB dongle and an SSD1306 OLED display to display the current weather and train times for selected locations. Optionally, add a rotary encoder and add your own menus!

Hardware

  • Raspberry Pi
  • Compatible USB WiFi dongle
  • SD Card (at least 8GB)
  • Power supply
  • SSD1306 OLED Display
  • Jumper wires (7-10)
  • (optional) Rotary encoder, soldering iron, wire, solder-sucker
  • (temporarily) Screen + HDMI cable + keyboard (setup directly) OR ethernet cable + router + computer (setup via SSH)

Software

Initial setup:

Prepare your Pi if possible by using a fresh installation of the latest Raspbian. Burn this to your SD card and connect to your Pi using one of the following methods:

A. Connect up your ethernet cable between your Pi and router and log in to your Pi using SSH (Putty on Windows). If you can connect using avahi/Bonjour, the address you need is raspberrypi.local, otherwise find the Pi's IP address by logging in to your router.
NOTE: You will first need to place a blank file ssh on the /boot/ partition in order to enable SSH!
This is a new security measure in builds released since November 2016.

B. Connect keyboard and monitor to your Pi.

The default login username is pi and the password is raspberry. You can change this in the next step or by using the passwd command.

Run sudo raspi-config to set up your Pi. Go through options 1-4 in turn, and it is considered safe to overclock a little (I used the Medium setting, but whatever works for you). In the Advanced options (7), enable SSH, SLI and I2C. Reboot and then update the pi: sudo apt-get update && sudo apt-get upgrade

Connect to WiFi:

Plug in your WiFi dongle and check it is recognised using lsusb. Then check the interface appears with ifconfig. You should have a wlan0 or similar but with no IP address. A good way to add a WiFi network is by using the interface wpa_cli. This allows a number of commands to interact with your dongle. Search for WiFi networks using the commands scan followed by (give it a few seconds) scan_results. Add a new network: add_network and note the number returned (the first time this will be 0, if not, change in the following commands). Use the commands set_network 0 ssid "YOUR_SSID" and set_network 0 psk "YOUR_PASSWORD". Then, enable_network 0. You should hopefully see "Associated with...", meaning you have connected. Finally, save_config and quit. You can tinker with the config later if necessary with sudo nano /etc/wpa_supplicant/wpa_supplicant.conf. Finally, check the configuration survives a reboot by sudo reboot, unplug the ethernet cable (or disconnect monitor & keyboard), and try to ssh over WiFi to raspberrypi.local.

Prerequisites:

  • Pip: wget https://bootstrap.pypa.io/get-pip.py, then sudo python get-pip.py
  • Git: sudo apt-get install git
  • This very handy Darwin SOAP client provided by Robert Clark: sudo pip install nre-darwin-py
  • This library by Adafruit which enables drawing text and shapes on the SSD1306 OLED: git clone Adafruit_Python_SSD1306, cd Adafruit_Python_SSD1306/, sudo python ez_setup.py install
  • wiringPi2-Python (follow the instructions in the link to install wiringPi)
  • sudo apt-get install python-dev
  • sudo apt-get install python-PIL
  • sudo pip install spidev
  • PiWeather:

    Then clone this repository to your pi:
    git clone https://github.com/mattura/piweather

    Place any True Type font you want in the /fonts/ directory and edit the code, I used Minecraftia and Everyday (both free for personal use) from here:
    http://www.dafont.com/minecraftia.font
    http://www.dafont.com/everyday.font

    Check your screen runs correctly:
    python scrtest.py

    To access the Met Office Datafeed, you need to register for an api key. Once you have this, copy the key value into the "met.conf" file.

    To access the National Rail OpenLDBWS data feed, you need to register for a token. Once you have this, place it into the "nre.conf" file.

    Check your apikey and token work:
    Run python cron.py and check for errors, then run ls *.dat and check the dat files have been created

    Set up your crontab to run cron.py at regular intervals. I run it every minute between the hours of 5am and 11pm:
    sudo crontab -e
    * 5-23 * * * /usr/bin/python /home/pi/piweather/cron.py

    Now you should be set! Try python display.py
    If it works, you can run it on boot by adding a script in /etc/rc.local

    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.