At the end of this blog, you will be able to:
- print your custom message on 16 X 2 LCD
- print the current time, weather, and weather condition in LCD
To follow this tutorial you will need:
- Raspberry Pi (We are using Raspberry pi B+ model)
- 16 X 2 LCD Display
- Jumper Wires (Male to male and Female to male)
- GROUND (GND)
- VCC +5V (not to be confused with 3.3V)
- Contrast Adjustment (Vo, usually we use variable resistor)
- Register Select (RS)RS=0: Command, RS=1: Data
- Read/Write(RW)RW = 0: WriteRW=1: Read
- Bit (0) Not required in 4bit operation
- Bit (1) Not required in 4bit operation
- Bit (2) Not required in 4bit operation
- Bit (3) Not required in 4bit operation
- Bit 4
- Bit 5
- Bit 6
- Bit 7
- LED Backlight Anode (+)
- LED Backlight Cathode (-)
Here is how we wired up our LCD
Note:In order to control the contrast you can adjust the voltage presented to Pin 3. This must be between 0 and 5V. We used a resistor between pin 3 of LCD to GND of PI.
Your circuit should look something like this.
Displaying current date, time and weather info
In the above tutorial we saw how to display the custom message on 16 X 2 LCD using raspberry pi and python.Now we shall move on how to display the current weather info on LCD:
- First we will need to download the python weather api.Download the pywapi library using the following command on your pi.
This will download the tar file of the pywapi library
- Extract the tar file using
tar -zxvf pywapi-0.3.8.tar.gz
Now enter the directory using
1. cd pywapi-0.3.8
Now run the following command
python setup.py build
python setup.py install
In case if you get any error saying Insuffient Permission
sudo chmod -R 777 /usr/local/
Now you are done with installing the pywapi library
Now download the source code into your pi using
To run the code
Now you should be able to see the output as below
Now next step is to find the location code/id of your desired city.
Open the link, and enter your city. You should be able to get unique weather id of your city.
For example for Bangalore, the weather id is INXX0012, similarly for Kathmandu is NPXX0002.
Now open your source code and edit the line 8 with your city’s unique weather id.
#define the weather location id
weather_com_result = pywapi.get_weather_from_weather_com('NPXX0003')
Now you should be able to see the weather info of kathmandu as below