USB Camera to ESP32-S2 (UVC Camera)
ฝัง
- เผยแพร่เมื่อ 28 มิ.ย. 2024
- ESP32-S2 supports a native USB interface. It works as a USB Host and allows data communication by connecting USB peripherals. Unfortunately, the maximum speed of this USB is 12Mbps, so you can't expect that fast.
In this video, I will show you how to properly acquire an image by connecting a UVC camera and ESP32-S2.
[ESP32-S2 | Native USB Serial Speed]
• ESP32-S2 | Native USB ...
[Auto Key Input USB Keyboard using ESP32-S2 (based on Keyset)]
• Auto Key Input USB Key...
[Espressif IoT Solution Overview]
github.com/espressif/esp-iot-...
[USB Camera Example]
github.com/espressif/esp-idf/...
Recommend purchasing ESP32-S3 instead of ESP32-S2
[ESP32-S3-DevKitC-1-N8R8 Development Board]
amzn.to/3FZmfAM
#UVC #USB #Camera #ESP32S2 #ThatProject - วิทยาศาสตร์และเทคโนโลยี
~ User$ th-cam.com/users/ThatProject (For more projects)
~ User$ github.com/0015/ThatProject (Project Github Repo)
~ User$ facebook.com/groups/138965931539175 (Facebook Group)
Love your projects ! Are you planning on having a discord ?
thank you, good information
(6:35) "my descriptor does not have this information" about the bFrameIndex. But it did have bFrameIndex=1 listed in the descriptor, line 41? Did you just miss it, maybe? It's not exactly a straightforward setup, it's already impressive that you managed to get it to work!
¡Gracias!
Thanks
Hello I have an idea for a great projects using esp32 ttgo t cam plus , it does not seem to have been done before and there is some code out there to help so not all has to be done from scratch. How do get information to you?
Hey Eric,
I have been working over a machine where I will be using cameras to record pictures with esp32. Earlier I was relying over Esp32-cam module but now after your video, I think I can connect a webcam for pictures as you did.
One question: If I use an Esp32 development board instead of Esp32-s2 then will it work or will I have to purchase a separate esp32-s2 board.
This only works with S2 or S3 as it requires a Native USB interface.
@@ThatProject Thanks.
I regularly watch your videos and got to learn a lot and made many different projects.
Can you connect a usb camera, sd card model and pir sensor to a ESP32 development board?
To create a time lapse video?
Hello sir. Have you tried using USB borescope probe cameras for looking into small dark spaces like drain pipes?
I've seen videos, but I've never actually used it. What do you want to say?
Hi. could you pls tell a quick compare between this camera streaming and native esp32-cam module with ov2640 cam. which one can transfer better quality. which one has lower latency in same resolution? thanks
I'll try this if I have a good chance. Thank you.
thank you so much
This was helpful
But I have some questions
Is it possible to build a project based on api and flutter?
A request is sent to the camera to take a video or photo
Control the camera so that you can send video and photos
backend
thank you so much
were you able to get the camera's mic input to play on your smartphone?
Very challenging! I have no idea how to get Audio Data from the built-in MIC of a USB Camera but that's gonna be cool if it's possible.
Hi, can you explain how to open the configuration descriptor and the uvc config at sdkconfig as now it uses the new file "usb-camera-mic-spk". Thank you for your help cause i'm totally lost following this video with the new file
I've never tried the "usb-camera-mic-spk" so I have no idea until I try it.
Nice work. Do you know any project that uses serial camera 4 wires (5v, grn, txm dx). I need to use external camera with IR light.
I've never seen a camera module with a serial connection. If it's an SPI connection, it seems to be possible with 4 wires. How about ArduCam Mega? th-cam.com/video/5ygPx5FUH1Y/w-d-xo.htmlsi=m9P2x4Op_tinQF7y
It can capture very high-quality images. However, because it is connected via "SPI", it is difficult to use for streaming. Also, since this does not have an IR light, I think it will need to be attached additionally.
Fantastic video, however i need help setting up the ide to do this, could anyone help me ?
consider I have a fresh install of vscode
How would I go about using the esp32 as a simple wifi antenna for my laptop? for example if my wifi card inside was to fail, could I use the esp32 to connect and surf?
No. It's impossible to use the ESP32 as a network modem for your computer.
Hi, is there a new model for the ESP32 with a display that you would recommend for this purpose?
There are so many products coming out these days that it's hard to catch up. Please check the display I used in my project first. It can reduce failures.
Which visual studio code plugin are you using? Is there any example for PlatformIo
I just use ESP-IDF VS Code Extension. I don't have any examples for PlatformIO.
considering the horrible impedance mismatch due to the lousy wiring, I find the result impressive.
😂
hello, will this work with a esp32 s2 mini? that one does not have pinout for pin 19 and pin 20, bu the microchip still has the pins, so i can remove the mask from 2 traces going from the microchip to the single usb port, if you know how to use that, can you please aid me ?
soldering wired directly to the microchip would be like putting the "programming" usb port and the camera usb port in parallel i think?
if not, will this work with a esp32 s3 with 2 usb ports ?
I don't know what kind of ESP32-S2 MINI you have, but to use the native USB interface, pins 19 and 20 must be connected directly. If not, I have no idea how to connect it.
Would using a Espressif ESP32 Dev Module with a USB to UART adapter work? I don't have a ESP32-S2/S3.
I don't get it. It has a built-in USB UART and also USB Native. You can use both of them.
Cheers
I'm stuck on the first part as I can't get the example to load into the IDE and compile for me. Are there previous steps that I should know about? In the IDE I can put several examples, but just in this example I am doing something wrong.
What kind of IDE are you using???
@@ThatProject i try with idf-espressif and vscode but not working
@@joseluislafuente4968 I did this project the same as your dev environment. I think your problem is all components to run the official examples on your end are not prepared yet. Would you please check these are installed on your end again? for Mac, docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/linux-macos-setup.html
for Windows, docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/windows-setup.html
Thank you for your time and effort. I tried recreating the setup by using a dev-board containing a ESP32-S3-WROOM-1-N8R2. However, after uploading the cloned report the ESP runs only until the PSRAM is initialized and after that it freezes until the watchdog timer runs out and triggers a reset. I have no idea what would cause this behaviour any help would be appreciated.
The example code requires an additional 2 MB PSRAM. For this project, my S2 board has 8 MB PSRAM though. My guess is that your S3 2MB PSRAM is not working properly or is insufficient for some reason. If you look at the source code, line number 34, #define CONFIG_USE_PSRAM Would you like to try without using PSRAM by removing this part? I'm curious about what kind of error you're getting.
github.com/espressif/esp-iot-solution/blob/usb/add_usb_solutions/examples/usb/host/usb_camera_wifi_transfer/main/main.c
@@ThatProject Thank you for your fast respose. I tried removing the define and the console output remained exactly the same. However the compile time was only a few seconds, compling it for the first time takes about 2 minutes. Is this normal?
Do I have to change anything regarding PSRAM in the sdkconfig?
@@S0urceC0de If the sdkconfig is modified, it takes time because the entire code is rebuilt. It's normal, so don't worry.
According to your logs, it doesn't seem particularly related to PSRAM. It has to be something different depending on how the memory is allocated, but it gives the same error. Were there any other errors prior to the PSRAM error?
@@ThatProject No there are no errors at all. I dont know which PSRAM error you refer to; that is the problem: There is no error message or anything the like, it just freezes. I have ordered a different board with more PSRAM from a different manufacturer. I will check if that works. Thanks for the help!
@@S0urceC0de I'll let you know after testing with the different board.
Hi, can you make a similar video but with USB uac for audio
Oh, that's an interesting suggestion. I'll take a look at it.
Please help! Can I use this scheme to connect some external camera that connects to my smartphone via otg?
Wow, that's a very tricky question. S2 supports OTG interface but not sure how to connect it while connecting external cameras at the same time. If I have a good approach, I'll show you.
it can be used with a usb video capture to make a stand alone ambilight?
It's possible, but with some difficulty. You need to extract the image color of a specific part from an image obtained from a USB camera.
It seems that you can apply the extracted image colors to the connected RGB LED Strip.
Can I used usb c of esp32 s3 instead usb data plus used for esp32 s2 ?
If your ESP board(S2/S3) has USB-OTG supported, you can use it without having DIY a cable.
Hey man, is it possible to capture an image to upload GoogleDrive or something?
Yes, it's possible to upload the captured image file to Google Drive. Please refer to this post.
create.arduino.cc/projecthub/phpoc_man/arduino-take-picture-upload-to-google-drive-2d1cd3
Also, You can make your own server to upload the captured image from your ESP32.
Hey thanks a lot! What's the VBUS pin on an AI thinker esp32 S2 ?
It's powered via VBUS from your USB connection. Which model do you have?
@@ThatProject ok so I just use 5v pin?
it's an AI thinker s2
@@DH-ls9qv Yes just use 5v to power the USB device.
@@ThatProject cool thanks man!
should i getting S2 or S3? what the difference for UVC demo?
For using a USB camera, you should use S2 or S3.
How to set maximum resolution of our usb camera ?
i try resolution like 320*480 and 640*480 , 1280*720, but video quality still same nothing difference ?
This is all about Descriptor. In order to set your parameters to work, you need to get the correct parameters from the descriptor you get from the camera.
It Will work also whit ESP devkitu1?
Also can you Just skip the varius usb adapter and expose the wire in the usb cable and connect them at the pin?
Are you saying ESP Devkit v1? Unfortunately, it works only S2/S3 which has the native USB interface. You can skip the adapter and wire them directly.
@@ThatProject a tanks.
Btw what if you use an Arduino to act like a bridge?
Or use a bluetooth camera whit the esp?
How to observe it online. I want to make an online surveillance camera
A server is required to view online. How about using a WebSocket server? th-cam.com/video/CpIkG9N5-JM/w-d-xo.htmlsi=iSWHTNPgGeLiHTuL
Thanks, I tried with ESP32S3 it worked, how about get audio streaming.
Awesome!!!
@@ThatProjectdo you have tutorial about audio streaming from usb cam...
@@devamsol7879 Unfortunately, I don't have it yet...
This could be done by adding a microphone (savaged from an old notebook, for example) to the camera and using the ADC pin for sound reading. However, it depends on the processing capability of our development board. Thats just an idea!
If the procedure to do it in ESP32 S3 same as S2? Do you have any contact? ThankYou sir
Hello, is it possible to plug the camera to the usb-c default port of the board? thanks
No, I don't think so. If you do that, how will you supply the power to the board??
@@ThatProject through batteries?
@@faisalsaddique3323 As far as I know, to use a USB host, you need to use the external port which is not the main port.
does it work with an esp32 devkit?? Nice video bro
Unfortunately, only S2 or S3 with native USB is possible.
Any chances you can add HomeKit integration?
Many other people have already linked ESP32 with Homekit. When Apple officially supports Matter, I plan to use it for a project.
Can we use nudemcu esp8266 instead of esp32?
Unfortunately this only works with the ESP32-s2/s3 series.
I am trying to receive data from USB barcode reader (serial mode) but the example code (basic CDC) in "Espressif IOT" gives partition error. Board ESP32-S3-WROOM-1-N8, Environment ESP IDF. Will this setup work?
Your ESP32-S3-WROOM-1-N8 has no PSRAM. This project requires a minimum of 2MB of PSRAM.
@@ThatProject can an ESP32-S3-WROOM-1-N8 be configured to have PSRAM or do you recommend he get a different ESP32 type of board?
@@Cdswjp According to the official document, it requires at least 2MB of PSRAM. But I found that it supports NON-PSRAM boards after reviewing the code again. The problem is that I've never tried with the non-PSRAM board on my end. Please try it. I think this is worth a try
How do you use it with bluetooth only
for this project?
Hello sir would you please clarify me about "how to connect hard disk with esp 32 s2 for storing pics and vedio from esp32 s2 with camera setup"
I am waiting for your response 😊
The "hard disk" you said is your PC's hard disk? Or is it a hard disk directly connected to the ESP32?
@@ThatProject PC hard disk and not even know to how to connect with esp32:(
It just an idea to create vedio storage for this setup
@@jarvisN10280 As far as I know, there is no way to make a connection between your ESP32 and your PC hard disk directly. You need to send image data from ESP32 to your PC through WiFi or some other way.
Hello, I have the problem that I do not appear sdkconfig (3:50) on the edge what am I doing wrong?
Are you sure your ESP-IDF is installed from VS Code Extension?
@@ThatProject No i'm not sure, can you recommend a video or describe what i have to do?
hi, do you know what is this '"esp_idf_size [-h] [--format {text,csv,json}] [--archives] [--archive_details ARCHIVE_DETAILS] [--files] [--target TARGET] [--diff ANOTHER_MAP_FILE] [-o OUTPUT_FILE] map_file
esp_idf_size"?
I didn't know that so I googled. The esp-idf-size package is part of the ESP-IDF SDK for Espressif products and is automatically installed. It is responsible for analyzing firmware binary size of ESP-IDF projects.
Can we use es32 (if possible esp8266) to make my keyboard and mouse Bluetooth?
It just clicked so if you know please enlighten us all 😊
First, the ESP8266 doesn't have a BT module, so that's not possible.
th-cam.com/video/i4qrWbHXH3U/w-d-xo.html This video shows how to make a BT keyboard with ESP32. There is a BT keyboard & mouse for ESP32. Please check this out. github.com/T-vK/ESP32-BLE-Keyboard
@@ThatProject sorry I missed that Bluetooth part but can it work if I put eap8266 at sender's and receiver's end like one connect to keyboard and other to PC, would that need some kind of ESP-NOW connection if its too complicated just let me know it might work or not... Btw thank you for responding to your viewers :)
@@ThatProject just checked the video and i think its only for shortcut keys, i saw similar thing on Electronoob's channel but what if I take whole keyboard's input but just connecting 4 pins of usb to esp32 and send it to pc just like camera is connected in above video.
Does this need 5V or work off 3.3?
This should be 5v.
My usb camera is endoscopic and has no JPEG compression but has UVC parameters in it. I have no idea how to make it work with the parameters obtained with "lsusb -v".
I don't even know how to send it here, because the Camera Interface Association listing is very large
@@atamico That's the problem. Annoying but, you need to find out the working interface among the interface descriptors you have for your USB camera. That's all I did too.
@@ThatProject if something about the error that is returning in the serial monitor already help me:
E (2766) UVC_STREAM: Configuration descriptor larger than control transfer max length
W (3846) UVC_STREAM: line 677 Pipe: iso HCD_PIPE_EVENT_ERROR_OVERFLOW
Thanks!
Esp32 s2 (s3) has not classic BT. Is there a way to add external BT dongle (usb)?
Now i am using esp32 and ps3 controllrer, but i would like to try esp32-s3.
What about using HC-05 Bluetooth Module? I think you can easily connect it to your ESP32-s3.
@@ThatProject The HC-05 uses the Bluetooth Serial Port profile (SPP). The PS3(4) controller doesn't.
@@ThatProject In case of Arduino, as most people use, a USB Host shield with a Bluetooth dongle that can then be configured to communicate using the right profile. But esp32-s3 has usb.
I am just a beginner, so i can do mistakes))))))
@@olegl6339 Sorry, I don't know much about the PS controllers. ESP32-S3 has a native USB but I don't know how to connect the BT dongle here. I should try this first to find out how to do it. What I want to do is to use my BT mouse in S3 in my case. Anyway, I'll try a couple of ways and update you if I have a good one.
@@ThatProject it will be interesting.
don't waste your time usb_camera_wifi_transfer example that used uvc_stream doesn't work.After a few transmitted frames it returns W (80191) UVC_STREAM: line 378 HCD_PORT_EVENT_ERROR and the connection to the camera is terminated. After disconnect camera from usb and reconnect it again the result is a same as described above.
Hi, when I flash the program I get the following error:
E (2292) UVC_STREAM: urb data_buffer alloc failed
E (2297) UVC_STREAM: C:/Users/evaav/Desktop/TTGO_T8/esp-iot-solution-usb-add_usb_solutions/components/usb/uvc_stream/uvc_stream.c:1412 (_usb_processing_task):stream urb alloc failed
It's about the stream line, but i can't figure out how to solve it. Do you have any recommendations?
With this log, I'm not sure which part is a problem. Have you tried the native-USB port with your TTGO T8 before doing this project?
@@ThatProject Hi, thanks for answering me. I've previously tried another example from espressif (usb_cdc_basic) where i was able to get the interface descriptor of my webcam, which means that i was able to connect to the device. I'm using the same model of ESP32s2 as you, so i'm not really sure of what i'm doing wrong.
@@evaavilesalvarez5049 Then you have no problem connecting to the USB port, but it seems to be a problem with the connection to your USB camera.
#define NUM_ISOC_STREAM_URBS 4 //Number of isochronous stream URBS created for continuous enqueue
#define NUM_PACKETS_PER_URB_URB 5 //Number of packets in each isochronous stream URB
It looks like these two parameters are wrong, causing the issue, "urb data_buffer alloc failed". Please check this part again.
@@ThatProjectThanks! I was able to solve the problem modifying those parameters. I'm currently using other webcam where de max packet size is 800 bytes, so i'm trying to use the bulk transfer mode config. The problem is that i'm getting this warning:
W (3262) UVC_STREAM: bogus packet: actual_len=4, header_len=2
I've tried to modify the bulk parameters of the UVC stream in the SDK config, but nothing seems to work. What am i doing wrong?
@@evaavilesalvarez5049 Setting the maximum packet size to 512 or higher seems to cause problems. Is it currently set to 800bytes? Are there any smaller packet size options?
Hi sir, this repository has been deleted, can you give me a replacement? please.
It was merged into the main brunch. github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/uvc
Can I use USB 2.0 module instead of nagative USB?
I don't get it. What is the USB 2.0 module? Are you saying the built-in USB-UART?
@@ThatProject I mean Dip USB female
@@cherrylife389 Oh, I think you connect an external USB device with a USB OTG female port. Which model are you using?
Can we add 2 cameras, im trying to build a machine it will have 2 cameras and i need to control that through web
As far as I know, connecting two UVC devices at the same time is not yet supported.
@@ThatProject any other microcontroller which can do this? Because I need those two camera to display side by side to control my machine.
@@pocopoco3468 I've never seen an MCU that can connect more than two units via UVC. I think you need to use two microcontrollers or use an SBC.
@@ThatProject sbc mean a raspberry Pi like that?
@@pocopoco3468 Yes. Single-board computer.
Hello. Can you addd this codes in order to avoid the usage of usb breakout? i found it on the esp32-s3 forum. OTG should be able to provide 5v on the vbus usb connector. Thanks. Code :gpio_set_direction(12, GPIO_MODE_OUTPUT);
gpio_set_direction(13, GPIO_MODE_OUTPUT);
gpio_set_direction(17, GPIO_MODE_OUTPUT);
gpio_set_direction(18, GPIO_MODE_OUTPUT);
gpio_set_level(12, 1); // DEV_VBUS_EN
gpio_set_level(13, 0); // BOOST_EN
gpio_set_level(17, 1); // IDEV_LIMIT_EN
gpio_set_level(18, 1); // USB_SEL
Thank you for the good information. I'll try it.
@@ThatProject yeah. But i think works only for devkits because they have already 2 usbs built into the board. Im not sure if you have a small external USB C device to power, as i wanted to try to power an external midi controller (and convert the controller to wireless via BLE) with an s3 board, but looks like It will require a breakout as well😅
Hi , Great explanatory video covers alot of aspects.
I need to know something can esp32s3 support this camera "HOEUJIA Hidden Camera HD 1080P Mini Spy".
As far as I know, the camera you are talking about can only acquire images through a wifi connection. The USB port is for charging only. Therefore, connecting via UVC seems impossible. Please correct me if I’m wrong.
@@ThatProject yes you are right it is wireless, can we import frames from its stream into the esp32s3 for facial detection.
@@habibhussainhabib8971 Unless you have data from the device, I think it's almost impossible.
@@ThatProject Can't we import from the rstp stream if we have the link? I believe it can be done.
@@habibhussainhabib8971 If RTSP is available on this USB camera, you can use it. However, UVC cannot be used. It should only receive data through the USB interface.
Can I achieve this using a ESP 8266? Thank you
I want to send daily pictures by whatsapp of a plant
@@elderwoodstudio ESP8266 doesn't have a native USB Interface.
@@ThatProject so what can I do to achieve with ESP 8266?
@@elderwoodstudio Unfortunately, you don't have an option with ESP8266. Why don't you use ESP32-S2 or S3?
is it possible to take a photo and save in SD?
Captured image frames can be used as JPEG and saved to an SD card.
@@ThatProject Thanks for your reply! I am looking for the scenario that the device , esp32 i mean, connect to usb camera and take ONLY picture and send to the server. taking picture can trigger by http request, web socket or MQTT. I don't need live video streaming or video recording. only picture is necessary. I do appreciate if you do some project like this or direct me about this. / I learn a lot from your channel / Thanks
@@blogactivities5462 I'll try it when I get a chance. Thank you.
I have tried many, many cameras and found that if the camera was made by Logitech it is very likely to work (all Logitech UVC cameras I tested worked) at 800x600. Most other cameras do not work, or work at 320x240 or below, but possibly only once you disable some asserts, etc.
If anyone out there wants to do this, I suggest you grab a used old-ish but not too old Logitech camera. E.g. the c270n (still available new).
This is very good information. Thanks for sharing!
Relatedly, some sdkconfig changes that may be needed:
CONFIG_USB_HOST_HW_BUFFER_BIAS_IN=y (instead of CONFIG_USB_HOST_HW_BUFFER_BIAS_BALANCED)
CONFIG_USB_HOST_CONTROL_TRANSFER_MAX_SIZE=2048
(Can't remember if you covered these in your video)
@@snagrul I don't think this has been mentioned. I plan to redo this project as soon as the new camera is ready. Thank you for always.
Hi sir can this circuitry able for object detection in Arduino??
This simply streams video from a USB camera. To recognize objects, you need to use an image processing library such as OpenCV(th-cam.com/video/7qPIRBY6C8c/w-d-xo.htmlsi=U33SDJbLNhxEkq03) or a deep learning framework such as TensorFlow.
Hello sir!
Can u help me ?
How can I help you?
@@ThatProject How to set the resolution for live streaming for ili9488 lcd tft.pushimage() function
Mjpg live stream to sd card . how to do this ?
If I recall correctly, there was an example of that. Please check the UVC examples series.
@@ThatProject Thank you for response !
UVC examples series these are working fine . but this ''usb_camera _sd _card " Example code are saving the jpg images in sd card not full live streaming .But i wanna to save usb camera mjpg live streaming in sd card. how to do this?
@@followembedded1549I cannot find exactly what you want. Check this out. github.com/s60sc/ESP32-CAM_MJPEG2SD
@@ThatProject I am using usb camera with esp32s3 mcu . jpeg images sucessesfully store in sd card . but now i want to store usb camera live stream like video .mp4 format in sd card . on esp-ide
@@followembedded1549 I know, but it's not easy to find something that can help you directly.
hai can you help me, i got some error like cannot open file "freertos/freeRTOS.h"
freertos/freeRTOS.h is the one of core components of ESP-IDF. Please check if the ESP-IDF environment is properly configured.
¡Gracias!
Thank you!
thank you so much
This was helpful
But I have some questions
Is it possible to build a project based on api and flutter?
A request is sent to the camera to take a video or photo
Control the camera so that you can send video and photos
backend
thank you so much
This is possible through websockets. He has previous projects with cameras and websockets and you could connect your flutter app to send a command and receive a screenshot back.