Problem with Cloud Dimmed Light

Hi,
with this sketch:

#include "arduino_secrets.h"
/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/5e625f25-4d71-473d-ac9a-e33135c80ef8 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  CloudDimmedLight white;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  
}


/*
  Since White is READ_WRITE variable, onWhiteChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onWhiteChange()  {
  int brightness = map(dimmedLightwhite.getBrightness(),0,100,0,255);
  if(dimmedLightwhite.getSwitch()){
    analogWrite(5, brightness);
  }
  else{
    analogWrite(5, LOW);
  }
}

gives me this error:

/usr/local/bin/arduino-cli compile --fqbn esp32:esp32:esp32doit-devkit1:DebugLevel=none,EraseFlash=none,FlashFreq=80,UploadSpeed=921600 --build-cache-path /tmp --output-dir /tmp/3766442049/build --build-path /tmp/arduino-build-4AB17AFD4FA3EE874AE2C0B68570C579 /tmp/3766442049/Lampada_v2_mar29a
/tmp/3766442049/Lampada_v2_mar29a/Lampada_v2_mar29a.ino: In function 'void onWhiteChange()':
/tmp/3766442049/Lampada_v2_mar29a/Lampada_v2_mar29a.ino:46:24: error: 'dimmedLightwhite' was not declared in this scope
int brightness = map(dimmedLightwhite.getBrightness(),0,100,0,255);
^~~~~~~~~~~~~~~~
/tmp/3766442049/Lampada_v2_mar29a/Lampada_v2_mar29a.ino:47:24: note: suggested alternative: 'DimmedLight'
int brightness = map(dimmedLightwhite.getBrightness(),0,100,0,255);
^~~~~~~~~~~~~~~~
DimmedLight
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/seeed_arduino_rpcwifi_1_0_7
Not used: /home/builder/opt/libraries/wifi_1_2_7
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/wifiespat_1_4_3
Not used: /home/builder/opt/libraries/da16200_wi_fi_library_for_arduino_1_1_0
Not used: /home/builder/opt/libraries/nina_wi_fi_1_0_1
Not used: /home/builder/opt/libraries/wifinina_1_8_14
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_7
Error during build: exit status 1

I cannot understand where I am going wrong and I need help.

EzioGi

Hi @eziogi. If looks like the name of your Cloud variable is white, not dimmedLightwhite:

If so, just correct the variable name in the references in the sketch:

@@ -43,8 +43,8 @@ void loop() {
   executed every time a new value is received from IoT Cloud.
 */
 void onWhiteChange()  {
-  int brightness = map(dimmedLightwhite.getBrightness(),0,100,0,255);
-  if(dimmedLightwhite.getSwitch()){
+  int brightness = map(white.getBrightness(),0,100,0,255);
+  if(white.getSwitch()){
     analogWrite(5, brightness);
   }
   else{

Hi,
next weekend I make the changes.
Thanks

EzioGi

I made the changes as you advised and now it works regularly.

Thank you

EzioGi

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.