Hi friends. can anyone help me why ESP32 cannot auto connect to wifi network ? is problem with void loop ? or … ?
my sketch:
#include <HardwareSerial.h>
#include <TinyGPS++.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <SimpleTimer.h>
TinyGPSPlus gps; // The TinyGPS++ object
HardwareSerial ss(1);
SimpleTimer timer;
char auth[] = "8b7e5fc4e68d43d9862145bbbcf0c136";
char ssid[] = "MikroTik Home";
char pass[] = "12345678";
char server[] = "10.5.51.3";
//unsigned int move_index;
unsigned int move_index = 1;
bool simulation = false;
bool IranHack = false;
WidgetMap myMap(V15);
void setup()
{
Serial.begin(115200);
Serial.println();
ss.begin(9600, SERIAL_8N1, 16, 17);
Blynk.begin(auth, ssid, pass, server, 8080);
timer.setInterval(5000L, checkGPS);
timer.setInterval(2000L, check);
}
void checkGPS(){
if (gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected: check wiring."));
Blynk.virtualWrite(V18, "GPS ERROR");
Blynk.virtualWrite(V16, "--------");
Blynk.virtualWrite(V17, "--------");
}
}
void displayInfo()
{
if (gps.location.isValid() || simulation == true || IranHack == true)
{
Blynk.virtualWrite(V18, "GPS OK");
float latitude = (gps.location.lat());
float longitude = (gps.location.lng());
if(latitude == 0 && longitude == 0 )
{
Blynk.virtualWrite(V16, "--------");
Blynk.virtualWrite(V17, "--------");
Blynk.virtualWrite(V18, "0,0");
}
Serial.print("LAT: ");
Serial.println(latitude, 6);
Serial.print("LONG: ");
Serial.println(longitude, 6);
Blynk.virtualWrite(V16, String(latitude, 6));
Blynk.virtualWrite(V17, String(longitude, 6));
myMap.location(move_index, latitude, longitude, "ESP32Location");
}
else
{
Serial.print(F("INVALID"));
Blynk.virtualWrite(V18, "GPS INVALID");
Blynk.virtualWrite(V16, "--------");
Blynk.virtualWrite(V17, "--------");
}
Serial.println();
}
void check()
{
if(simulation == true || IranHack == true)
{
displayInfo();
}
else
{
while (ss.available() > 0)
if (gps.encode(ss.read()))
displayInfo();
}
}
void loop()
{
Blynk.run();
timer.run();
}
thanks