Okay i did it but it still doesnt show the location on map widget.
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/d6e2bdcf-ebab-4c09-9272-39f0d83d3f97
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
CloudLocation boardGPS;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#include "TinyGPS++.h"
TinyGPSPlus gps;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
Serial1.begin(9600);
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
// Your code here
while(Serial1.available())
{
if(gps.encode(Serial1.read()))
{
String msg = Serial1.readStringUntil('\r');
Serial.println(msg);
Serial.print("LAT="); Serial.println(gps.location.lat(), 6);
Serial.print("LONG="); Serial.println(gps.location.lng(), 6);
Serial.print("ALT="); Serial.println(gps.altitude.meters(), 6);
delay(4*1000);
}
}
double Lat;
double Long;
boardGPS = Location(gps.location.lat(), gps.location.lng());
}
Please don't use delay() function in IoT Cloud sketches because it can interfere with the internal state machine of ArduinoCloud . More information here.