In the previous post, I showed how to make a Raspberry Pi powered Prayer times display using PiTFT. In this post I will show how to make a Raspberry Pi powered Prayer times display using a TV or a monitor as not everyone has PiTFT display.
This project is based on article by Jamie Jackson “Raspberry Pi PiTFT Weather Station” and “Turn your Raspberry Pi into an Azaan/Prayer clock”. You can refer to those for more information. I am just an integrator who puts works of other people together according to my requirement.
Disclaimer: Since the Islamic date and prayer times are based upon calculations, it is very well possible that it may differ from the actual date based on moon sighting. Also, the prayer time can vary from the actual prayer time of the location.
- Raspberry Pi with Raspbian image
- TV or monitor
- Working Internet connection (for Internet Weather)
We will begin by creating a folder in the Raspberry Pi Home directory.
We will go to this directory and download all necessary files.
Prior to that we must install the necessary packages. The first package is the pywapi. This package allows us to fetch weather information from sites like Yahoo weather, weather.com, etc and in an easily parse able form such that we can extract daily weather, weekly weather, temperature, pressure, humidity, etc.
we will extract and install this package.
tar -xzvf pywapi-0.3.8.tar.gz
python setup.py build
sudo python setup.py install
Now we need to install the module which converts Gregorian to Islamic date. The installer for the converter module “umalqurra” requires pip, so we will have to install it first.
sudo apt-get install python-pip
Now install the converter module
sudo pip install umalqurra
There are several files required for the display to work.
- praytimes.py : This is the file which will calculate the prayer times for us depending upon the location we live in.
- prayerwalltv.py : This is the python code which combines the prayer times code, the weather code and Islamic date code.
- Weather Logos: Every weather condition has an icon code at weather.com. According to these codes, the display will show an image of the weather condition.
There are several settings we need to do as weather and prayer times are location specific. Also, people at different locations follow different prayer time calculation method.
The only file that will need to be edited is prayerwalltv.py
sudo nano prayerwalltv.py
In here we have to set the Latitude and Longitude of our location. You should be able to get this if you open http://www.wikimapia.org and take your location at the cross-hair and the Latitude and Longitude will be seen at the lower left corner.
lat = 9.327531
long = 8.086139
You need to get your location code from weather.com so that you can get customized weather for your location. Go to weather.com which should show your location. Click on the location and you should see your code in the webpage URL. It should be 2 characters of country code followed by XX and another 4 numbers.
weatherDotComLocationCode = ‘KUXX1087’
We need to set the Prayer times calculation method. To know more about the calculation methods, go to http://praytimes.org/calculation
My location calculation method is Makkah so I have set it as
PT = PrayTimes(‘Makkah’)
The other options are MWL, ISNA, Egypt, Karachi, Tehran and Jafari.
You can set the display to update at defined intervals. At these intervals, the Pi will fetch weather data and refresh the screen.
updateRate = 600 will give you update interval of 10 minutes
If you would like to alter the position of any text in the display, you can use the following parameters
The Origin (0,0) for the display is top left, so give the X Y coordinates accordingly.
Do CTRL-X to save the file with a yes
You can check weather it is displaying properly by executing
sudo python prayerwalltv.py
Once you confirm that it is displaying properly, you can start the script at boot time
Edit the rc.local file and add the below line before exit 0
sudo nano /etc/rc.local
sudo python /home/pi/prayerwall/prayerwalltv.py &
After this, your TV will display the Prayer Times on boot.