Open Tonisg91 opened 2 years ago
You are sending GNSS data every 7.5 seconds? That's rather a lot unless moving fast. Does it start working again after a power cycle reset? What exactly is the device you're using and how are you powering it?
You are sending GNSS data every 7.5 seconds? That's rather a lot unless moving fast. Does it start working again after a power cycle reset? What exactly is the device you're using and how are you powering it?
In the sample code it is 7.5 seconds in effect. At the moment they are just tests.
With an interval of 30s, the same thing happens but the failure comes later. I was planning to send the coordinates only if the change is greater than a certain range (not done yet).
If I restart the device it works correctly.
The device is a Lilygo TTGO SIM7000.
If it restarts then you may have power supply instability problems if you are not using the battery. But its also good practise, well essential tbh, to regularly check your gprs connection, it can drop out for many reasons. Use something like this in your loop, every few minutes or just before sending data:
if (!modem.isGprsConnected()) {
// run a reconnect function here.
}
There's a constant battle to keep these things connected to the cell particularly if you are moving around. If you can try to use MQTT rather than HTTP, you will reduce your data. The SIM7000 does work really good using this library and PUBSUB client.
For updating, here's some tips. Distance calculation worked for me, I was using only speed. But you need to allow for drift too so I use a speed/distance combination, if above a certain speed (2 kph works), add the distance.
This will calculate distance:
float geodistance(float lon1, float lat1, float lon2, float lat2)
{
double R = 6371; // km
double sLat1 = sin(radians(lat1));
double sLat2 = sin(radians(lat2));
double cLat1 = cos(radians(lat1));
double cLat2 = cos(radians(lat2));
double cLon = cos(radians(lon1) - radians(lon2));
double cosD = sLat1 * sLat2 + cLat1 * cLat2 * cLon;
double d = acos(cosD);
double dist = R * d;
float distf = (float)dist;
return distf;
}
Call it with this for distance in kilometers, you need current and previous GPS coordinate's.
float track_point_distance = geodistance(GPSlongitude, GPSlatitude, lastGPSlongitude, lastGPSlatitude);
You will be surprised how accurate this is, I use it to a meter resolution. Get GPS every second get the distance and keep adding until you ready to send.
Si se reinicia, es posible que tenga problemas de inestabilidad de la fuente de alimentación si no está usando la batería. Pero también es una buena práctica, bien esencial, por cierto, verificar regularmente su conexión gprs, puede fallar por muchas razones. Use algo como esto en su ciclo, cada pocos minutos o justo antes de enviar datos:
if (!modem.isGprsConnected()) { // run a reconnect function here. }
Hay una batalla constante para mantener estas cosas conectadas a la celda, especialmente si se está moviendo. Si puede intentar utilizar MQTT en lugar de HTTP, reducirá sus datos. El SIM7000 funciona muy bien con esta biblioteca y el cliente PUBSUB.
Para actualizar, aquí hay algunos consejos. El cálculo de la distancia funcionó para mí, estaba usando solo la velocidad. Pero también debe permitir la deriva, así que utilizo una combinación de velocidad / distancia, si está por encima de cierta velocidad (2 kph funciona), agregue la distancia.
Esto calculará la distancia:
float geodistance(float lon1, float lat1, float lon2, float lat2) { double R = 6371; // km double sLat1 = sin(radians(lat1)); double sLat2 = sin(radians(lat2)); double cLat1 = cos(radians(lat1)); double cLat2 = cos(radians(lat2)); double cLon = cos(radians(lon1) - radians(lon2)); double cosD = sLat1 * sLat2 + cLat1 * cLat2 * cLon; double d = acos(cosD); double dist = R * d; float distf = (float)dist; return distf; }
Llámelo con esto para la distancia en kilómetros, necesita coordenadas GPS actuales y anteriores.
float track_point_distance = geodistance(GPSlongitude, GPSlatitude, lastGPSlongitude, lastGPSlatitude);
Se sorprenderá de lo preciso que es, lo uso con una resolución de medidor. Obtenga GPS cada segundo, obtenga la distancia y siga agregando hasta que esté listo para enviar.
Hello! I finally went over to mqtt protocol and was able to get it to work stably. At the beginning there were connection problems in about 30% of the data sendings but it already works correctly. Thank you very much for your help, it has been very useful and I have learned things. Greetings and happy new year!
@Tonisg91 How did you solve it?
Hi all. I am doing some tests with an ESP32 Lilygo TTGO SIM7000 and I have warned that there is a problem with HTTP after some time sending data.
When you turn on the ESP32 it works correctly and after about an hour of sending data, the connection fails and it does not connect again.
This is the code. Any suggestion?
Successful http request AT dump commands.
Error AT Commands