Trying to send GPS data to Blynk - Neo6MV2 on Arduino MKR1010

Hello,

I need help with my project.
Any help appreciated!



#include <TinyGPS++.h>
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <WiFiNINA.h>
#include <BlynkSimpleWiFiNINA.h>


char auth[] = "********";
// Set password to "" for open networks.
char ssid[] = "********";
char pass[] = "********";

WidgetMap myMap(V0);
BlynkTimer timer;
TinyGPSPlus gps;

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);

  // If you want to remove all points:
  //myMap.clear();

  int index = 1;
  float lat = 51.5074;
  float lon = 0.1278;
  myMap.location(index, lat, lon, "value");


  timer.setInterval(2000L, myTimerEvent4); //2sec timer
}

void myTimerEvent4() {
  
  Blynk.run();
// This sketch displays information every time a new sentence is correctly encoded.
   while (Serial1.available() > 0)
       if (gps.encode(Serial1.read())) 
           displayInfo();
       }

void displayInfo() {
   if (gps.location.isValid()) {
       lat = gps.location.lat();    //get latitude and longitude
       lon = gps.location.lng();
       Blynk.virtualWrite(V12, 1, lat, lon, "car");    //write to Blynk map
       //create location string which can be used directly in Google maps 
       slocation = String(lat) + "," + String(lon);
       spd = gps.speed.kmph();    //get speed
       Blynk.virtualWrite(V13, spd);
       bearing = TinyGPSPlus::cardinal(gps.course.value()); //direction
       Blynk.virtualWrite(V14, bearing);
       sats = gps.satellites.value();    //get number of satellites
       Blynk.virtualWrite(V15, sats);
       hdop = gps.hdop.value() / 10;    //get accuracy of location
       Blynk.virtualWrite(V16, hdop);
       msg5 = "GPS Good";
       Blynk.virtualWrite(V11, msg5);
   }
   else
   {
       msg5 = "Invalid Data";
       Blynk.virtualWrite(V11, msg5);
   }
}
       
void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}


ERROR MESSAGE:

Arduino: 1.8.14 Hourly Build 2020/09/14 03:35 (Mac OS X), Board: “Arduino MKR WiFi 1010”

sketch/GPS_BLYNK_Yannis.ino.cpp:2:63: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
#line 1 “/Users/yannis/Documents/Arduino/sketch_GPS_WORKING_???/GPS_BLYNK_Yannis/GPS_BLYNK_Yannis.ino”

/Users/yannis/Documents/Arduino/sketch_GPS_WORKING_???/GPS_BLYNK_Yannis/GPS_BLYNK_Yannis.ino:18:64: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
void setup()

/Users/yannis/Documents/Arduino/sketch_GPS_WORKING_???/GPS_BLYNK_Yannis/GPS_BLYNK_Yannis.ino:19:64: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
{

/Users/yannis/Documents/Arduino/sketch_GPS_WORKING_???/GPS_BLYNK_Yannis/GPS_BLYNK_Yannis.ino:38:64: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]

/Users/yannis/Documents/Arduino/sketch_GPS_WORKING_???/GPS_BLYNK_Yannis/GPS_BLYNK_Yannis.ino:47:64: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
if (gps.location.isValid()) {

/Users/yannis/Documents/Arduino/sketch_GPS_WORKING_???/GPS_BLYNK_Yannis/GPS_BLYNK_Yannis.ino:72:64: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
{

/Users/yannis/Documents/Arduino/sketch_GPS_WORKING_???/GPS_BLYNK_Yannis/GPS_BLYNK_Yannis.ino: In function ‘void displayInfo()’:
GPS_BLYNK_Yannis:48:8: error: ‘lat’ was not declared in this scope
lat = gps.location.lat(); //get latitude and longitude
^~~
/Users/yannis/Documents/Arduino/sketch_GPS_WORKING_???/GPS_BLYNK_Yannis/GPS_BLYNK_Yannis.ino:48:8: note: suggested alternative: ‘Uart’
lat = gps.location.lat(); //get latitude and longitude
^~~
Uart
GPS_BLYNK_Yannis:49:8: error: ‘lon’ was not declared in this scope
lon = gps.location.lng();
^~~
/Users/yannis/Documents/Arduino/sketch_GPS_WORKING_???/GPS_BLYNK_Yannis/GPS_BLYNK_Yannis.ino:49:8: note: suggested alternative: ‘log’
lon = gps.location.lng();
^~~
log
GPS_BLYNK_Yannis:52:8: error: ‘slocation’ was not declared in this scope
slocation = String(lat) + “,” + String(lon);
^~~~~~~~~
GPS_BLYNK_Yannis:53:8: error: ‘spd’ was not declared in this scope
spd = gps.speed.kmph(); //get speed
^~~
GPS_BLYNK_Yannis:55:8: error: ‘bearing’ was not declared in this scope
bearing = TinyGPSPlus::cardinal(gps.course.value()); //direction
^~~~~~~
/Users/yannis/Documents/Arduino/sketch_GPS_WORKING_???/GPS_BLYNK_Yannis/GPS_BLYNK_Yannis.ino:55:8: note: suggested alternative: ‘String’
bearing = TinyGPSPlus::cardinal(gps.course.value()); //direction
^~~~~~~
String
GPS_BLYNK_Yannis:57:8: error: ‘sats’ was not declared in this scope
sats = gps.satellites.value(); //get number of satellites
^~~~
/Users/yannis/Documents/Arduino/sketch_GPS_WORKING_???/GPS_BLYNK_Yannis/GPS_BLYNK_Yannis.ino:57:8: note: suggested alternative: ‘pass’
sats = gps.satellites.value(); //get number of satellites
^~~~
pass
GPS_BLYNK_Yannis:59:8: error: ‘hdop’ was not declared in this scope
hdop = gps.hdop.value() / 10; //get accuracy of location
^~~~
/Users/yannis/Documents/Arduino/sketch_GPS_WORKING_???/GPS_BLYNK_Yannis/GPS_BLYNK_Yannis.ino:59:8: note: suggested alternative: ‘loop’
hdop = gps.hdop.value() / 10; //get accuracy of location
^~~~
loop
GPS_BLYNK_Yannis:61:8: error: ‘msg5’ was not declared in this scope
msg5 = “GPS Good”;
^~~~
GPS_BLYNK_Yannis:66:8: error: ‘msg5’ was not declared in this scope
msg5 = “Invalid Data”;
^~~~
exit status 1
‘lat’ was not declared in this scope

This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.

The errors are about variable declarations (or lack of them).

Take the last one…

You do declare the variable lat as a float, but you do this in your void setup. This makes it local to void setup, and therefore invisible/inaccessible in other functions - hence the message that it wasn’t available within the scope of the void displayInfo function.

Many of your other variables simply aren’t declared at all.

If you want variables to be globally accessible then declare them outside of a function, preferably at the top of your code, where your SSID/pass/auth deflations are.

This is basic C++ stuff, not Blynk related in any way.

Pete.

Thank you Pete,

I will try to ask more Blynk related questions next time.

All the best,

Yannis