Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A ArduinoJson
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 24
    • Issues 24
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Benoît Blanchon
  • ArduinoJson
  • Issues
  • #1889
Closed
Open
Issue created Mar 13, 2023 by TheRoyalGuard001@TheRoyalGuard001

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

  1. The issue happens at compile time
  2. 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.

Assignee
Assign to
Time tracking