A fun little project to show the weather on a LCD character display with a Raspberry Pi.
- Raspbian (2013-02-09-wheezy-raspbian)
- Python 2.7.3
- RPi.GPIO (ships with Raspbian)
Raspberry Pi P1 Header | LCD |
---|---|
(3.3 V) 1 | 2 (VDD) |
(GND) 6 | 1 (VSS) |
(GPIO 4) 7 | 4 (RS) |
(GPIO 17) 11 | 5 (R/W) |
(GPIO 22) 15 | 6 (E) |
(GPIO 23) 16 | 11 (DB4) |
(GPIO 24) 18 | 12 (DB5) |
(GPIO 25) 22 | 13 (DB6) |
(GPIO 27) 13 | 14 (DB7) |
LCD pin 3 (V0) has a 1.5K ohm resistor connected to ground for the LCD's contrast.
This python script scrapes the GC weather forecast page for Toronto, ON for the temperature and weather conditions to display the information on a LCD display (and update once every 5 minutes). Other cities in Canada work as well, but for a different weather website, the regex will have to be changed. The code comments may be lacking because this was a personal project.
16 H19
Now: Cloudy. Later: Showers.
The first line means "currently 16, high of 19 today". The second line will be scrolling because it is longer than the LCD.
The following setup starts piweather.py on boot and allows you to SSH in to terminate it (and shutdown), which means you only need to provide power and networking to the Raspberry Pi.
-
Clone piweather.py into the home directory (e.g., /home/pi/).
-
Make the script executable:
chmod 755 /home/pi/piweather.py
-
Create a symbolic link to the script in /etc/init.d/:
sudo ln -s /home/pi/piweather.py /etc/init.d/piweather
-
Register script to be run on boot:
sudo update-rc.d piweather defaults 98
-
Register SSH to be run on boot:
sudo update-rc.d ssh defaults
To end the script safely in SSH:
sudo pkill -SIGTERM piweather
####To set up Wi-Fi to connect on boot:
sudo apt-get update
sudo apt-get install wicd-curses
sudo wicd-curses
Press 'P' for preferences
Set Wireless Interface: wlan0
Press F10 to save
Press 'R' to refresh
Navigate to your network
Press right arrow to configure
Select 'Automatically connect to this network'
Set Key: <wireless password>
Press F10 to save
Press 'C' to connect
Edit /etc/network/interfaces to include: auto wlan0