User avatar
HermannSW
Posts: 4945
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Pi Zero works with 3 USB cameras and ethernet

Mon Sep 26, 2016 6:17 pm

I tried cheap 3-port USB hubs with RJ45 before, but they did not work.
RJ45 did work, but Pi Zero froze when connecting something to USB.

Then I did read "We've tested heaps of these adapters and this one is by far the best!" on pimoroni.com (where I bought two of my 4 Pi Zeros) for their "Three Port USB Hub with Ethernet - microB connector":
https://shop.pimoroni.com/products/thre ... -connector

Although that one costed £10 plus £4 shipping I did buy it, it arrived 5 days after shipping (over the weekend) and just works. I did connect 3 cheap 2$ USB cameras (a fake 5M camera, but really good 0.3M, see report) to it and ethernet:
Image

After identifying the Pi Zero IP address with "nmap -sn 192.168.178.1/24" I did "ssh -X pi@192.168.178.124" with X11 forwarding. Started "eog X.jpg &" with X in {4,5,6} to view the image taken by the USB camera "/dev/videoY" with Y in {0,1,2}. The images get shown on Laptop by X11 forwarding and get updated when new picture gets taken by "fswebcam -d /dev/videoY -r 320x240 X.jpg". The photos of the cameras do show the other camera(s) [right click for bigger screenshot]:
Image

Summary:
£14 is not cheap, but a good price for quick delivery and working well.

Hermann.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4945
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Pi Zero works with 3 USB cameras and ethernet

Mon Sep 26, 2016 7:10 pm

I remembered on how to connect to Pi Zero via UART:
viewtopic.php?p=1021437#p1021437

So this is a method to use a single USB camera with Pi Zero and control it over UART:
Image

This time I had to select 38400 speed in minicom, then it worked perfectly:

Code: Select all

[  297.110134][  297.320975] usb 1-1: Product: USB2.0 PC CAMERA                               
[  297.320990] usb 1-1: Manufacturer: Generic                                   
[  297.394042] media: Linux media interface: v0.10                              
[  297.420642] Linux video capture interface: v2.00                             
[  297.463119] uvcvideo: Found UVC 1.00 device USB2.0 PC CAMERA (1908:2311)     
[  297.465764] input: USB2.0 PC CAMERA as /devices/platform/soc/20980000.usb/us0
[  297.468396] usbcore: registered new interface driver uvcvideo                
[  297.468423] USB Video Class driver (1.1.1)                                   
pi@raspberrypi01:~$ fswebcam 7.jpg                                              
--- Opening /dev/video0...                                                      
Trying source module v4l2...                                                    
/dev/video0 opened.                                                             
No input was specified, using the first.                                        
Adjusting resolution from 384x288 to 352x288.                                   
--- Capturing frame...                                                          
Captured frame in 0.00 seconds.                                                 
--- Processing captured image...                                                
Writing JPEG image to '7.jpg'.                                                  
pi@raspberrypi01:~$ 
Now the problem is how to the taken photo off the Pi Zero over the UART connection.
I know an answer is to use PPP over minicom, have not tried that yet:
https://www.ibiblio.org/pub/packages/in ... er-minicom

Hermann.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4945
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Pi Zero works with 3 USB cameras and ethernet

Mon Sep 26, 2016 10:56 pm

I did this with UART connection, but it is the same with three port USB plus ethernet hub.

I connected an ili9341 320x240 LCD to above setup.
Then I did hold the camera high above the scene and took this 320x240 photo and displayed it on the LCD:
Image

This is higher resolution photo, right click to see more details:
Image

Here are the steps I did:
1) Take the photo:

Code: Select all

pi@raspberrypi01:~$ fswebcam --png 0 -r 320x240 7.png
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
--- Capturing frame...
Captured frame in 0.00 seconds.
--- Processing captured image...
Setting output format to PNG, quality 0
Writing PNG image to '7.png'.
pi@raspberrypi01:~$ 
2) convert .png to raw rgb565 image format of framebuffer

Code: Select all

pi@raspberrypi01:~$ avconv -vcodec png -i 7.png -vcodec rawvideo -f rawvideo -pi
x_fmt rgb565 7.raw
avconv version 11.7-6:11.7-1~deb8u1+rpi1, Copyright (c) 2000-2016 the Libav deve
lopers
  built on Jun 17 2016 02:13:49 with gcc 4.9.2 (Raspbian 4.9.2-10)
Input #0, image2, from '7.png':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: png, rgb24, 320x240, 25 tbn
File '7.raw' already exists. Overwrite ? [y/N] y                                
Output #0, rawvideo, to '7.raw':                                                
  Metadata:                                                                     
    encoder         : Lavf56.1.0                                                
    Stream #0.0: Video: rawvideo, rgb565le, 320x240, q=2-31, 200 kb/s, 25 tbn, 2
5 tbc                                                                           
    Metadata:                                                                   
      encoder         : Lavc56.1.0 rawvideo                                     
Stream mapping:                                                                 
  Stream #0:0 -> #0:0 (png (native) -> rawvideo (native))                       
Press ctrl-c to stop encoding                                                   
frame=    1 fps=  0 q=0.0 Lsize=     150kB time=10000000000.00 bitrate=   0.0kbi
ts/s                                                                            
video:150kB audio:0kB other streams:0kB global headers:0kB muxing overhead: 0.00
0000%                                                                           
pi@raspberrypi01:~$ 
3) activate framebuffer (needed once only)

Code: Select all

pi@raspberrypi01:~$ sudo modprobe fbtft_device name=rpi-display gpios=reset:23,d
c:24,led:18 rotate=90                                                           
pi@raspberrypi01:~$
4) copy raw image to framebuffer for displaying

Code: Select all

pi@raspberrypi01:~$ cat 7.raw > /dev/fb1                                        
pi@raspberrypi01:~$ 
Hermann.

P.S: Instead of micro USB to USB cable a 0.31$ OTG converter could be used as well:
https://www.aliexpress.com/item/Android ... 37793.html
Image
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4945
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Pi Zero works with 3 USB cameras and ethernet

Sat Nov 04, 2017 3:40 pm

I used the Pimoroni "Three Port USB Hub with Ethernet - microB connector" for more than a year now without any issues. Only today after having installed a new cable modem I realized that it allows for 10/100Mbps. This is from laptop:
Image

I used same ethernet cable with Pi Zero, and same speedtest-cli:

Code: Select all

pi@raspberrypi:~ $ speedtest-cli 
Retrieving speedtest.net configuration...
Testing from Kabel BW (46.223.20.147)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by PfalzKom (Ludwigshafen) [20.29 km]: 35.818 ms
Testing download speed................................................................................
Download: 64.66 Mbit/s
Testing upload speed....................................................................................................
Upload: 19.62 Mbit/s
pi@raspberrypi:~ $ 
Anyway, 64Mbps sounds like a nice value for Pi Zero.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Return to “General discussion”