0

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

  • adding #include <Arduino.h> (which I had missed)
  • checking the baud rate (115200)
  • checked the tty device (ttyACM0)
  • turning off rts and drt
  • tried the code on Arduino IDE (2.3.4) which had the same problem
  • tried another esp32 (not H2) which worked fine

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
2
  • If the primary UART is busy doing console I/O, then you cannot also use that port for normal serial stuff. Is that what you are attempting? /dev/ttyACM0 should be busy talking to your debugger. Commented Dec 29, 2024 at 4:58
  • no, I realise that. I just wanted to see Serial.println string in the monitor (console i/o I assume), So this simple test I would expect to the line "Hello, ESP32!" and "Loop running..." string but they don't see them on the esp32-h2 but if I use esp32 standard it works as expected with both those strings. and Serial.available() don't even see any bytes so "I received: %d\n" line either when sending "test/n". it's like Serial just isn't working at all. I have read in a few places that turning off monitor_rts and monitor_dtr but don't seem to do anything for me tho. Commented Dec 29, 2024 at 9:27

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.