Skip to content
a weather display for a raspberry pi and a adafruit featherwing TFT ili9341 display written in python
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
fonts
icons
logs
.gitignore
LICENSE
PiButtons.py
PiButtons_Service.sh
README.md
WeatherPi_TFT.py
WeatherPi_TFT_Service.sh
example.config.json

README.md

WeatherPi_TFT

Hardware

a weather display for a raspberry pi and a adafruit (featherwing) TFT ili9341 display

first of all, i'm a beginner in python... so don't be to hard to me... i'm still learning

written with love in python3

WeatherPi_TFT

all available weather icons in 2 sizes

Weather Icons

icons for moonphases

Moon Icons

Hardware and wiring

i wrote this app on a mac with PyCharm and tested it quite a while. since it uses only standard python3 modules and libraries it should work on nearly everything that can run python3 and pygame.

PyCharm IDE by intelliJ jetbrains

this tutorial is basically for running it on a raspberry pi (zero, 1, 2, 3) and a TFT display which matches up with chips like the ones from adafruit. as long as it uses standard spi it should work with the new dtoverlaymodule in the latest jessie versions of raspbian... i think there is no need for a custom kernel. it's just a little bit configuration.

i tested it with following TFT's:

no configuration needed for:

  • official raspberry pi 7" display
  • any HDMI display
  • skip all the TFT setup parts

wiring

wiring

  • this should explain how to wire up your display
SDO (MISO) TFT Data Out SPI_MISO    = GPIO09
SDI (MOSI) TFT Data In  SPI_MOSI    = GPIO10
SCK TFT Clock           SPI_CLK     = GPIO11

CS TFT Chip Select      SPI_CE0_N   = GPIO08
D/C TFT Data / Command              = GPIO24

RESET Reset                         = GPIO23
 
GND Ground                          = GND
VCC 3V3 supply                      = +3V3 or 5V
  • optional if you like to use the included PiButtons script
BUTTON 1    used for restart app    = GPIO19
BUTTON 2    used for shutdown pi    = GPIO26
  • give you the option to put some function on a hardware button (like restart the WeatherPiTFT service, shutdown/reboot your Pi, change display brightness, etc.)
  • feel free to add your own functions in PiButtons.py

Setup your Pi

install jessie to a sd card and update

  • get the latest NOOBS installer
https://www.raspberrypi.org/downloads/noobs/

i used NOOBS v2.1.0 which was the latest version for now

setup the SD card

TODO: write a tutorial for setting up the SD card

the first boot

TODO: write a tutorial for first boot

enable SPI

TODO: write a tutorial for setting up SPI

connect to your WiFi

TODO: write a tutorial for connecting to WiFi via terminal

update all tools

  • when your connected to your wifi open up a terminal and type:
sudo apt-get update -y && sudo apt-get upgrade -y

install and configure WeatherPi_TFT

git clone https://github.com/LoveBootCaptain/WeatherPi_TFT.git
cd WeatherPi_TFT
rm -rf docs/

install the dependencies

TODO: write a requirements.txt

get an api key from darksky / forecast.io

add API key and other options to the config file

  • create a new config-file
cd
cd WeatherPi_TFT
cp example.config.json config.json
  • edit the config.json file
nano config.json
  • replace xxxxxxxxxxxxxxxxxxxxxxxxx in "FORECAST_IO_KEY": "xxxxxxxxxxxxxxxxxxxxxxxxx" with your own API key
  • replace en in "FORECAST_LANGUAGE": "en" with your preferred language
  • replace si in "FORECAST_UNITS": "si" with your preferred unit format
  • replace 40.705565 and -74.1180865 in "FORECAST_LAT": 40.705565 and "FORECAST_LON": -74.1180865 with the coordinates of your preferred forecast-location (this example-location data is from new york city)
  • replace flags in "FORECAST_EXCLUDES": "flags" with whatever you want to exclude in the API-respond
  • for language-support, units, lat , lon and excludes please refer to -> DarkSky API Docs

set up the TFT

  • in /boot/config.txt, add in the following at the bottom
# TFT display and touch panel
dtoverlay=rpi-display
dtparam=rotate=0
  • change /boot/cmdline.txt to add the following to the end of the existing line
fbcon=map:10 fbcon=font:VGA8x8 logo.nologo

setup the services

cd
cd WeatherPi_TFT
sudo cp WeatherPi_TFT_Service.sh /etc/init.d/WeatherPiTFT
sudo cp PiButtons_Service.sh /etc/init.d/PiButtons
sudo chmod +x /etc/init.d/WeatherPiTFT
sudo chmod +x /etc/init.d/PiButtons
sudo chmod +x Weatherpi_TFT.py
sudo chmod +x PiButtons.py

run python with root privileges

  • this is useful if you like to run your python scripts on boot and with sudo support in python
sudo chown -v root:root /usr/bin/python3
sudo chmod -v u+s /usr/bin/python3

setting up python3 as default interpreter

  • this should start your wanted python version just by typing python in the terminal
  • helps if you have projects in python2 and python3 and don't want to hassle with the python version in your service scripts
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives --install /usr/bin/python python /usr/bin/python3.4 2

you can always swap back to python2 with:

update-alternatives --config python

and choose your preferred version of python

  • check if python3.x is now default with:
python --version
  • it should say something like:
Python 3.4.x

update all python modules

  • open up a python console
python
  • than run this line by line
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
    call("pip install --upgrade " + dist.project_name, shell=True)
  • if everything is set up and updated correctly:
sudo reboot

test the services

  • for the WeatherPiTFT Service
sudo service WeatherPiTFT start
sudo service WeatherPiTFT stop
sudo service WeatherPiTFT restart
sudo service WeatherPiTFT status
  • for the PiButtons Service
sudo service PiButtons start
sudo service PiButtons stop
sudo service PiButtons restart
sudo service PiButtons status
  • if this is doing what it should you can run the service every time you boot your pi
sudo update-rc.d WeatherPiTFT defaults
sudo update-rc.d PiButtons defaults

Troubleshooting

  • if you have any issues with setting up your locale please read the issue #1
  • if some special characters of your language is not supported (e.g. like chinese characters) please read the issue #1

WeatherPi_TFT in Chinese

  • a good way to setup for chinese was given from @yifanshu02 here

WeatherPi_TFT in Chinese

credits

screenshots

darcula styled theme with another font

Darcula styled Theme for WeatherPi_TFT

WeatherPi_TFT

You can’t perform that action at this time.