Monitor Serial Issue. Arduino IDE

Hi!

I’ve read in many posts that the Arduino Cloud Editor doesn’t work properly with ESP32 boards. Instead, it’s recommended to use the Arduino IDE for sketching, uploading, and using the Serial Monitor. Here’s my code:

#include "arduino_secrets.h"
/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/540228a6-b349-4a44-871f-9510a43543f9 

  Arduino IoT Cloud Variables description

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

  float x;

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

float step = 0.1; // Tamaño del incremento
bool increasing = true; // Dirección del cambio

void loop() {
  ArduinoCloud.update();
  
  // Modificar el valor de x entre 0 y 10
  if (increasing) {
    x += step; // Incrementar x
    if (x >= 20) {
      increasing = false; // Cambiar dirección al llegar a 10
    }
  } else {
    x -= step; // Decrementar x
    if (x <= 0) {
      increasing = true; // Cambiar dirección al llegar a 0
    }
  }

  // Enviar el valor actualizado a la nube
  delay(0); // Controlar la velocidad de cambio
  Serial.println("Hi world");
}

The problem is that when I open the Serial Monitor at 9600 Hz, nothing is displayed. Additionally, no connection information appears, such as the IP address or any details I’ve seen in many tutorial videos.

Hi @chuspi135.

Please tell us exactly which ESP32 board you are using. It will be helpful if you provide a link to the product listing on the website where you purchased the board as that might provide the forum helpers with important information about the board.

Hi, thank you for the fast response.

Im using a ESP32C6 WROOM. It work with an USB C - USB cable.

OK, great. That gives me the information I was looking for.

A fairly unique thing about the boards that use the microcontrollers of the ESP32 family with native USB capability (as is the case with your ESP32-C6-based board) is that they are typically configured to disable the use of their USB CDC serial port in the sketch by default.

That default disabled configuration is appropriate when your sketch doesn't use the serial port, but in cases where you do need it (such as when your sketch calls Serial.println, etc.), then it is necessary to configure the board so that the port will be enabled. Fortunately this is quite easy since the ESP32 boards platform developers configured the board definition to produce a custom board options menu you can use to enable or disable the port as needed via the Arduino IDE user interface.

Please try this:

  1. Select Tools > USB CDC On Boot > Enabled from the Arduino IDE menus.
  2. Upload the sketch to your board again, just as you did before.

Now check the Serial Monitor. Hopefully you will now see the expected output from the board there.

1 Like

It works! Thank you.

You make this forum amazing to post on!

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

Regards, Per