-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
type: imperfectionPerceived defect in any part of projectPerceived defect in any part of project
Description
Hardware used
MKR GSM 1400 with MKR GPS attached as a shield.
Issue description
When using the MKR GPS example sketch, GPS data immediately appears in the serial monitor.
However, when using the following code to send GPS data to Arduino IoT hub, the GPS data never comes.
A connection to IoT cloud is made successfully but the function GPS.available() always returns 0.
Code
#include <Arduino_MKRGPS.h>
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
#define THING_ID ""
#define BOARD_ID ""
const char GPRS_APN[] = "";
const char PINNUMBER[] = "";
const char GPRS_LOGIN[] = "";
const char GPRS_PASSWORD[] = "";
float lat;
float lon;
GSMConnectionHandler ArduinoIoTPreferredConnection(PINNUMBER,GPRS_APN,GPRS_LOGIN, GPRS_PASSWORD);
void setup() {
Serial.begin(9600);
while(!Serial);
if(!GPS.begin(GPS_MODE_SHIELD)){
Serial.println("Failed to initialize GPS!");
while(1);
}else Serial.println("GPS Initilized OK!");
initProperties();
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(4);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
delay(10000);
if (GPS.available()){
lat = GPS.latitude();
lon = GPS.longitude();
Serial.println("Latitude: " + String(lat));
Serial.println("Longitude: " + String(lon));
}
}
void initProperties(){
ArduinoCloud.setThingId(THING_ID);
ArduinoCloud.addProperty(lat, READ, ON_CHANGE);
ArduinoCloud.addProperty(lon, READ, ON_CHANGE);
}frbuceta
Metadata
Metadata
Assignees
Labels
type: imperfectionPerceived defect in any part of projectPerceived defect in any part of project