WDT Reset when getting gps speed from GPS Streaming widget

Hello!
I’m creating a project to measure speed with NodeMCU Esp8266 and Neo 6M GPS module. It works perfectly before I use GPS Streaming widget. I want to compare the speed from GPS module and the speed from gps on my phone. I’m using GPS Streaming widget to get gps speed from my phone. Here is my code:


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

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266_SSL.h>

static const int RXPin = 12, TXPin = 13;
static const uint32_t GPSBaud = 9600;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "#############";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "##############";
char pass[] = "#############";

TinyGPSPlus gps;
SoftwareSerial ss(RXPin, TXPin);
BlynkTimer timer;

void setup()
{ 
  // Debug console
  Serial.begin(115200);
  ss.begin(GPSBaud);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(500L, check_module);
}
  
void loop()
{  
  Blynk.run();
  if (ss.available() > 0)
    if (gps.encode(ss.read()))
      timer.run();
  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
  }
}

void check_module()
{
  if (gps.speed.isUpdated())
  {
    displayInfo();
  }
}

void displayInfo()
{
  if (gps.location.isValid())
  {
    double gps_spd = trunc(gps.speed.kmph());
    String gps_spdbuf;
    gps_spdbuf = String(gps_spd);
    WidgetLED led1(V1);
    WidgetLED led2(V2);
    WidgetLED led3(V3);

    Serial.print(gps_spdbuf);
    Serial.println(" km/h");

    Blynk.virtualWrite(V0, gps_spd);

    if (gps_spd < 40)
    {
      Blynk.setProperty(V0, "color", "#2ecc71");
      led1.on();
      led2.off();
      led3.off();
    }
    else if (gps_spd >= 40 && gps_spd <60)
    {
      Blynk.setProperty(V0, "color", "#f1c40f");
      led1.off();
      led2.on();
      led3.off();
    }
    else if (gps_spd > 60)
    {
      Blynk.setProperty(V0, "color", "#e74c3c");
      led1.off();
      led2.off();
      led3.on();

      Blynk.notify("Do not exceed speed limit!");
      Blynk.email("#######@gmail.com", "Warning!", "Do not exceed speed limit!");
    }
  }
}

BLYNK_WRITE(V4)
{
  float gps_phone_spd = trunc(param[3].asFloat());
  
  Blynk.virtualWrite(V5, gps_phone_spd);
  Serial.println(gps_phone_spd);
}

I think the problem is Blynk.virtualWrite(V5, gps_phone_spd);
When I erase that, the app works fine without wdt reset. But how can i manage that? I need to compare both speed to SuperChart widget which taking data from V5. Please help!

Maybe send the float as a String?

BLYNK_WRITE(V4)
{
  float gps_phone_spd = trunc(param[3].asFloat());
  
  Blynk.virtualWrite(V5, String(gps_phone_spd, 2));
  Serial.println(gps_phone_spd);
}

I tried, but its still getting wdt reset.

Your void loop looks very odd, and the test for millis()>5000 will always be true after the MCU has been running for 5 seconds.

Pete.

1 Like

and the dog needs to eat :smile:

1 Like