Hi, my code below seems to continuously attempt to connect my "ESP8266" to Wi-Fi and I can't figure out which part of my code is giving me this issue. The code is listed below
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <ESP8266WiFi.h>
#include <ThingsBoard.h>
#include <Seeed_mbedtls.h>
#define THINGSBOARD_ENABLE_PROGRAM 0
#define THINGSBOARD_ENABLE_PSRAM 0
#define THINGSBOARD_ENABLE_DYNAMIC 1
constexpr char WIFI_SSID[]="Fios-Rdq3F";
constexpr char WIFI_PASSWORD[]="sun59sum25mouse";
constexpr char TOKEN[]="TKm4MA82jKZKBRDidGlX";
constexpr char THINGSBOARD_SERVER[]="demo.thingsboard.io";
constexpr uint16_t THINGSBOARD_PORT=1883U;
constexpr uint32_t MAX_MESSAGE_SIZE=256U;
constexpr uint32_t SERIAL_DEBUG_BAUD= 115200U;
constexpr int16_t telemetrySendInterval = 2000U;
uint32_t previousDataSend;
WiFiClient wifiClient;
ThingsBoard tb(wifiClient, MAX_MESSAGE_SIZE);
int MQ2=A0;//(A0)
int GAS;
int Latitude;
int Longitude;
int Speed;
int Altitude;
TinyGPSPlus gps;
SoftwareSerial GPS(2,0);//Blue(D4),purple(D3)
void InitWiFi() {
Serial.println("Connecting to AP ...");
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Connected to AP");
}
const bool reconnect() {
// Check to ensure we aren't connected yet
const wl_status_t status = WiFi.status();
if (status == WL_CONNECTED) {
return true;
}
InitWiFi();
return true;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
GPS.begin(9600);
Serial.begin(115200);
InitWiFi();
pinMode(MQ2,INPUT);
}
void loop() {
if (!reconnect()) {
return;
}
if (!tb.connected()) {
Serial.print("Connecting to: ");
Serial.print(THINGSBOARD_SERVER);
Serial.print(" with token ");
Serial.println(TOKEN);
}
if (!tb.connect(THINGSBOARD_SERVER, TOKEN, THINGSBOARD_PORT)) {
Serial.println("Failed to connect");
return;
}
GPS.listen();
while (GPS.available() > 0) {
gps.encode(GPS.read());
if (gps.location.isUpdated()) {
Serial.print("Longitude=");
Serial.println(gps.location.lng(), 6);
Serial.print("Latitude=");
Serial.println(gps.location.lat(), 6);
Serial.print("Speed=");
Serial.println(gps.speed.kmph());
Serial.print("Altitude in meters=");
Serial.println(gps.altitude.meters());
GAS= analogRead(MQ2);
Serial.print("Gas=");
Serial.println(GAS);
Serial.println("\t");
delay(1000);
tb.sendTelemetryInt("Gas",GAS);
tb.sendTelemetryInt("Longitude",gps.location.lng());
tb.sendTelemetryInt("Latitude",gps.location.lat());
tb.sendTelemetryInt("Speed",gps.speed.kmph());
tb.sendTelemetryInt("Altitude",gps.altitude.meters());
}
}
}
This is the message that I receive after I compile the code. The message is listed below...
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 3424, room 16
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8
tail 0
chksum 0x2b
csum 0x2b
v0007c3e0
~ld
����o�r��N|�$�d b�2�|r�$�o��o�$`��r�l�l��Connecting to AP ...
.............Connected to AP
Connecting to: demo.thingsboard.io with token TKm4MA82jKZKBRDidGlX
—-----------------CUT HERE FOR EXCEPTION DECODER—------------------
Exception (3):
epc1=0x40221d1a epc2=0x00000000 epc3=0x00000000 excvaddr=0x4026e6e7 depc=0x00000000
stack>>>
ctx: cont
sp: 3ffffde0 end: 3fffffd0 offset: 0150
3fffff30: 514d0400 3f045454 000001f4 000001f4
3fffff40: 00000000 4026e6e7 00000000 00000000
3fffff50: 00000001 00000100 00000000 4020ee6c
3fffff60: 3ffe91a2 fffffffc 00000001 3ffe8c00
3fffff70: 3ffe8c14 3fff0778 3fff05d0 4020c228
3fffff80: 00000000 00000000 00000001 4020c7d0
3fffff90: 3ffe8c14 3fff0778 3fff05d0 4020824c
3fffffa0: feefeffe feefeffe feefeffe 3fff0900
3fffffb0: 3fffdad0 00000000 3fff08d4 4020dd14
3fffffc0: feefeffe feefeffe 3fffdab0 4010140d
<<<stack<<<