esp32 s2 tinyUSB

chegewara
Posts: 1133
Joined: Wed Jun 14, 2017 9:00 pm

esp32 s2 tinyUSB

Postby chegewara » Sat May 30, 2020 2:45 am

I would like to share good news. Today i finished updating tinyUSB component to master branch and have prepared 3 useful and really cool examples https://github.com/chegewara/esp-idf/tr ... herals/usb:
- CDC usb, communication device class, which allows to connect with any terminal like putty and communicate with system, possible use case AT commands etc, alternative to UART, but using native USB,
- MSC, mass storage class, can be used like a common pendrive, for now example is using only internal ram (small ram disk), possible use case - OTA update by drag and drop, adding SD card will make even more use cases,
- webUSB, usb device controlled from web browser without using wifi, currently example is using website terminal to send message to esp32s2 and esp32s2 is echoing it, also its possible to connect with putty at the same time and text between website esp32 and putty, another example project what can be done with webusb https://github.com/sowbug/weblight, another use case is setup wifi credentials and all other device setting using cloud hosted website, without need to run AP

Still few more usb device types left, like HID or MIDI.

esp-idf PRs on the way, lets hope can be merged soon.

WebUSB:
Screenshot from 2020-05-30 04-25-09.png
Screenshot from 2020-05-30 04-25-09.png (143.32 KiB) Viewed 1380 times
MSC disk:
Screenshot from 2020-05-30 05-01-34.png
Screenshot from 2020-05-30 05-01-34.png (47.44 KiB) Viewed 1373 times
MSC disk benchmark:
Screenshot from 2020-05-30 08-26-40.png
Screenshot from 2020-05-30 08-26-40.png (96.3 KiB) Viewed 1353 times

chegewara
Posts: 1133
Joined: Wed Jun 14, 2017 9:00 pm

Re: esp32 s2 tinyUSB

Postby chegewara » Tue Jun 02, 2020 6:37 am

Here is another test. This time i am using port of tinyusn library with arduino as component. Board is kaluga, and disk is in spiram, disk size 1MB:
Screenshot from 2020-06-02 08-39-10.png
Screenshot from 2020-06-02 08-39-10.png (89.77 KiB) Viewed 1174 times

chegewara
Posts: 1133
Joined: Wed Jun 14, 2017 9:00 pm

Re: esp32 s2 tinyUSB

Postby chegewara » Fri Jun 12, 2020 3:18 pm

I played with USB and tinyusb for some time recently and i prepared small, not finished, library that can show how it is going to be easy to use it with arduino. There is few examples prepared to show few USB classed at work. Code is prepared to work as arduino as component, sorry for that:
https://github.com/chegewara/esp32s2-ti ... -component

chegewara
Posts: 1133
Joined: Wed Jun 14, 2017 9:00 pm

Re: esp32 s2 tinyUSB

Postby chegewara » Sun Jun 21, 2020 5:08 pm

I have another cool example how to use USB on S2. This time its MSC class (mass storage) to OTA update device with drag n drop.
Its enough to copy new binary to esp32 which works like a pendrive and new firmware will be flashed and start from OTA partition.

Code is still messy, but for all who would like to test it here is dfu.bin that can be flashed and tested.
dfu.zip
(137.16 KiB) Downloaded 10 times
PS i forgot to mention, there is implemented factory reset with pin 21, so it can be updated as many times as you want

Here is arduino as component code:
https://github.com/chegewara/esp32s2-msc-ota

chegewara
Posts: 1133
Joined: Wed Jun 14, 2017 9:00 pm

Re: esp32 s2 tinyUSB

Postby chegewara » Fri Jun 26, 2020 12:19 am

Hi,
i would like to share with another esp32 S2 demo using native USB. This time i have connected DS18d20 temp sensor and data are sent to webUSB. Whenever web page is opened and connected to esp32 data are received every 500ms and last 10 records are displayed with chart.js:

Screenshot from 2020-06-26 02-27-00.png
Screenshot from 2020-06-26 02-27-00.png (150.83 KiB) Viewed 185 times
I know it is possible with old esp32 and web server, but here we dont need wifi connection to esp, website is hosted on internet.

Who is online

Users browsing this forum: Majestic-12 [Bot] and 4 guests