I am having an error while compiling, what should I do?

I am having an error
/usr/local/bin/arduino-cli compile --fqbn esp32:esp32:uPesy_wroom --build-cache-path /tmp --output-dir /tmp/2910988330/build --build-path /tmp/arduino-build-F27D94EA05010993F5311E08938A1E0A /tmp/2910988330/Untitled_jan13a

/home/builder/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /tmp/arduino-build-F27D94EA05010993F5311E08938A1E0A/sketch/objs.a(Untitled_jan13a.ino.cpp.o):(.literal._Z14initPropertiesv+0x44): undefined reference to `onLedStateChange()'

collect2: error: ld returned 1 exit status

Multiple libraries were found for "WiFi.h"

Used: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5/libraries/WiFi

Not used: /home/builder/opt/libraries/nina_wi_fi_1_0_1

Not used: /home/builder/opt/libraries/da16200_wi_fi_library_for_arduino_1_1_0

Not used: /home/builder/opt/libraries/seeed_arduino_rpcwifi_1_0_6

Not used: /home/builder/opt/libraries/indhilib_3_0_5

Not used: /home/builder/opt/libraries/vega_wifinina_1_0_1

Not used: /home/builder/opt/libraries/wifinina_1_8_14

Not used: /home/builder/opt/libraries/wifi_1_2_7

Not used: /home/builder/opt/libraries/wifiespat_1_4_3

Multiple libraries were found for "WiFiClientSecure.h"

Used: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5/libraries/WiFiClientSecure

Not used: /home/builder/opt/libraries/seeed_arduino_rpcwifi_1_0_6

Multiple libraries were found for "Adafruit_Sensor.h"

Used: /home/builder/opt/libraries/adafruit_unified_sensor_1_1_14

Not used: /home/builder/opt/libraries/arduav_1_4_2

Multiple libraries were found for "Wire.h"

Used: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5/libraries/Wire

Not used: /home/builder/opt/libraries/flexwire_1_1_2

Multiple libraries were found for "DHT.h"

Used: /home/builder/opt/libraries/dht_kxn_3_4_4

Not used: /home/builder/opt/libraries/dht118266_1_0_16

Not used: /home/builder/opt/libraries/dht11esp8266_1_0_10

Not used: /home/builder/opt/libraries/nanoplayboard_0_1_1

Not used: /home/builder/opt/libraries/dht_sensor_library_1_4_6

Not used: /home/builder/opt/libraries/dht11esp8266examples_1_0_10

Not used: /home/builder/opt/libraries/servodht11_1_0_10

Not used: /home/builder/opt/libraries/ukit_explore_1_2_28

Not used: /home/builder/opt/libraries/grove_temperature_and_humidity_sensor_2_0_1

Not used: /home/builder/opt/libraries/esp826611_1_0_16

Error during build: exit status 1

what should I do?

Welcome to the forum

Start by posting your full sketch, using code tags when you do

Do you have any Cloud variables in your sketch and, if so, what are there names and definitions ?

There's the relevant part of your error message.

Read that. Think about it. Maybe try searching for it in your sketch's source code (the stuff that if you'd read and followed How to get the best out of the forum) you would have included in your message. Inside <CODE/> tags of course.

#include "thingProperties.h"
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

const int GAS_SENSOR_PIN = 4;
const int RAIN_SENSOR_PIN = 5;
const int LED_PIN = 13;

void onLedStateChange(int newState) {
  // This function handles changes in LED state
  digitalWrite(LED_PIN, newState);
}

void setup() {
  Serial.begin(9600);
  delay(1500);

  dht.begin();

  Wire.begin(32, 33);

  pinMode(GAS_SENSOR_PIN, INPUT);
  pinMode(RAIN_SENSOR_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);

  initProperties();
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();

  // Read sensor values
  float temperatureValue = dht.readTemperature();
  float humidityValue = dht.readHumidity();
  int gasLevelValue = digitalRead(GAS_SENSOR_PIN);
  int rainValue = digitalRead(RAIN_SENSOR_PIN);

  // Update IoT Cloud variables
  temperature = temperatureValue;
  humidity = humidityValue;
  gas_level = gasLevelValue;
  rain_value = rainValue;

  // Print sensor values to Serial Monitor
  Serial.println("Temperature: " + String(temperatureValue) + " °C");
  Serial.println("Humidity: " + String(humidityValue) + " %");
  Serial.println("Gas Level: " + String(gasLevelValue));
  Serial.println("Rain Value: " + String(rainValue));
  Serial.println("-----------------------------");

  // Control LED based on IoT Cloud command
  onLedStateChange(ledState);

  delay(1000);
}

variables:
gas_level
humidity
temperature
ledState
rain_value

Hi @mukundan_balaji. The problem is that you have changed the signature of the onLedStateChange function. This function is automatically called by the ArduinoIoTCloud library whenever the ledState Cloud Variable is changed on your Arduino Cloud Dashboard. The library does the equivalent of calling it like this:

onLedStateChange();

Note that no argument is passed to the function. So when you added a newState parameter to the function you made the call in the library invalid.

So you must change the function signature back to what it was originally in the Thing sketch generated by Arduino Cloud:

void onLedStateChange() {
  // This function handles changes in LED state
  digitalWrite(LED_PIN, ledState);
}

The way the library passes data to the function is by setting the value of the ledState global variable independently so there is no need for a parameter in this function.

Thank you, now my code is working

You are welcome. I'm glad it is working now.

Regards,
Per

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