SIMCOM SIM 7000 to get GPS coordinates

Hi! I have Arduino Mega and SIMCOM SIM 7000 gsm module connected to it. I got it connected using GSM library for arduino, but I don’t know how to start sending GPS coordinates to Cayenne. I think something has to be changed in this line of code - Cayenne.virtualWrite(). I would really appreciate your help. Thanks.

you will need a separate GPS module.
For GSM module connection with cayenne, you can use Cayenne-MQTT-Arduino/GSM.ino at master · myDevicesIoT/Cayenne-MQTT-Arduino · GitHub

Thanks for you answer! I’m using this module. It has GPS in it. SIM7000A - SIMCom | Cellular IoT Module . I used AT commands for the module and made it print a string in NMTEA format(1,1,20210210172207.000, 51.054653, -114.019004,-1060.100,0.00,175.2,1,0.9,1.2,0.8,11,8,45,) to the Arduino Serial Monitor. But now I don’t know how to write the 51.054653 and -114.019004 coordinates to Cayenne. My idea is to parse the string and write longitude and latitude values to the Arduino loop. But the problem is I’m new to both Arduino and C++, so I would appreciate your help. Thank you.

The above Sim700 is not supported with cayenne library. Check if you can get a library for sim700 and example for MQTT

Ok, thanks. I have one last question. What are the type value and unit value I should use in the virtualWrite() statement for GPS location(latitude and longitude values)? Because I couldn’t find anything in this topic.Data types for Cayenne MQTT API

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

where buffer is in format [lat, lon, alt]

Thank you so much! I found a library for SIM7000 and made the code that prints GPS coordinates and assign them to variables. But now I don’t know how to send them to Cayenne correctly and would really appreciate your help. Here’s part of the code related to that part. I just used random coordinates in this example, but still don’t know how to send them to the map widget.

char latBuff[12], longBuff[12], locBuff[50], altBuff[12];
void loop() {
float lat2 = -115.016020080;
float lon2 = 24.03466582;
float alt2 = 1051.8;
dtostrf(lat2, 1, 8, latBuff); // float_val, min_width, digits_after_decimal, char_buffer
dtostrf(lon2, 1, 8, longBuff);
dtostrf(alt2, 1, 1, altBuff);
// Construct a combined, comma-separated location array
sprintf(locBuff, “%s,%s,%s”, latBuff, longBuff, altBuff); // This could look like “10,33.123456,-85.123456,120.5”
delay(100);
// Construct a combined, comma-separated location array
Cayenne.virtualWrite(1,locBuff,“gps”, “m”);
}
CAYENNE_IN(1)
{
//CAYENNE_LOG(“Channel %u, value %s”, request.channel, getValue.asString());
}
CAYENNE_OUT(1)
{
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
Cayenne.virtualWrite(1,locBuff,“gps”, “m”);
}

Before sending the GPS data, does your device gets connected to the cayenne?

yes, it’s connected to cayenne via Cayenne.begin() function

can you share the serial monitor output by adding #define CAYENNE_DEBUG in the code.

I updated the code. So now I’m just trying to send coordinates manually to the map widget. But for some reason, map is showing up at all. Here’s the sample of the code.
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
//#include “High_Temp.h”
#define TINY_GSM_MODEM_SIM7000
#define CAYENNE_DEBUG

#include <CayenneMQTTGSM.h>
// This sketch uses a software serial connection.
#include <SoftwareSerial.h>
#define gsmSerial Serial1
char apn = ***; // Access point name. Leave empty if it is not needed.
char gprsLogin = “”; // GPRS username. Leave empty if it is not needed.
char gprsPassword = “”; // GPRS password. Leave empty if it is not needed.
char pin = “”; // SIM pin number. Leave empty if it is not needed.

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = ***;
char password = ***;
char clientID = ***;

char latBuff[12], longBuff[12], locBuff[50], altBuff[12];
float lat = -113.053020080;
float lon = 50.06766842;
float alt = 1051.8;

void setup() {
Serial.begin(9600);
Serial.println("Hello ");

// Auto-detect the GSM serial baud rate. You can manually set it instead if you want to save a bit of space.
TinyGsmAutoBaud(gsmSerial);
Cayenne.begin(username, password, clientID, gsmSerial, apn, gprsLogin, gprsPassword, pin);
}

void loop() {
Cayenne.loop();

dtostrf(lat, 1, 8, latBuff); // float_val, min_width, digits_after_decimal, char_buffer
dtostrf(lon, 1, 8, longBuff);
dtostrf(alt, 1, 1, altBuff);
// Construct a combined, comma-separated location array
sprintf(locBuff, “%s,%s,%s”, latBuff, longBuff, altBuff); // This could look like “10,33.123456,-85.123456,120.5”
delay(100);
// Construct a combined, comma-separated location array
Cayenne.virtualWrite(2,locBuff,“gps”, “m”);
}

greymap
As you can see the street name is right, but the map itself is greyed out and can’t be used.

can you try zooming out.

it doesn’t work

can you private message me your cayenne account email address, so that i can check what is the issue on the dashboard.

it needs to be in format

[ 33.123456,-85.123456,120.5 ] 
[lat, lon, alt ]

Thanks for your answer. But the values I entered are:
float lat = -113.053020080;
float lon = 50.06766842;
float alt = 1051.8;
and then it’s formatted like this:
dtostrf(lat, 1, 8, latBuff);
dtostrf(lon, 1, 8, longBuff);
dtostrf(alt, 1, 1, altBuff);
sprintf(locBuff, “%s,%s,%s”, latBuff, longBuff, altBuff);
So the end result looks like this: [-113.05302008,50.06766842,1051.8]. But as I told you, the map doesn’t show up

you are missing [ ]

  buffer1[0] = '[';
  size_t offset1 = 1;
  dtostrf(x1, 1, 3, &buffer1[offset1]);
  offset1 += strlen(&buffer1[offset1]);
  buffer1[offset1++] = ',';
  dtostrf(d1, 1, 3, &buffer1[offset1]);
  offset1 += strlen(&buffer1[offset1]);
  buffer1[offset1++] = ',';
  dtostrf(z1, 1, 0, &buffer1[offset1]);
  offset1 += strlen(&buffer1[offset1]);
  buffer1[offset1++] = ',';
  dtostrf(a1, 1, 0, &buffer1[offset1]);
  offset1 += strlen(&buffer1[offset1]);
  buffer1[offset1++] = ']';
  buffer1[offset1] = 0;
  Serial.println(buffer1);

I changed the formatting. And now it prints out the correct coordinates: [-113.05302008,50.06766842,1051.8]
But I still face the same problem. Map is just grey and zooming out or in doesn’t work

locBuff[0] = ‘[’;
size_t offset1 = 1;
dtostrf(lat2, 1, 8, latBuff, &locBuff[offset1]);
offset1 += strlen(&locBuff[offset1]);
locBuff[offset1++] = ‘,’;
dtostrf(lon2, 1, 8, &locBuff[offset1]);
offset1 += strlen(&locBuff[offset1]);
locBuff[offset1++] = ‘,’;
dtostrf(alt2, 1, 1, &locBuff[offset1]);
offset1 += strlen(&locBuff[offset1]);
locBuff[offset1++] = ‘]’;
locBuff[offset1] = 0;
Serial.println(locBuff);
delay(100);
// Construct a combined, comma-separated location array
Cayenne.virtualWrite(2,locBuff,“gps”, “m”);

image