jazzjazzy
jazzjazzy

Reputation: 432

ESP32-H2 supermini Serial Class methods not working PIO or Arduino IDE

So I am running an esp32-H2 Supermini on Platform IO and I need to use some method from Serial. initially, I had a problem with the monitor where Serial.println() was not working but that was fine as a workaround as printf() worked without a problem. but now I need Serial methods like Serial.available() and after some investigation I worked out the Serial is not doing anything.

I have tried

I am putting it down to the esp32-H2 itself, in theory, it should have USB-UART and I would assume it works as I can get messages from printf(). so I am quickly running out of things to look at. any ideas would be appreciated.

platform io ini:

[env:esp32-devkitm-1]
platform = espressif32
framework = arduino
board = esp32-h2-devkitm-1
monitor_speed = 115200
monitor_port = /dev/ttyACM0
monitor_rts = 0
monitor_dtr = 0 

Code :

#include <Arduino.h>

int incomingByte = 0;

// put function declarations here:
void setup() {
    Serial.begin(115200);
    printf("Program started\n");

    while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB
    }

    printf("Serial initialized.\n");
    delay(1000);
    Serial.println("Hello, ESP32!");
}

void loop() {
    Serial.println("Loop running...");

    if (Serial.available() > 0) {
      // read the incoming byte:
      incomingByte = Serial.read();

      // say what you got:
      printf("I received: %d\n", incomingByte);
    }else {
      printf("No data received\n");
    }
   
    delay(1000);
}

output : all printf lines are printed, but none of the Serial.println. and the test/n is not seen.

ESP-ROM:esp32h2-20221101
Build:Nov  1 2022
rst:0x15 (USB_UART_HPSYS),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40802974
SPIWP:0xee
mode:DIO, clock div:1
load:0x408460e0,len:0x148
load:0x4083cad0,len:0xcdc
load:0x4083efd0,len:0x215c
entry 0x4083cad0
Program started
Serial initialized.
No data received
No data received
No data received
No data received
No data received
o data received
No data received
No data received
---- Sent utf8 encoded message: "test\n" ----
No data received
No data received
No data received
No data received

Upvotes: 0

Views: 99

Answers (1)

DaveS
DaveS

Reputation: 11

I has the same issue....

You need to need to enable to enable 'usb cdc on boot'

I use the Arduino IDE and you do via 'Tools' menu item.

It's a feature of the chip that usb cdc is disabled by default

Good luck

Upvotes: 1

Related Questions