Arduino MKRGSM 1400 Giving thrown off coordinates when publishing to an MQTT

I am currently trying to track my location through an Arduino MKRGSM 1400 board and publish this information to an MQTT. The issue is whenever I add in to publish this data (or anything, even just ‘Hello World’), it seems to throw my coordinates halfway across the city. I have run the example code for GsmLocation and from running that I can rule out any issues with the board, as it gives me a correct location. It is only when I implement the MQTT that it will put me really far away. I have also tried switching the library to PubSubClient and using different MQTT brokers - both give the same results. Is there a solution to this?

#include <MKRGSM.h>
#include <MQTT.h>
#include <avr/dtostrf.h>
const char pin[] = "";
const char apn[] = ""; 
const char login[] = "";
const char password[] = ""; 
GSMLocation location;
GSMClient net;
GPRS gprs;G
SM gsmAccess;
MQTTClient client;
char pubCharsPayload[100]; 
void connect() {  
// connection state 
bool connected = false;
Serial.print("connecting to cellular network ...");
while (!connected) {
if ((gsmAccess.begin(pin) == GSM_READY) && 
(gprs.attachGPRS(apn, login, password) == GPRS_READY)) {
connected = true;
Serial.println("Connected to cellular network!");
} else {
Serial.print("Connecting to MQTT...");
while (!client.connect("","","")) {
Serial.println("Connected to MQTT!");
void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);
void setup() {
client.begin("", net);
void loop() {
if (!client.connected()) {
if (location.available()){
//Construct the string for the latitude
char bufferLat[20];
//Uses dtostrf library to convert 
String latVal = dtostrf(location.latitude(), 10, 7, bufferLat);
//Construct the string for the longitude
char bufferLon[20];
String lonVal = dtostrf(location.longitude(), 10, 7, bufferLon);
char bufferAcc[20];
String accVal = dtostrf(location.accuracy(), 10, 7, bufferAcc);
//Construct the payload as a JSON object
String payload = "{\"Latitude\":" + latVal + ",\"Longitude\":" + lonVal + ",\"Accuracy\":" + accVal + "}"; payload.toCharArray(pubCharsPayload, (payload.length() + 1));
client.publish("/location", pubCharsPayload); } }

What does the payload look like if you Serial.print it?

It throws me the coordinates in a JSON format like so:

What I'm really asking is how those coordinates compare to your actual lat lon. I'm wondering whether what you're actually sending is correct.

I suspect that somewhere along the way, you're losing precision in the numbers. Something may be dropping significant places. A good start to debugging would be to see if they're right when you send them.