Arduino Cloud ESP32 LED

I am trying to make a LED blink with ESP32 but it won’t work even if it connected to my laptop. I’ve checked the serial monitor and it says it’s connected to my internet but it still won’t work. Also I can’t send a video to show it.

1 Like

Hi @niko65.

The first thing you should try is the most simple possible sketch to blink the LED. You will find one already written here:

Does the LED blink after you upload that "Blink" sketch to your ESP32?


In order to help you with your problem, we will need more information:

Please post your full sketch.

  1. Auto Format your code by following these instructions:
    • If using the Arduino IDE: select Tools > Auto Format from the menus.
    • If using Arduino Cloud Editor: press Ctrl+B
  2. Click on the window that contains your sketch code.
  3. Press Ctrl+A. This will select all the text.
  4. Press Ctrl+C. This will copy the selected text to the clipboard.
  5. In a forum reply here, click on the reply field.
  6. Click the </> icon on the post composer toolbar. This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block
  7. Press Ctrl+V. This will paste the compilation output into the code block.
  8. Move the cursor outside of the code block markup before you add any additional text to your reply.
  9. Repeat the above process if your sketch has multiple tabs.
  10. Click the Reply button to post the output.

When your code requires a library that's not included with the Arduino IDE please post a link to where you downloaded that library from or if you installed it using Library Manager (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.


We will also need to know about any external circuitry on your ESP32 board. Do you have a separate LED wired to it, or are you using the built-in LED that is on the board itself? If the former, we need to know exactly how the LED is wired to the board.

Here is the full code:


 /*
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/f337125f-467a-4786-a5dd-5ff3b135650f

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

  // 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()  {
  if (led == 1)
  {
    digitalWrite(2, HIGH);
  }
  else
  {
    digitalWrite(2, LOW);
  }
}

Most of it was done by Arduino IoT cloud. I just did the bottom


LedChange()  {
  if (led == 1)
  {
    digitalWrite(2, HIGH);
  }
  else
  {
    digitalWrite(2, LOW);
  }

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