Showing GPS coordinates on map using sim808 module

#1

Hi, I am using sim808 module to get GPS coordinates. I want to show these coordinates on map using asset tracking api of cayenne. But I don’t know how to start. I am using texas instrument microcontroller. Please guide me how can I achieve this task.

#2

which programming language are you preferring to work with?

#3

Thanks for the response. I am using embedded C.

#4

you have to use this publish code https://github.com/myDevicesIoT/Cayenne-MQTT-C/blob/master/src/Platform/Linux/examples/SimplePublish.c and make changes accordingly that it sends GPS data in [lat, lon, alt] format.

#5

Sorry for asking a silly question. How is the communication is being done at low level? As i have no ehternet connection or wifi connected. I only have SIM808 module.

#6

we have a GSM support library for GSM808 https://github.com/myDevicesIoT/Cayenne-MQTT-Arduino/blob/master/examples/Connections/GSM/GSM.ino you can use it if you want.

#8

Hi, how can I add map on the dashboard when connected to Cayenne Cloud. I am using SimplePublish.c example project for testing. Kindly guide me how can i add map on the dashboard?

#9

you need to send data GPS data to cayenne using:

CayenneMQTTPublishData(&mqttClient, NULL, DATA_TOPIC, 2, TYPE_ GPS, UNIT_ GPS, GPS_data);

where GPS_data should be in [lat, lon, alt] format.

#10

is this right?
CayenneMQTTPublishData(&mqttClient, NULL, DATA_TOPIC, 3, TYPE_GPS, UNIT_UNDEFINED, “33.69,72.00,12”)

Now it is showing a map but it does not shows the marker

#11

it should be in this format:

CayenneMQTTPublishData(&mqttClient, NULL, DATA_TOPIC, 3, TYPE_GPS, UNIT_GPS, [33.69,72.00,12]);

including [ ]

#12

Do I need to refresh the map every time I send a new coordinate?

#13

no, you dont have to if you are sending correct data.

#14

CayenneMQTTPublishData does not accepts data in this format. It gives error because the last parameter is expecting a character array.

#15

this is the code i used with my arduino to create a map and it shows data properly on the map.

float x = 0.5;
float y = 0.4;
float z = 0.2;
  char buffer1[50];
  buffer[0] = '[';
  size_t offset = 1;
  dtostrf(x, 1, 3, &buffer[offset]);
  offset += strlen(&buffer[offset]);
  buffer[offset++] = ',';
  dtostrf(y, 1, 3, &buffer[offset]);
  offset += strlen(&buffer[offset]);
  buffer[offset++] = ',';
  dtostrf(z, 1, 3, &buffer[offset]);
  offset += strlen(&buffer[offset]);
  buffer[offset++] = ']';
  buffer[offset] = 0;
Serial.println(buffer);

Cayenne.virtualWrite(20, buffer, "gps", "m");
#16

I am sending using the following code. It shows the coordinate only first time then it does not updates map. However in data tab I can see the live data coming. But map is not updated
#define TYPE_GPS “gps”
#define UNIT_GPS “m”
if (count == 0) {

			if ((error = CayenneMQTTPublishData(&mqttClient, NULL, DATA_TOPIC, 3, TYPE_GPS, UNIT_GPS, "[33.674119,72.996591,13]")) == CAYENNE_SUCCESS) {
				printf("Data send1\r\n");
			}
			count = 1;
		}
		else {
			if ((error = CayenneMQTTPublishData(&mqttClient, NULL, DATA_TOPIC, 3, TYPE_GPS, UNIT_GPS, "[33.695057,72.9755828,15]")) == CAYENNE_SUCCESS) {
				printf("Data send2\r\n");
			}
			count = 0;
		}

As you can see from the image I am receiving updated coordinates every 5 seconds.

#17

i am getting the points as they move. but on refresh they wont be kept.


you are not sending the correct data format.

#18

I have solved the problem. I have one more question that does this maps supports auto zoom in or zoom out? Like if the coordinates are out of the display shown on the screen will it take us to that point or not?

#19

if you check on the map widget there + - for zoom in and zoom out. the map auto direct and shows the latest location point it has received.