Qibla direction Compass Project

Hey Guys,

I am planning on making a Project to show the qibla direction using hmc5883l compass.

i am totally a newbie.

i need help.

my idea is to collect data of cities around the world and the qibla directions (degrees) from their and create a menu to select ur city (using the display and rotatry button).

if the headingdegree matches the degree of that specific degree a buzzer or led turns on.

can some one help me please?

thanks

Hi,

The compass you chose has an "I2C" interface which makes it very easy to connect to your Arduino. If you get a display which also has an I2C interface, this will keep thinks neat and easy to wire.

mYJt46lkEqmVxB8JAIA-DJg.jpg

Also, a potentiometer ("pot") might be easier to use for a beginner than a rotary switch. Alternatively, a 5-way mini joystick/tactile switch could be used. Or this one. Either way, you will probably need to organise your city data into countries or regions to make them quicker to find.


A simple piezo buzzer should be fine for your project.

Paul

This raises the interesting question "what is the Qibla direction?" and as usual with interesting questions, there do not appear to be clear answers. From Wikipedia:

In recent years, Muslims from North America have used two rules to determine the direction of the Qiblah. According to spherical calculations, a Muslim praying from Anchorage, Alaska would pray almost due north if determining the Qiblah. However, when one looks at the world on most Mercator map projections, Mecca appears to be southeast of Anchorage. The shortest rhumb line (line of constant bearing) from most points in North America to Mecca will point toward the southeast, but the distance to Mecca along this route on the actual surface of the earth is longer than the great circle route.

{When in outer space}

Grand Ayatollah Ali al-Sistani has stated that one should face the direction of the Earth. This is part of the Malaysian document which recommends that the qibla should be 'based on what is possible' for the astronaut, and can be prioritized this way: 1) the Ka'aba, 2) the projection of Ka'aba, 3) the Earth, 4) wherever.

(bold typeface added). Now, I'm wondering if anyone has considered shortest-direct-path directions, i.e. through the Earth.

Paul - thank you very much for your kind response. I already have that screen and the button as well. I am concerned about the programming part.

Jremington - Thanks for the reply.

i think my 1st post wasnt clear - my apologies. Qibla is the direction where muslims face while praying which is in Makkah, Saudi Arabia.

if you can visit http://www.qiblaway.com/list/country/ you will find all the countries and their cities listed there. once you go to the city, you will find the degree to the Qibla direction.

i want to make a program where all this can be listed, either in a excel sheet or someother way so that arduino can access this list and get the degrees and then by IF condition i can ring the buzzer.

Is it possible?

Also, a small help on connecting the compass and obtaining the correct headingdegree will be appreciated.

i really appreciate your kind response.

thanks

Furthermore, i found the attached code on the internet but i do not know how it is calculating the qibla direction.

this code is for a project which can be seen on this video Arduino Qibla Compass - YouTube

Arah_Kiblat_Compass_I2C.ino (9.89 KB)

MesraSerial.h (9.12 KB)

MesraSerial.cpp (6.43 KB)

Also, a small help on connecting the compass and obtaining the correct headingdegree will be appreciated.

Perhaps you missed the point. There seems to be no agreement on how this bearing is to be calculated.

Do you plan to calculate the "great circle" direction or the direction suggested by the Mercator projection? If the great circle direction is to be calculated, you will find the relevant formula here.

The Arduino does not support double precision calculations, which are required for accurate navigation (if that matters here).

On the other hand, you could use an SD card to simply store the data given in the web site you linked, and have the Arduino look up the relevant direction.

you could use an SD card

Depending how many cities you want to include, and how large your sketch turns out, it may be possible to store the data in the Arduino's flash memory.

Here is a tutorial on the compass module.

Thank you for the response guys.

Sorry for being such a NOOB.

is it possible to point the degrees mentioned at the site that i mentioned early?

I mean can someone guide me on making a LCD Menu for the data of that site and then obtaining the degree from that data and then point towards that degree?

thanks for your attention.

First connect together the Arduino and the HMC588L compass, following the tutorial linked in reply #6.

Once you have that working and understand it thoroughly, come back and post further questions.

I have managed to connect the LCD display and the COMPASS with my Arduino.

the compass on arduino shows different degress / value compared to actual. Checked on my phone.

Pics attached,

Also, have attached the Sketch for your kind review.

lcd_and_compass.ino (4.92 KB)

Have you made sure that the compass is calibrated? Here is one procedure: http://hobbylogs.me.pn/?p=17
Do you have a reason to believe the compass in your phone?
Are you sure you understand which direction on the compass board points to Magnetic North?
What is your magnetic declination? It doesn't seem to be entered in your program.

Yes, I already tried calibrating using procedure: http://hobbylogs.me.pn/?p=17 still the values are not accurate.

Reason to believe the phone is that the mobile shows the correct direction to Qibla at my home. It should be at 101.6 degree from my home as per internet sites and the phone is showing the same direction and degree at my home. I assume that is correct.

I removed the declination from my program just to make sure if that was causing any inaccuracy in degrees.

Declination from my city is +3.73.

Yes, I already tried calibrating using procedure: http://hobbylogs.me.pn/?p=17 still the values are not accurate.

Well, that has to be fixed or nothing will work. It should be possible to obtain 1 degree accuracy from the compass.

Here is a more sophisticated procedure for calibrating the magnetometer. You must be sure that there are no magnetic materials or current-carrying wires near the sensor, either during calibration or during measurements.

jremington:
Sailboat Instruments: Improved magnetometer calibration (Part 1)

Well, this looks like a perfect procedure for a Dummy like me to calibrate the magnetometer.

let me give it a shot and revert.

Bro, i really appreciate your kindness.

thanks

You should be comparing magnetic north in your location, as indicated by a good quality magnetic needle compass, with the bearing of 0 degrees, as indicated by the HMC5883.
Like this compass:
If those agree, and the HMC5883 compass indicates 90, 180 and 270 degrees for due east, south and west (relative to magnetic north), it is properly calibrated.

Any electronic compass, like the one in your phone, can potentially have a calibration problem.