BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk+Sim900 shield + NEO 6M + Arduino UNO

Well honestly then, I think you will need to start at the basics and get the Ublox GPS working first, http://www.instructables.com/id/Arduino-Ublox-GPS/ Then add in the GSM shield… and only then start looking toward Blynk to make it easier to control/monitor, etc.

Now, if you want to use your phone’s GPS to get a map and pass location data to hardware, and do it in style, then Blynk is a good solution, however Blynk is probably not the magic bullet that will seamlessly link all of your differing hardware together without having a solid functional foundation first.

1 Like

In these code i already insert working code fo GPS(also sent lat and lon by sms ), it was working good and sending lat and lon to serial.
But blynk is sending zeros and 7 to map widget, maybe someone know what format blynk uses or there are another problem?

Disable the DEBUG.

Try adjusting your Map Widget command to this:

Blynk.virtualWrite(V1, pointIndex, lat, lon, "value");

To see if it places a point in the correct location.

And perhaps also send the same data to a couple of Labeled Value Widgets (set to /pin/ ) to confirm what data you are receiving on the app side (assign them proper Vpin numbers, not the x & y in my example).

Blynk.virtualWrite(Vx, lat);
Blynk.virtualWrite(Vy, lon);

Also… what is with the 7 at the end?? is that required by your GPS library?? Try removing it and just having the following:

long lat = (gps.location.lat());
long lon = (gps.location.lng());  // <--- also, is this supposed to be lng and not lon?

Thanx for your help!

7 means number of signs after (.)
In debug phone sends to arduino lot and lat in format xx.xxxxxxx
Also i think the reason in library.
I found WidgetMap.h

#ifndef WidgetMap_h
#define WidgetMap_h

#include <Blynk/BlynkWidgetBase.h>

class WidgetMap
    : public BlynkWidgetBase
{
public:
    WidgetMap(uint8_t vPin) : BlynkWidgetBase(vPin) {}

    void clear() {
        Blynk.virtualWrite(mPin, "clr");
    }

    template<typename T1, typename T2, typename T3, typename T4>
    void location(const T1& index, const T2& lat, const T3& lon, const T4& value) **_------Here all values are const, maybe change to float lat and lon?_**
 {
        Blynk.virtualWrite(mPin, index, lat, lon, value);
    }

};

#endif

It seems problem could be that Blynk Map Widget example has const lat and lon

/ Debug console
  Serial.begin(9600);

  Blynk.begin(auth);

  // 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");
}

Sounds like your GPS library outputs in Decimal Degrees. Do the Labeled Value Displays at least show the proper data format?

As for the WidgetMap.h… Try changing to Float and see what happens. That is beyond me to easily test as I do not have any external GPS source.

I’ll try these evenin, will tell result later.

I changed to float, no result.
Also changed braud rate for modem to 19200, to prevent conflicts between gps rate 9600 and gsm rate, no result.
Also added to setup

simple timer, timer(5000L, Map)
void Map()
{
int index = 1;
myMap.location(index,gps.location.lng() ,gps.location.lat() , "value");
}

and

void loop()
{
    
  Blynk.run();
   timer.run();
 }

Still result 0.0000, also in debug and in serial.print.

@Dmitriy Can u help please to solve these case, or maybe someone of your colleagues?

OK, now I am confused, earlier you stated serial was working…

But you said it was placing the location incorrectly… (this would more likely be a GPS library or code issue, not Blynk)

Then you stated that you had everything working fine with some other code?

And now you are saying that it outputs all zeros…[quote=“mvd, post:13, topic:12467”]
Still result 0.0000, also in debug and in serial.print.
[/quote]

Perhaps there might be an issue getting the data to the map, and Debug might be adding to the issue due to additional delay, but I don’t see how Blynk itself can possibly mess up your GPS, hardware or library (and it’s output).

I still think you need to re-start with very simple steps…

  1. Using just the Uno and GPS, get the GPS showing correct data on IDE serial monitor. Don’t use Debug, just use basic serial prints.

  2. Show that same data on the App in a simple method… In case the GSM shield is conflicting, use the USB-Link to connect to Blynk Cloud from the UNO (At which point first disable ALL serial prints) and just send data via Blynk.virtualWrite().

  1. Once confirmed that the Labeled Value widgets are showing the correct numbers and format. Then add the Map Widget and confirm if it is working properly or not.

  2. Finally, add in the GSM shield.

Otherwise it appears that you are just complicating the hardware, mixing it in too quickly, possibly running into pin conflicts? and apparently confusing Blynk as the culprit.

First i used sketch for gps. It works fine.
Then i took Map sketch and replaced numbers from example with gps data in format of working TinyGPS++ example.
I will try virtual write first in evning, maybe it is really problem with timing.

@vshymanskyy could help.

@vshymanskyy can you help please?

  long lat = (gps.location.lat(), 7);
  long lon = (gps.location.lng(), 7); 

This would lead lat and lon equal to exactly 7. (this is , operator)
please print lat and lon to serial, then send same to Blynk.
use double instead of long

I tried double , no effect.

Also i tried just send data to virtyal pin, using double , also no use.

I have some ideas where could problems be.

First
Blynk library for Map Widget

    template<typename T1, typename T2, typename T3, typename T4>
    void location(const T1& index, const T2& lat, const T3& lon, const T4& value) {
        Blynk.virtualWrite(mPin, index, lat, lon, value);
    }

May be some conflicts appear between format from library and scetch? (i am not sure , just as variant)

Second

Tiny GPS ++ library

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

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}

In these example , which works well with my NEO 6M , is a part of code

while (ss.available() > 0)
    if (gps.encode(ss.read()))

It is used to avoid data sending conflicts as i understand.
Where can i put in my code for Map Widget?
Is it necessary?

As i see code

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#define TINY_GSM_MODEM_SIM900
// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30

//is that needed?

#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>
#include <TinyGPS++.h>

static const int RXPin = 5, TXPin = 4;
static const uint32_t GPSBaud = 9600;(for NEO 6M)



char auth[] = "YourAuthToken";


char apn[]  = "YourAPN";
char user[] = "";
char pass[] = "";

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);


#include <SoftwareSerial.h>
SoftwareSerial SerialAT(7, 8); // RX, TX

TinyGsm modem(SerialAT);

WidgetMap myMap(V1);

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

  // Set GSM module baud rate
  SerialAT.begin(19200);
  delay(3000);

 ss.begin(GPSBaud);

//does delay needed//

  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  modem.restart();

  // Unlock your SIM card with a PIN
  //modem.simUnlock("1234");

  Blynk.begin(auth, modem, apn, user, pass);

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

  int index = 1;
  double lat = gps.location.lat();
  double lon = gps.location.lon();
  myMap.location(index, lat, lon, "value");

I think here may be needed these check code from library

 while (ss.available() > 0)
    if (gps.encode(ss.read()))
}

void loop()
{
  Blynk.run();
}

Main questions:

  1. Braud rates of SIM900 and GPS NEO 6M have to be different as i made (NEO 9600 and Sim 19200) or not?
  2. Does it matters in what order and whith what delay begin serials for GSM and GPS?
  3. How to associate code from Tiny gps++ for waiting data and blynk timers for delay and etc.?
  4. Library for Map Widget maybe needs any modifications?

@vshymanskyy I will be really greathful to see your thoughts!)

Also any other opinion will be useful!

Today I’ve done some tests with MAP widget, but actually it’s not working as expected.
So…
The first problem - maps.google.com shows a little different place than blynk Android app with the same coordinates :open_mouth: for about few hundred meters. Strange.

When I read V1 value with RESTful API, I get something like “1\u000056.970\u000021.977\u0000444”,
but in sketch was hardcoded lat=56.970159, lon=21.977929.
Why acuracy is reduced? Why are there leading zeros and lost decimals after point? Is this cause float value type, arduino or widget?
What is the V1 format actually?

Please send it as double or format numbers to strings manually to get desired precision.

1 Like

TNX! Seems it works.

A post was split to a new topic: Not getting the location from my GPS project