Sim808 gps & mqtt

Hello to all , currently i’m working on project where i need to send data every 3-5 sec , but also i need to get GPS data from sim808 , problem is when i connect to MQTT it open connection but when i try to get GPS data it broke connection for publishing MQTT data . Anyone had same problem or have a solution . I’m open for all !

You can acheive 5 second update rate using MQTT over TCP if you dont hang the code anywhere while processing AT command responses.
3 seconds is little difficult but still acheivable.
You might get better results with transparent mode, but it is much trickier compared to non transparent mode.
Yes, with SIM808 you have to read GPS data in between and that adds to the delay, but you should be able to achieve 5 second update rate without any problem.
The connection breaks if you send any packet with wrong MQTT format or if there is a long gap and server closes connection.
Are you using transparent mode or non transparent mode?

Hello Ravi , thank you for response . I use non transparent mode , oh yes it took me a lot of delay while sending at commands , do i need to send commands in this order :

  1. turn on module
  2. turn on gps
  3. wait for gps fix
  4. get gps data
  5. connect mqtt
  6. publish mqtt
  7. back to 3.

I have so much porblems with delays and publishing via mqtt .

Its the correct flow. Also add a state where you check if connection is still open.
If you get CLOSED URC you should go back to opening the TCP connection again.

Ravi, I have a similar issue where I have a MQTT Connection going on and I need to get the GPS location in parallel and send it over the MQTT connection.

Is there a way of without breaking the MQTT connection, we could get the GPS location and send it over this same connection to the server? Thanks

What module you use , can you give little more description ?

I am using SIM800 at present with MQTT protocol for connection with the server. I just wanted to send the location of the device to the server, however when I send AT+CIPGSMLOC=1,1 the connection breaks. Though my software takes care and reconnects however breaking every 15sec is becoming a problem

Could you share your code here , so we can see whats wrong

1 Like

Hi there, I have tried transparent transmission mode in SIM800L. I have successfully established TCP connection (AT+CIPSTART="…","…" => OK CONNECT). But I cannot send the data packet next. I received " CLOSED ". What’s the issue?