Blynk+Sim900 shield + NEO 6M + Arduino UNO

Hello!

I am trying to make a tracker using Map Widget.

Code is

#define BLYNK_DEBUG // Optional, this enables lots of prints    
#define BLYNK_PRINT Serial
#define TINY_GSM_MODEM_SIM900


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

static const int RXPin = 5, TXPin = 4;
static const uint32_t GPSBaud = 9600;

TinyGPSPlus gps;

SoftwareSerial ss(RXPin, TXPin);


const char auth[] =
const char apn[]  = 
const char user[] = 
const char pass[] = 


SoftwareSerial SerialAT(7, 8); // RX, TX

TinyGsm modem(SerialAT);


WidgetMap myMap(V1);

void setup()
{
  // Set console baud rate
  Serial.begin(115200);
  delay(10);

  ss.begin(GPSBaud);
  delay(10);

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

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

  Blynk.begin(auth, modem, apn, user, pass);
  
 
  int index = 1;
  long lat = (gps.location.lat(), 7);
  long lon = (gps.location.lng(), 7); 
  myMap.location(index, lat, lon, "value");
  
}

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

Ihave problem with gps data format.
Using gps part only i get in serial normal format, but in blynk debug it is wrong

Initializing modem…
[12608]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.4 on Arduino Uno

[12615] Free RAM: 1013
[12617] Modem init…
[13377] Connecting to network…
[17120] Network: MTS-RUS
[17121] Connecting to ****************…
[29296] Connected to GPRS
[29565] Connecting to blynk-cloud.com:8442
[31388] <[02|00|01|00] *********************
[32681] >[00|00|01|00|C8]
[32683] Ready (ping: 992ms).
[32684] <[11|00|01|00]ever[00]0.4.4[00]h-beat[00]60[00]buff-in[00]256[00]dev[00]Arduino Uno[00]cpu[00]ATmega328P[00]con[00]SIM800[00]build[00]Mar 12 2017 21:18:05[00]
[33073] <[14|00|02|00|10]vw[00]1[00] 1[00]0[00]0[00] value (in these line should be lat and long data)
[34641] >[00|00|01|00|C8]

Can someone help, plz?

Please edit and properly format your code above. It is difficult to read otherwise.

Sorry

If it is working normally, then why enable the Debug? Blynk Debug will drastically slow down your script operation… perhaps that is affecting the GPS data flow?

it was not workink well, he showed me that i am in africa, but i am in europe.

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!