Arduino IoT Cloud not working

Hello,

I am trying to turn on a Led through Arduino IoT Cloud by toggling on a switch but it isn't working...

Here's my code:

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/6c9e30db-eeb4-4a54-8817-6e1423ad3296 

  Arduino IoT Cloud Variables description

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

  CloudLight lED;

  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); 

  pinMode(16,OUTPUT);
  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  
  
}



/*
  Since LED is READ_WRITE variable, onLEDChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onLEDChange()  {
  // Add your code here to act upon LED change
  if(lED){
    Serial.print(lED);
    digitalWrite(16,HIGH);
  }
  else{
    digitalWrite(16,LOW);
  }
}

Thanks

Hi @ifuino

I just gave it a try and it works fine for me.

Please add a forum reply here that provides a detailed explanation of what you mean by this, including:

  • What did you do?
  • What were the results you expected from doing that thing?
  • What were the results you observed that did not match your expectations?

Make sure to include the full and exact text of any error or warning messages you might have encountered.

What do you see in Serial Monitor if you open it while the board is running this sketch and then change the value of the Cloud Variable via an Arduino Cloud dashboard?

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