Raspberry pi openweather display. This project uses the openweathermap API for weather information. The script requires the Longitude and Latitude coordinates for your location. It also requires a FREE API key from openweathermap for operation. The inside temperature is obtained with a DHT22 sensor connected to the Pi. The screen required is a 3.5” HDMI or a 5". The touch feature of the screen is not required but is helpful to shutdown the App.
Openweathermap API keyTo obtain a Free API key go to http://www.openweathermap.org and register.
InstallationDownload the full raspbian buster image and burn to a 8GB or bigger SD card. To start, you should know how to SSH to the Raspberry Pi and also use the remote connection VNC. After burning the image create an empty file called ssh in the boot folder of the SD card. Also create a file called wpa_supplicant.conf and include your WIFI credentials.
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid="WifiName"
psk="password"
key_mgmt=WPA-PSK
}
Power ON the Pi and try connecting to it with SSH. Use pi@raspberrypi.local for the IP address or find the IP in your network by using your android phone, and an App called FING. The password is raspberry.
After the Pi boots up, you need to turn ON the VNC server on the pi using SSH from your computer.
sudo raspi-config
Go to interfacing Options and enable VNC, then Exit.
Now connect to the Pi with VNC viewer from your computer and finish setting up your time zone and keyboard type. Use raspberrypi.local as the IP and raspberry as the password. Finish with the location and new password setup.
Enter the terminal screen and upgrade if needed.
sudo apt-get update
sudo apt-get upgrade
After the upgrade, you are ready for the installation.
You need to install the driver for the DHT22. Follow the Adafruit_Python_DHT for details.
cd
sudo pip install Adafruit_DHT
Now download the open_weather.py script.
cd
git clone https://github.com/granpino/raspi-openweather.git
cd raspi-openweather
Open the script from the terminal window and add your coordinates and API key.
SettingsOpen the raspi-openweather script and add your API key. Also add your coordinates for your location.
The Desktop ShortcutThe shortcut.sh file will create a shortcut on the Raspberry Desktop for easy operation. Run the shell script by typing;
sudo chmod -R 755 *.sh
sudo ./shortcut.sh
When using the touchscreen it is very difficult to open the app with 2 clicks. To change the desktop for a single click go to file manager, click on Edit and at the very bottom select preferences. Select 'open files with single click'.
Touchscreen DriversNow install the LCD drivers provided with your screen. Most of the problems related to LCD screens are related to the drivers.
If no drivers were included, you might try LCD-show
sudo git clone https://github.com/goodtft/LCD-show.git
cd LCD-show
sudo ./MPI3508-show
The resolution required by the script is 640x430, and the driver should make these changes. The file config.txt should indicate your resolution at the bottom of the file. Change it to 640x430
nano /boot/config.txt
Wiring the DHT22The DHT22 sensor is connected as follows. the (+) pin to 3.3V, the (-) pin to GND, and the signal pin to GPIO4 on the Raspberry pi. A 10K resistor might be needed between the data and (+ )depending on your model. Keep the sensor slightly away from the Raspberry pi to avoid reading the heat of the Pi. Also keep away from other electronics or sources of heat.
If the display uses all the pins needed for the sensor, solder the 3 wires to the back of the Pi.
Shuting down the AppIf your screen has touch, click on the upper right corner to shut it down. If you do not have a touch screen use a mouse with the Pi to shut it down. You can also use your computer with remote VNC.
TroubleshootingThe OpenWeather script is initially set at a resolution of 640x430 and it will fit in a 3.5” screen. If you get the error ‘No video mode large enough for 640x430’. It is because the Raspberry Pi screen is not big enough and must be changed. Set the Pi resolution to 640x480. To be able to troubleshoot the script, when changes are made, remove Fullscreen from the script. If you do not have an internet connection, the script will not run. The weather is updated every 4 minutes.
Comments