Error compiling for board NodeMCU 1.0
Description I found and used a GeoLocation code using V5 but recently decided to switch to V6 when I was putting in another feature. I followed the steps in the YouTube video but it seems V6 just isn't compatible for some reason??? I can't find a solution so do you have any idea what the problem could be?
Troubleshooter's report
- The issue happens at compile time
- The error is not in the list
Environment
- Microcontroller: ESP8266
- Core/Framework: NodeMCU 1.0 (ESP-12E Module) for Arduino
- IDE: Arduino IPE 1.8.19
Reproduction code
char bssid[6];
DynamicJsonDocument doc(1024);
Serial.println("scan start");
int n = WiFi.scanNetworks();
Serial.println("scan done");
if (n == 0)
Serial.println("no networks found");
else
{
Serial.print(n);
Serial.println(" networks found...");
}
//-----------------------BUILDING JSON------------------------
jsonString = "{\n";
jsonString += "\"homeMobileCountryCode\": 234,\n";
jsonString += "\"homeMobileNetworkCode\": 27,\n";
jsonString += "\"radioType\": \"gsm\",\n";
jsonString += "\"carrier\": \"Vodafone\",\n";
jsonString += "\"wifiAccessPoints\": [\n";
for (int j = 0; j < n; ++j)
{
jsonString += "{\n";
jsonString += "\"macAddress\" : \"";
jsonString += (WiFi.BSSIDstr(j));
jsonString += "\",\n";
jsonString += "\"signalStrength\": ";
jsonString += WiFi.RSSI(j);
jsonString += "\n";
if (j < n - 1)
{
jsonString += "},\n";
}
else
{
jsonString += "}\n";
}
}
jsonString += ("]\n");
jsonString += ("}\n");
//-----------------------JSON CLIENT SENDING------------------------------
Serial.println("");
WiFiClientSecure client;
client.setInsecure();
Serial.print("Requesting URL: ");
Serial.println("https://" + (String)Host + thisPage + "(My API code)");
Serial.println(" ");
if (client.connect(Host, 443)) {
Serial.println("Connected");
client.println("POST " + thisPage + key + " HTTP/1.1");
client.println("Host: " + (String)Host);
client.println("Connection: close");
client.println("Content-Type: application/json");
client.println("User-Agent: Arduino/1.0");
client.print("Content-Length: ");
client.println(jsonString.length());
client.println();
client.print(jsonString);
delay(500);
}
//-------------------READ, PARSE, AND REPLY THE DATA--------------------
while (client.available()) {
String line = client.readStringUntil('\r');
if (more_text) {
Serial.print(line);
}
DeserializationError error = deserializeJson(doc, jsonString);
if (error) {
Serial.print ("Json failed while doing ");
Serial.println (error.c_str());
}
latitude = doc["location"]["lat"];
longitude = doc["location"]["lng"];
accuracy = doc["accuracy"];
}
Serial.println("closing connection");
Serial.println();
client.stop();
//-----------------------FINAL LAT/LONG/ACC-------------------
Serial.print("Latitude = ");
Serial.println(latitude, 6);
Serial.print("Longitude = ");
Serial.println(longitude, 6);
Serial.print("Accuracy = ");
Serial.println(accuracy);
Serial.print ("Use this URL to connect: http://");
Serial.print(WiFi.localIP());
}
Remarks I think the problem is in the latter part of the code.