0

I'm making an ESP32 development board and I'm thinking about putting an Arduino Leonardo chip between the USB port and the ESP32's USART pins to act as a USB/USART converter instead of the FTDI chip so that I can program the ESP32 through a USB serial port like any other Arduino board.

Is there a library/sketch licensed under a permissive license (MIT, BSD, Apache, etc.) which can make the Leonardo chip act as a HID Serial Port device which has a device name I want for easy identification in Device Manager and which requires no special driver installation in Windows and Linux once plugged into the computer?

Thank you for your time.

  • you should do a better research before asking. "Leonardo chip"? "HID Serial port"? why do you wan't to use a 32u4 as USB-to-TTL-Serial? only Uno and Mega use an Atmel MCU for USB. most boards have FTDI or CH340 USB chips – Juraj Apr 30 at 14:41
  • 1
    @Juraj I use a small PIC32MX chip as a USB interface on my boards. I like the flexibility that creating your own interface gives you. For example, activating DTR on my system automatically creates a reset pulse, instead of just holding the line low. – Majenko Apr 30 at 15:02
  • The reason I'm using 32U4 is because I'd also like to use it as a virtual HID CD drive with a virtual CD providing an exe application for the end user to be able to upload firmware, communicate with the existing firmware, etc.. And most importantly, it's programmable as I want and all the code I add upon it is mine. – Foxcat385 May 5 at 21:49
1

Why not write your own?

First off, you'll want to create your own custom board definition. To do that, find the boards.txt file in the AVR core of your installation. Then find the block of entries that starts leonardo. and copy the whole block. Change the leonardo to a name of your choosing.

Then change the .name entry to give your board a new name in the IDE.

Finally look for the (renamed) entries:

leonardo.build.vid=0x2341
leonardo.build.pid=0x8036
leonardo.build.usb_product="Arduino Leonardo"

Of course the leonardo will be whatever you changed them to. You can now give your board a new VID and PID to uniquely identify them - and also change the usb_product to name your board.

You can also add a myboard.build.usb_manufacturer="..." entry to change the manufacturer from the default of Arduino.

Now you have a board definition that identifies your board as what you want it to be. So now just write a sketch that passes through the serial between USB and UART, and also handles the DTR and RTS signals to be able to enter flash mode on the ESP32 (hint: use Serial.dtr() and Serial.rts() to check the status of those signals).

  • That's quite a comprehensive response. Thank you! However, I still don't understand where's the HID Serial Port driver library (under a permissive license) for me to include in my C++ project and which functions/classes I need to use to talk to the USB side of things. I understand the Serial library, but that's for the USART between the Leonardo and the ESP32. I need the virtual USART part. Could you please append that to your answer? – Foxcat385 May 5 at 21:58
  • It's already there. It's in the Arduino core. There is no library needed. – Majenko May 5 at 22:08
  • Oh, so there's Serial and Serial1? Is that correct? – Foxcat385 May 5 at 22:09
  • Yes. Serial is the USB, and Serial1 is the TX/RX pins. – Majenko May 5 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.