Feed on
Posts
Comments

ATmega GPS SMS Alerter

Previously I made a ATtiny GPS Long Lat logger to record the GPS co-ordinates to an EEPROM and now it’s time to implement the full functionality of my project which is to check an accelerometer for motion, monitor the GPS until we are in a certain area and then send an SMS. If it’s a few KM away from the area, then it’ll turn the GPS off for a few minutes and check again later but if it’s close to the area, it will keep checking the GPS as long as movement is detected within 1 minute.

I was using the ATtiny2313 before however it didn’t have any ADCs so I’ve switched to the ATmega88 which is approximately the same price. To reduce power I have a mosfet for the accelerometer, GPS and mobile phone. The mobile I’m using this time is the Nokia 3210 which cost me $22 from Ebay, the battery seemed to discharge after a couple of days so I was trying out different options.

The Nokia 3210 seems to power up from ~2.3V to 3.4V, so one option is to try a 3.7V Li-ion with a diode to drop it however after some experimentation it switches only stays on for a few seconds.

gsa-2

I thought it would be interesting to try out a super capacitor, the first one I purchased I didn’t notice the internal resistance which was quite high at 75 ohms so it didn’t work out as the phone didn’t switch on at all however these types of super capacitors are good for low current draw as a few days later the capacitor maintained it’s voltage.

gsa-1

The next capacitor was the film type, after charging it to 2.5V it seemed to power up the phone but only for 3 seconds, I tried to use the diode solution with the super capacitor (2 in series), but it still switched off after a few seconds. Sometimes the easiest solution is the best one, just a pair of AA batteries powers up the phone just fine but in the future I’m looking at grabbing a adjustable LDO regulator and seeing how well that will run from the 3.7V Li-poly.

gsa-3

Here’s how the schematic looks.

Now on to the code, firstly I was able to make a function without using atof to convert the GPS Long and Lat co-ordinates to a number. We read the number to the decimal point, break up the number before and after the decimal point and then combine them together.

Next is another function that I use to calculate the distance away between two GPS co-ordinates and assigns the shortest difference to the gpsLowestDistance global varaiable. After checking on Google maps it seems that 1KM is approximately 0.01 in longitude or latitude so we times by 100 to give us a round number for each KM (a result of 1 means there is a difference of 1KM)

Firstly when starting up, we check if the accelerometer detects any movement for 10 seconds on all axises and if so, turn on the GPS otherwise check again in 1 minute.

After switching the GPS on and grabbing the Long and Lat, if we find we’re in the SMS alert area, we set our re-check timer to 1 hour so that if movement is detected again we don’t send another duplicate SMS. We then disable the GPS, USART RX, set up the next baud rate for the Nokia and enable the TX, power up the phone and send our SMS message.

Now if we’re not in the SMS alert area, we calculate how far we are away from the alert’s Long/Lat markers and find the shortest distance. If we detect that we’re more than 5KM away, we can turn off the GPS for about 5 minutes to save power. If we are within 5KM, we continually check if there is movement within 60 seconds, if there is we check the GPS but if there isn’t we turn off the GPS for 1 minute.

Download ATmega_GPS_SMS_Alerter_v0.1

And that’s all there is to it, seems fairly simple once you have it all up and running.

Leave a Reply