Prayer Times Display using Raspberry Pi

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.

Prayer display monitor

Prerequisites

  1. Raspberry Pi with Raspbian image
  2. TV or monitor
  3. Working Internet connection (for Internet Weather)

Procedure

We will begin by creating a folder in the Raspberry Pi Home directory.

mkdir prayerwall

cd prayerwall

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.

wget https://launchpad.net/python-weather-api/trunk/0.3.8/+download/pywapi-0.3.8.tar.gz

we will extract and install this package.

tar -xzvf pywapi-0.3.8.tar.gz
cd pywapi-0.3.8/
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

Files

There are several files required for the display to work.

  1. praytimes.py : This is the file which will calculate the prayer times for us depending upon the location we live in.
  2. prayerwalltv.py : This is the python code which combines the prayer times code, the weather code and Islamic date code.
  3. 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.

Settings

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

textAnchorX =
textAnchorY =
textYoffset =

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.

Advertisements

4 thoughts on “Prayer Times Display using Raspberry Pi

  1. Salam aleyka,

    thank you for this tuto
    Unfortunatly the files are not available anymore, could you update all of them, unless prayerwalltv.py
    barakallahoufik

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s