Car Digital Compass & Thermometer
Intro: Car Digital Compass & Thermometer
I'm not really good at finding places and direction but at least I'm able to read maps and compass. These days, GPS navigation systems are getting more popular, so probably some people would say why I need a compass. Well, first off, I like gadgets and if I can make one, that will be much better to enjoy it. So, I decided to make a digital compass for my car.
I started with very basic function, showing bearing and heading angle from a digital magnetometer on an LCD, but there are a number of digital and analog pins are left unused on the microcontroller (Arduino compatible, JeonLab mini) so I added a digital temperature sensor and a phototransistor to adjust the brightness of the backlight (single LED) of the LCD.
I still have more than a few pins available and have a plan to add more sensors such as an exterior thermometer, anti-theft device, etc. (any suggestion would be appreciated!)
The picture shown in this Intro page is the fully assembled and mounted on top of the interior mirror of my car showing the bearing, angle and current interior temperature. Unfortunately I didn't take a lot of pictures when I assembled the electronic parts, but I'm sure someone who are interested in making one of these will be able to follow easily the schematic diagram I will show in a couple of steps later.
I started with very basic function, showing bearing and heading angle from a digital magnetometer on an LCD, but there are a number of digital and analog pins are left unused on the microcontroller (Arduino compatible, JeonLab mini) so I added a digital temperature sensor and a phototransistor to adjust the brightness of the backlight (single LED) of the LCD.
I still have more than a few pins available and have a plan to add more sensors such as an exterior thermometer, anti-theft device, etc. (any suggestion would be appreciated!)
The picture shown in this Intro page is the fully assembled and mounted on top of the interior mirror of my car showing the bearing, angle and current interior temperature. Unfortunately I didn't take a lot of pictures when I assembled the electronic parts, but I'm sure someone who are interested in making one of these will be able to follow easily the schematic diagram I will show in a couple of steps later.
STEP 1: Part List
- LCD: 16x2 HD44780 LCD (white text on blue background): This is pretty popular LCD that you can find and buy easily.
- JeonLab mini v1.3: This is a minimalist Arduino board I made. There are a number of small Arduino compatible boards in the market so pick anything small that can be hidden behind the LCD.
- Digital compass: MAG3110 (bought an assembled one from ebay): I have tried other digital compass a couple years ago but couldn't make it work. But this one is relatively easy to program. I will explain this in detail later.
- Temperature sensor: TMP36: take a look at the datasheet from the Digikey link. It's easy to use.
- Phototransistor: LTR-4206E: I'm sure any other IR phototransitor will do the same.
- 7805 regulator: You know what this is. Car battery's charging and regulated voltage is 13.8-14.4V while we need 5V for the controller and the LCD.
- resistors and capacitors (see schematic diagram)
- Car battery jack
- prototyping board
- push button switch (normal open, N.O.) for calibration of the magnetometer
- solid copper wire (1mm in diameter) for bracket frame
- cable ties
STEP 2: Schematic Diagram
The JeonLab mini v1.3 part has the minimal Arduino. In order to upload your sketch, you need an FTDI USB interface which you don't need all the time but only when you upload sketches or serial communication is required.
The LCD connection is well explained with a library in Arduino tutorial page. I just changed the pins for my convenience. Note that you need to change these pins accordingly in the sketch. One important thing here is the backlight LED Anode pin is not hooked up to the V but to the digital pin 5 which provides PWM with which you can control the brightness of the backlight of the LCD.
The temperature sensor, TMP36 has 3 legs, V , signal, and GND. I connected the signal leg to one of those analog input pins of the JeonLab mini. Refer to the Arduino sketch (program) in the next step for how to calculate the temperature from it.
The phototransistor has two legs, positive and negative. You can omit the resistor between the negative and GND which I did as long as you get the values correctly when it's dark (I tested in dawn) and bright (you don't have to measure this cause it's already maximum of the V ). The brightness measured by this phototransistor is used to adjust the brightness of the backlight LED of the LCD as explained above.
The LCD connection is well explained with a library in Arduino tutorial page. I just changed the pins for my convenience. Note that you need to change these pins accordingly in the sketch. One important thing here is the backlight LED Anode pin is not hooked up to the V but to the digital pin 5 which provides PWM with which you can control the brightness of the backlight of the LCD.
The temperature sensor, TMP36 has 3 legs, V , signal, and GND. I connected the signal leg to one of those analog input pins of the JeonLab mini. Refer to the Arduino sketch (program) in the next step for how to calculate the temperature from it.
The phototransistor has two legs, positive and negative. You can omit the resistor between the negative and GND which I did as long as you get the values correctly when it's dark (I tested in dawn) and bright (you don't have to measure this cause it's already maximum of the V ). The brightness measured by this phototransistor is used to adjust the brightness of the backlight LED of the LCD as explained above.
STEP 3: Preliminary Tests and Heading Calculation
First of all, the LCD, JeonLab mini and the magnetometer, MAG3110 have been assembled on a breadboard and tested. The magnetometer has 3 axis sensor, but because, fortunately, the most roads where I live and commute to work are relatively level. So I didn't bother to use complicated equations, but decided to calculate simply the heading angle using ATAN from X and Y readings. And it really works just good enough.
The magnetic field strength and direction is differ from location to location. In order for accurate compass and map reading, you need to know the magnetic declination (difference between the compass north and the geographic true north). In my sketch, I didn't subtract or add the declination, but if your location has very large declination, you may want to add this to compensate the difference.
By the preliminary tests, I found the value shows the maximum and minimum values of X and Y axis represented north and south. But the values did not evenly distributed in angle. In other words, the central value didn't represent east nor west. This is common, as far as I know, for all the semiconductor type magnetometer as long as they don't have any built-in compensation algorithm in it. In order to read heading (roughly) correctly I figured that if you know the values for north and south per each axis, X and Y, simply calculating ATAN of differences of current reading and averages of X and Y will give you heading angle (see Arduino sketch in the next step), and it worked fine. This is not perfect method to calculate the heading but we are not talking about decimal number precision. I have driven my car with this compass for about a week now and the results are quite satisfactory.
The magnetic field strength and direction is differ from location to location. In order for accurate compass and map reading, you need to know the magnetic declination (difference between the compass north and the geographic true north). In my sketch, I didn't subtract or add the declination, but if your location has very large declination, you may want to add this to compensate the difference.
By the preliminary tests, I found the value shows the maximum and minimum values of X and Y axis represented north and south. But the values did not evenly distributed in angle. In other words, the central value didn't represent east nor west. This is common, as far as I know, for all the semiconductor type magnetometer as long as they don't have any built-in compensation algorithm in it. In order to read heading (roughly) correctly I figured that if you know the values for north and south per each axis, X and Y, simply calculating ATAN of differences of current reading and averages of X and Y will give you heading angle (see Arduino sketch in the next step), and it worked fine. This is not perfect method to calculate the heading but we are not talking about decimal number precision. I have driven my car with this compass for about a week now and the results are quite satisfactory.
STEP 4: Arduino Sketch (updated)
I have added comments in the attached sketch as specific as I can. But if you have any question, please add a comment below.
UPDATED (April 24, 2013):
1. I couldn't upload Arduino sketch directly (weird, I had uploaded before...), so uploaded a compressed file.
2. I added the temperature in Fahrenheit as well.
3. In order to test the brightness values, added the analogRead(1) value and the mapped PWM value in the 2nd row.
UPDATED (April 24, 2013):
1. I couldn't upload Arduino sketch directly (weird, I had uploaded before...), so uploaded a compressed file.
2. I added the temperature in Fahrenheit as well.
3. In order to test the brightness values, added the analogRead(1) value and the mapped PWM value in the 2nd row.
STEP 5: Assembling Electronic Parts
STEP 6: Wire Frame Bracket
STEP 7: Mounting and Done
Done and done!
22 Comments
khaidirzakaria 6 years ago
Very useful! Thank you !
linkage134 9 years ago
2 questions, how much of a hassle is this to program and what would be needed to display a clock?
JeonLab 9 years ago
I haven't used it before, but there is a real time clock module. Check this site (
http://playground.arduino.cc/Main/DS1302) for more information.
dmwatkins 9 years ago
Really cheap real-time clock from dipmicro.com (and other cheap parts)
http://www.dipmicro.com/store/DS1307BAT-MOD
It's intended for use with a rechargeable battery, but easy to modify for a normal battery.
If anyone needs help with using an Arduino and a real-time clock I'm willing to share some stuff... just reply!
vaycon 9 years ago
pro work , now you need to make cover around your device and its will be perfect , also hide the sensor some where else .
good job
SonnyA1 9 years ago
Silly Question - I would make this for my dad but all I would need is a larger screen for the compass - could you suggest one and I can just take away from YOUR design to make it work?
JeonLab 9 years ago
I have used only two LCDs for my projects: the one in this Instructable (16x2) and Nokia 5110. I don't know how big LCD your are looking for, but I just quickly googled and found one at Sparkfun store:
https://www.sparkfun.com/products/710. Take a look at it and see if it is big enough. You also need to modify the Arduino sketch to display numbers and letters for the LCD you choose.
Good luck and have fun!
ThatMexicanKidd 9 years ago
How much money does this cost to make?
JeonLab 9 years ago
Well, I used many of the parts that I already had before, so I cannot say exactly how much it took, but my rough guess is around $30 if you have to buy everything.
efoo 9 years ago
JeonLab 9 years ago
That's why I put the sensor on the wind shield close to the interior mirror where the magnetic field interference is minimal. It works fine.
efoo 9 years ago
cool, thanks
dmwatkins 10 years ago
JeonLab 10 years ago
Oh, that's interesting stuff to add. Thanks for the information. I wish I had more time to make things. :-)
BowMan831 10 years ago
This is pretty impressive. Have you played around with any raspi stuff? Seems like you could have even more fun.
JeonLab 10 years ago
I'm thinking to get one of those soon.
umursengul 10 years ago
JeonLab 10 years ago
Thank you.
kebmoore 11 years ago
JeonLab 11 years ago