Arduino IoT cloud

Compilation error: 'ArduinoIoTCloud' was not declared in this scope.
i get the error while uploading the code to ESP32.

What code would that be?
(You can't upload code that doesn't compile)

I’m using open weather map monitoring weather conditions

Sweet.

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

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.

this is the code which I'm used.

#include <ArduinoIoTCloud.h>
#include <Arduino_JSON.h>
#include <WiFi.h>

// WiFi credentials
const char* ssid = "";
const char* password = "";

// OpenWeatherMap API key
const char* openWeatherMapApiKey = "API Key";

// City and country code
const char* city = "";
const char* countryCode = "";

// Arduino IoT Cloud variables
int temperature;
int humidity;
int pressure;

// Device ID and Secret key
const char* deviceId = "f3ad949f-c1ee-4a38-9f64-2e6f9983d1df";
const char* secretKey = "XILHTWCV4PQXODTQW8CY";

void setup() {
Serial.begin(115200);
while (!Serial);

// Initialize Arduino IoT Cloud
ArduinoIoTCloud.begin(deviceId, secretKey);

// Connect to WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

// Get weather data from OpenWeatherMap
String serverPath = "http://api.openweathermap.org/data/2.5/weather?q=" + city + "," + countryCode + "&APPID=" + openWeatherMapApiKey;
String jsonBuffer = httpGETRequest(serverPath.c_str());

// Parse JSON data
JSONVar json = JSON.parse(jsonBuffer);
temperature = json["main"]["temp"];
humidity = json["main"]["humidity"];
pressure = json["main"]["pressure"];
}

void loop() {
// Update Arduino IoT Cloud variables
ArduinoIoTCloud.update(temperature, humidity, pressure);

// Delay
delay(60000);
}

String httpGETRequest(const char* serverPath) {
WiFiClient client;
HTTPClient http;
String payload;

// Connect to server
if (http.begin(client, serverPath)) {
// Send request
int httpCode = http.GET();

// Check response code
if (httpCode == 200) {
  // Get response payload
  payload = http.getString();
} else {
  Serial.println("Error: " + httpCode);
}

// Close connection
http.end();

} else {
Serial.println("Error connecting to server");
}

return payload;
}

Hi @jaleelpc. You have an error in the ArduinoIoTCloud library's instance name. Somewhat confusingly, it is ArduinoCloud instead of ArduinoIoTCloud as you have in your sketch.

So change all the occurrences of the incorrect name in the sketch. For example, change this line:

to this:

ArduinoCloud.begin(deviceId, secretKey);

After that, you'll still run into some other errors. For example:

C:\Users\per\AppData\Local\Temp\.arduinoIDE-unsaved2023630-14752-xj40eu.h5q5d\sketch_jul30c\sketch_jul30c.ino: In function 'void loop()':
C:\Users\per\AppData\Local\Temp\.arduinoIDE-unsaved2023630-14752-xj40eu.h5q5d\sketch_jul30c\sketch_jul30c.ino:55:54: error: no matching function for call to 'ArduinoIoTCloudTCP::update(int&, int&, int&)'
   ArduinoCloud.update(temperature, humidity, pressure);
                                                      ^
In file included from C:\Users\per\Documents\Arduino\libraries\ArduinoIoTCloud\src/ArduinoIoTCloud.h:175,
                 from C:\Users\per\AppData\Local\Temp\.arduinoIDE-unsaved2023630-14752-xj40eu.h5q5d\sketch_jul30c\sketch_jul30c.ino:1:
C:\Users\per\Documents\Arduino\libraries\ArduinoIoTCloud\src/ArduinoIoTCloudTCP.h:78:18: note: candidate: 'virtual void ArduinoIoTCloudTCP::update()'
     virtual void update        () override;
                  ^~~~~~
C:\Users\per\Documents\Arduino\libraries\ArduinoIoTCloud\src/ArduinoIoTCloudTCP.h:78:18: note:   candidate expects 0 arguments, 3 provided

As the error message says, you can't pass arguments to the ArduinoCloud.update function.

It seems you are taking an inefficient approach of throwing a lot of code into your sketch without verifying it along the way, hoping it will work by luck. I would recommend taking a look at the information here to learn more about using the ArduinoIoTCloud library:

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