Help With Car Tracking System (From Instructables)

Hello,

I have been trying to build the Athena Car Tracking System from the Instructables Website (http://www.instructables.com/id/Athena-The-Global-Car-Tracking-System/?ALLSTEPS). I bought all of the same parts that were listed on the websites and followed the instructions to wire it up. I even used the same pins on the Arduino. The only difference is that I just have it hooked up to the computer and some 9-Volt batteries, instead of to the cars power. So, of course I don't have the voltage regulator part of the circuit.

It doesn't seem to want to work, though. I tried just directly copying and pasting the code directly from the website and in to Arduino, but it didn't want to work. So, I tried troubleshooting myself, and going through the comments on the web page to find the problem with no luck. I even used the code somebody posted in the comments that was an improved version of the original code.

Finally, I compared the codes side-by-side and tried to integrate them together in hopes that it would work like that. Every time I text the password to the Arduino, though, nothing happens, and nothing ever seems to output in the Serial Monitor, either. I have tested the GPS module by itself, and I know that is working, so that can't be the problem. I guess the only problem I have noticed is that the netlight seems to be blinking at 64ms ON and 3000ms OFF, then at 64ms ON and 800ms OFF after I upload the code. I'm not sure what would be the cause of this problem.

So, I was wondering if there is anything I can do to find the problem with the code, because reading through it I don't see any problems with it, and it verifies fine and everything. It seems to make sense to me with my intermediate knowledge, but it never sends a text back to my phone with the GPS location.

This was the code I ended up with:

#include <SoftwareSerial.h>
#include <string.h>
#include <TinyGPS.h>

SoftwareSerial Sim900Serial(2, 3);

byte buffer[64]; // buffer array for data recieve over serial port
int count=0; // counter for buffer array

SoftwareSerial GPS(4, 5);

TinyGPS gps;
unsigned long fix_age;
long lat, lon;
float LAT, LON;

void gpsdump(TinyGPS &gps);
bool feedgps();
void getGPS();

void SIM900power() // software equivalent of pressing the GSM shield "power" button
{
  digitalWrite(9, HIGH);
  delay(1000);
  
  Sim900_Inti();
}

void setup()
{
  Sim900Serial.begin(19200); // the SIM900 baud rate
  SIM900power();
  
  GPS.begin(9600); // GPS module baud rate
  Serial.begin(9600); // the Serial port of Arduino baud rate.
  
  delay(500);
}

void loop()
{
  Sim900Serial.listen();
  
  if (Sim900Serial.available()) // If data is comming from from GSM shield)
  {

    while(Sim900Serial.available()) // reading data into char array
    {
      buffer[count++]=Sim900Serial.read(); // writing data into array
      
      if(count == 64)
        break;
    }
  
    Serial.write(buffer,count); // if no data transmission ends, write buffer to hardware serial port
    
    Cmd_Read_Act();
    //SendTextMessage();
    clearBufferArray(); // call clearBufferArray function to clear the storaged data from the array
    
    count=0; // set counter of while loop to zero
  }

  if (Serial.available()) // if data is available on hardwareserial port ==> data is comming from PC or notebook
  Sim900Serial.write(Serial.read()); // write it to the GPRS shield
}

void clearBufferArray() // function to clear buffer array
{
  for (int i=0; i<count; i++)
  {
    buffer[i]=NULL;
  } // clear all index of array with command NULL
}

void Sim900_Inti(void)
{
  Sim900Serial.println("AT+CMGF=1"); // Set GSM shield to sms mode
  Serial.println("AT CMGF=1"); 
  delay(500);
  Sim900Serial.println("AT+CNMI=2,2");
  Serial.println("AT CMGF=1");
  delay(500);
}

void Cmd_Read_Act(void)                       //Function reads the SMS sent to SIM900 shield.
{ 
  char buffer2[64];
  
  for (int i=0; i<count;i )
  { 
    buffer2[i]=char(buffer[i]);
  }  
    
  if (strstr(buffer2,"FIND"))    //Comparing password entered with password stored in program  
  {
      Serial.println("Password Authenticated.");
      Serial.println("Sending reply SMS.");
      SendTextMessage();            
  } 
}

void SendTextMessage()
{
  Sim900Serial.print("AT+CMGF=1\r"); //Sending the SMS in text mode
  delay(100);
  Sim900Serial.println("AT + CMGS = \"6058700235\""); //The predefined phone number
  delay(100);
  Sim900Serial.println("Please wait while Module calculates position"); //the content of the message
  delay(100);
  Sim900Serial.println((char)26);//the ASCII code of the ctrl z is 26
  delay(100); 
  Sim900Serial.println();
  delay(5000);

  int counter=0;
  
  GPS.listen();

  for (;;)
  {
    long lat, lon;
    unsigned long fix_age, time, date, speed, course;
    unsigned long chars;
    unsigned short sentences, failed_checksum;
    long Latitude, Longitude;

    // retrieves /- lat/long in 100000ths of a degree
    gps.get_position(&lat, &lon, &fix_age);
    getGPS();

    Serial.print("Latitude : ");
    Serial.print(LAT/1000000,7);
    Serial.print(" :: Longitude : ");
    Serial.println(LON/1000000,7);
    
    if (LAT == 0 && LON == 0)
    {
      continue;    
    } 
    
    counter;
    
    if (counter<30)
    {
      continue;    
    }

    Sim900Serial.print("AT+CMGF=1\r"); //Sending the SMS in text mode
    delay(100);
    Sim900Serial.println("AT + CMGS = \"6058700235\""); //The predefined phone number
    delay(100);

    Sim900Serial.print("maps.google.com/maps?q=");
    Sim900Serial.print(LAT/1000000,7);
    Sim900Serial.print("+");
    Sim900Serial.println(LON/1000000,7);//the content of the message
    delay(100);
    
    Sim900Serial.println((char)26);//the ASCII code of the ctrl z is 26
    delay(100);
    Sim900Serial.println();
    delay(5000);

    counter=0;
    break;
  }
}

void getGPS()
{
  bool newdata = false;
  unsigned long start = millis();
  
  while (millis() - start < 1000)
  {
    
    if (feedgps ())
    {
      newdata = true;
    }

  }

  if (newdata)
  {
    gpsdump(gps);
  }
}

bool feedgps()
{
  while (GPS.available())
  {
    
    if (gps.encode(GPS.read()))
      return true;

  }
  
  return 0;
}

void gpsdump(TinyGPS &gps)
{
  gps.get_position(&lat, &lon);

  LAT = lat;
  LON = lon;

  {  
    feedgps();
  }
}

And finally some pictures of our set-up...

  if (Sim900Serial.available()) // If data is comming from from GSM shield)
  {

    while(Sim900Serial.available()) // reading data into char array

What's the point of an "if" followed by a "while" with the same condition?
How much data is this going to collect before writing it out and resetting the buffer?

(Why aren't you asking over at the Instructables site?)

Hi, I'm glad you didn't build the 5Volt regulator the way that instructibles did, with the parallel LM7805.
DON"T...This is not the way to get extra current handling from a linear regulator, in fact if your power supply is powerful enough and there is no fuse on the regulator input, it could get explosive.
(Tried it one day as an exercise.Bang, bits everywhere, quite impressive, then measured output voltage, it was at unregulated input level.)
In fact I'd be very careful of any of that project.
[soapbox] I worry when a project is more about 3D pictures, than the project itself, and no circuit diagram, and that regulator circuit. It shows how little research has gone into its construction.[/soapbox]

Tom....... :slight_smile:

What's the point of an "if" followed by a "while" with the same condition?
How much data is this going to collect before writing it out and resetting the buffer?

(Why aren't you asking over at the Instructables site?)

Would you honestly expect me to get any help on a post that is over 6 months old without the knowledge-bank that is available to us on this website? No way, haha. This website is in my opinion my only hope of getting help. Especially because that guy's voltage regulator circuit is sketchy at best.

And I think it is supposed to fill a buffer of array size 64. So, after it fills 64 it should reset it.