Blynk and wifi problem

I am using this code with the aim of controlling a car via Blynk and ESP8266. When the ESP8266 receives the letter 's' via UDP, Blynk should halt, and the GPS data will be uploaded to a web server to display the car's location.

#define BLYNK_TEMPLATE_ID "..."
#define BLYNK_TEMPLATE_NAME "..."
#define BLYNK_PRINT Serial

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WebServer.h>

TinyGPSPlus gps;
SoftwareSerial SerialGPS(D7, D8);

float Latitude, Longitude;
int year, month, date, hour, minute, second;
String DateString, TimeString, LatitudeString, LongitudeString;

ESP8266WebServer server(80);

// Motor PINs
#define ENA D0
#define IN1 D1
#define IN2 D2
#define IN3 D3
#define IN4 D4
#define ENB D5

bool forward = false;
bool backward = false;
bool left = false;
bool right = false;
int Speed = 255; // يمكنك تغيير هذا الرقم حسب سرعة الحركة التي ترغب بها

char auth[] = "4xNoxGO01b5Jo_ikD4JMRSNcIsn6N5DR"; // Enter your Blynk application auth token
char ssid[] = "WLAND94949";  // Enter your WIFI name
char pass[] = "FbxZATNYuk2N";  // Enter your WIFI password
unsigned int udpPort = 8888;  // local port to listen on
char packetBuffer[UDP_TX_PACKET_MAX_SIZE + 1]; // تعريف المتغير packetBuffer

WiFiUDP Udp;

void gpsmoh() {
  while (SerialGPS.available() > 0) {
    if (gps.encode(SerialGPS.read())) {
      if (gps.location.isValid()) {
        Latitude = gps.location.lat();
        LatitudeString = String(Latitude, 6);
        Longitude = gps.location.lng();
        LongitudeString = String(Longitude, 6);
      }

      if (gps.date.isValid()) {
        DateString = "";
        date = gps.date.day();
        month = gps.date.month();
        year = gps.date.year();

        if (date < 10)
          DateString = '0';
        DateString += String(date);

        DateString += " / ";

        if (month < 10)
          DateString += '0';
        DateString += String(month);
        DateString += " / ";

        if (year < 10)
          DateString += '0';
        DateString += String(year);
      }

      if (gps.time.isValid()) {
        TimeString = "";
        hour = gps.time.hour() + 3; //adjust UTC
        minute = gps.time.minute();
        second = gps.time.second();

        if (hour < 10)
          TimeString = '0';
        TimeString += String(hour);
        TimeString += " : ";

        if (minute < 10)
          TimeString += '0';
        TimeString += String(minute);
        TimeString += " : ";

        if (second < 10)
          TimeString += '0';
        TimeString += String(second);
      }
    }
  }

  String s = "<!DOCTYPE html><html><head><title>GPS Data</title>";
  s += "<style>body {font-family: Arial, sans-serif;}";
  s += "table {border-collapse: collapse; width: 50%; margin: auto;}";
  s += "th, td {border: 1px solid #dddddd; text-align: left; padding: 8px;}";
  s += "th {background-color: #f2f2f2;}</style></head><body>";
  s += "<h1 style='text-align: center;'>Location Details</h1>";
  s += "<table><tr><th>Latitude</th><td>" + LatitudeString + "</td></tr>";
  s += "<tr><th>Longitude</th><td>" + LongitudeString + "</td></tr>";
  s += "<tr><th>Date</th><td>" + DateString + "</td></tr>";
  s += "<tr><th>Time</th><td>" + TimeString + "</td></tr></table>";

  if (gps.location.isValid()) {
    s += "<p style='text-align: center;'><a href='http://maps.google.com/maps?q=" + LatitudeString + "," + LongitudeString + "' target='_blank'>Open in Google Maps</a></p>";
  }

  s += "</body></html>";

  server.send(200, "text/html", s);
}


void setup() {
  Serial.begin(9600);
  SerialGPS.begin(9600);
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  pinMode(ENB, OUTPUT);

  Serial.print("Connecting to WiFi...");
  WiFi.begin(ssid, pass);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println();
  Serial.println("Connected to WiFi");
  Serial.print("IP Address: ");
  Serial.println(WiFi.localIP());

  Blynk.begin(auth, ssid, pass);
  Udp.begin(udpPort);

  server.on("/", gpsmoh);
  //server.begin();
}

void loop() {
  Blynk.run();
  server.handleClient();

  int packetSize = Udp.parsePacket();
  if (packetSize) {
    int len = Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
    if (len > 0) {
      packetBuffer[len] = 0;
      Serial.print("Received packet: ");
      Serial.println(packetBuffer);

      if (strcmp(packetBuffer, "s") == 0) {
        Blynk.disconnect();
        gpsmoh();
        server.begin();
        Serial.println("good");
      }
    }
  }

  if (forward) {
    carforward();
    Serial.println("carforward");
  } else if (backward) {
    carbackward();
    Serial.println("carbackward");
  } else if (left) {
    carturnleft();
    Serial.println("carfleft");
  } else if (right) {
    carturnright();
    Serial.println("carright");
  } else {
    carStop();
    //Serial.println("carstop");
  }
}

void carforward() {
  analogWrite(ENA, Speed);
  analogWrite(ENB, Speed);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void carbackward() {
  analogWrite(ENA, Speed);
  analogWrite(ENB, Speed);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void carturnleft() {
  analogWrite(ENA, Speed);
  analogWrite(ENB, Speed);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void carturnright() {
  analogWrite(ENA, Speed);
  analogWrite(ENB, Speed);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void carStop() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

but it dosent work on serial it dosent write the ip and name of network

I moved your topic to an appropriate forum category @al_seba3y.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

have you tested the individual components of the system in separate programs? e.g. GPS, Blynk, etc
are you using EspSoftwareSerial?
upload a schematic showing the wiring and power supplies
what is the GPS module?
any other devices? e.g. sensors, relays, CANBUS connection, etc

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.