Hello,
i'm trying to build a car tracking system with an arduino and a SIM808 module: the system has two states
state 0 = arduino and sim808 in low power consumption mode
state 1 = normal operations (get GPS location, send SMS)
the system switches between the two states after receiving a call (from state 0 to 1 using an interrupt pin, from state 1 to 0 from known numbers).
When the system is not moving it works as expected, but when i use it on my car and it moves, if it is in state 0, for some reason it wakes up by itself without any call.
Why does it happen?
I thought this two things:
- perhaps SIM808 wakes when it is shaken, but i don't think it has a gyroscope/accelerometer
- perhaps sim808 continues to get GPS data also in low power consumption mode and after calling detachGPS function and this can wake the module
This is my code for state0 and Going_to_sleep function
if (state == 0){
Serial.println(state);
//delay(5000);
//Serial.println("ciao");
la = 0.00;
lo = 0.00;
delay(500);
sim808.detachGPS();
delay(1000);
Going_To_Sleep();
}
void Going_To_Sleep(){
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Sets the sleep mode
cli();
sleep_enable(); // set sleep bit
attachInterrupt(0, wakeUp, LOW); // attach interrupt to wake CPU after sleep.
digitalWrite(LED_BUILTIN, LOW); // turn off LED to show sleep mode
sei();
delay(500);
mySerial.print("AT+CSCLK=2\r");
sleep_cpu(); // put to sleep - will wake up here.
sleep_disable();
detachInterrupt(0); //Removes the interrupt from pin 2;
Serial.println("woke up"); // first line of code executed after sleep.
mySerial.print("AT+CSCLK=0\r");
delay(1500);
sim808.hangup();
delay(1000);
state = 1;
sim808.attachGPS();
digitalWrite(LED_BUILTIN, HIGH);//turning LED on
}
void wakeUp(){
//Serial.println("Interrrupt stop");//Print message to serial monitor
delay(500);
//Serial.println("Interrrupt Fired");//Print message to serial monitor
//detachInterrupt(digitalPinToInterrupt(2)); //Removes the interrupt from pin 2;
// sleep_disable();//Disable sleep mode
//detachInterrupt(0); //Removes the interrupt from pin 2;
}
Thanks for your advices!