How to check the last id value of GPS Module in the database is increasing or not?

Can anyone help me?

In this task I use Arduino uno + GSM sim900 and GPS Module. I have a problem making notifications when the GPS module that is placed in the vehicle is damaged or removed. How to check that? I'm thinking to check the last id on the GPS module in the database is increasing or not? Is it true? How to make the notification in PHP?

If your device is sending a heartbeat to some system (saying “I’m alive and well” every X minutes) then the system receiving this heartbeat needs to notice the messages are no longer coming in and can trigger the alert

My case is the same as you described. But I'm confused how the coding logic?

Remember the last time you got a message from the device in a variable lastHeartBeatTime (updated at every new heartbeat)

Have a piece of code checking how much time has elapsed since you last heard from the device

if (currenTime - lastHeartBeatTime >= timeout) {
  // alert device missing

}

How you code this depends on your coding language on the receiving system.

If your arduino speaks directly to the database then you need a separate process checking for timing in the database. It can be a separate app or depending on your database capabilities (SQL stored procedures and events) something you can configure directly in the database

A typical implementation is to store the log of heartbeats with their time stamp information and associated data (like GPS position etc) and have a batch process running from time to time fetch the latest record for each device you track, extract the time stamp and compare it with the current time and decide if it has been too long or not.

what is variable "timeout" ?

Whatever duration you want to have to trigger your alert for example 5 minutes or 1 hour or 10 seconds depending how often you receive the heartbeat and how many heartbeats you are OK to be missing before triggering the alert

1 Like

thanks :blush:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.