motioneye-project / motioneye

A web frontend for the motion daemon.
GNU General Public License v3.0
3.96k stars 650 forks source link

Migrate from RPi3 to RPi zero #1269

Open egrp opened 5 years ago

egrp commented 5 years ago

I have installed MotionEye on a Pi3, using the latest Jessie and MoionEye software (Not MotioEyeOs as i could not get my scavenged laptop camera to work with MotioEyeOS). Everything works on a Pi3, i tried to move everything to a Pi ZeroW and I get no video feed. Do i need a different version to install on the Pi Zero? (I have not yet been able to get this camera to work).

I did have 3 Pi Zero W's with actual USB cameras that i took on vacation and everything worked great. I am trying to make the package slimmer, and i have a few laptop cameras on hand. I was able to get everything working on the Pi3, but using the same install methods, i get no video stream on the Pi Zero, I know this has to be something i have missed, but i am not able to get this to work.

Any advice / direction would be most appreciated.

Thank you in advance

CRImier commented 5 years ago

Do you get any error messages? If launching through a systemctl unit (very likely if you followed the official install instructions), use sudo journalctl -fu motioneye to see the output (and any related error messages) in realtime. Also, is the camera actually detected as a USB device? If using repurposed laptop cameras, you might want to power them from 3.3V and not 5V, quite a bit of those cameras don't like 5V.

egrp commented 5 years ago

Ok.. Been doing a bit more working with this.. I have installed MotionEye on the Raspberry Pi Zero W. I connect a Logitec WebCam to it (to verify that everything is actually functioning and I see images and can run this as expected. When I connect the laptop camera to it, i get no image and sudo journalctl -fu motioneye shows an error that device does not support capturing. I have tried 5v fro the USB port as well as 3v from pin 1.

I removed the SDCard from the Pi Zero and put it into a 3b, connected the laptop camera to a usb port brought it up and it is seen as a Toshiba camera and it all works as expected. the only difference in this scenario is the PI itself. Does anyone know the differences between the Pi zero and the Pi 3b usb ports that may account for this?

CRImier commented 5 years ago

There are some differences, but they're minor. Have you tried using a USB hub between the Pi Zero and the camera? That should rule out some of the differences.

egrp commented 5 years ago

I have not yet tried that.. I am hoping to keep the footprint as small as possible so i can put the Pi Zero and the camera in one enclosure. I will give that a shot to see what happens. Thank you.

CRImier commented 5 years ago

It's not about the footprint, I'm suggesting it purely for testing purposes.

egrp commented 5 years ago

well that did the trick. I connected a powered usb hub to the Pi zero and the camera showed up and worked. The initial thought from this was that i was under powering the Pi (using a 1 amp power source), but i used the same power source for the hub (the pi got power from that hub through the usb/data port).

I used a 2 amp power source for the Pi and connected the camera direct. So you are correct in that going through a hub made it work. I am not sure at all which direction to go here.. I will try a different Pi zero and a different camera to see if i get different results, i am just not sure where the problem is at this point.

Thank you for your assistance and patience..

egrp commented 5 years ago

Ok.. That made it work.,. I connected to a powered hub (the pi now gets it power from the Hub connection). That camera shows up and works. The initial thought was that the pi was under powered with a 1 amp power source, but i was using the same source as before. I changed to a 2.1 amp power source and connected just the camera and power (no hub) and it still failed) Not sure where to look next, but i will try a different pi z and a different camera to see if the results change.

Thank you for your assistance and patience with this.

egrp commented 5 years ago

I tried a different pi z and a different camera (same model).. Same issue.. It worked with a powered hub, but not connected to the Pi Z. Thinking this may be power related (to the ports on the Pi), i spliced the camera wires into a different USB cable that i can connect to the data usb port. Still the same issue.

CRImier commented 5 years ago

Please try adding dtoverlay=dwc-otg in your /boot/config.txt and rebooting, it will use a different USB driver, which may resolve the issue. The difference between the Pi Zero and the Pi3 when it comes to USB ports is: 1) On Pi3, there's a USB hub between the BCM2837 USB port and the 4x USB ports 2) Pi3 uses the dwc-otg (USB host-only) driver by default, whereas IIRC Pi Zero uses the dwc2 driver (USB host and device, distinguished by the OTG pin, if I'm not mistaken) by default. The drivers are somewhat different, and using different drivers might result in different performance. Also, I've heard something about USB 1.1-only devices not being supported on the Pi... Your camera is unlikely to be such a device, but who knows, that's likely the next debugging step we could go through.

egrp commented 5 years ago

I added dtoverlay=dwc-otg to the config .txt file, that did not make a difference.. If it makes any sense at all.. I get 3 bcm2835-codec options when i try to add a camera (none of them seem to work.

CRImier commented 5 years ago

I don't quite know what you mean by the bcm2835-codec options, can you elaborate/send a screenshot? Also, what's the VID&PID of your laptop camera, maybe you can give a photo or two? I might be able to find a similar camera.

CRImier commented 5 years ago

You can get the VID&PID using lsusb - in fact, you can just paste your output here, don't forget to use code block formatting.

CRImier commented 5 years ago

My suggestion is - take a Pi Zero, connect that laptop camera, try to make motioneye work, then execute this: dmesg > pizero-direct.dmesg. This will create a file with full dmesg output, you can use pastebinit pizero-direct.dmesg (sudo apt install pastebinit to install) to upload it to a pastebin service, then share the link here. After you have uploaded it and saved the link, connect the camera to the Pi3, try to make it work there, then use dmesg > pi3-hub.dmesg and pastebinit pi3-hub.dmesg to get a link you can share with us.

Bonus points - take a Pi Zero with the USB camera and a USB hub in between (the configuration that works) and use dmesg > pizero-hub.dmesg and pastebinit pizero-hub.dmesg.

egrp commented 5 years ago

here is a snip of when i try to add a camera with the laptop camera connected directly to the pi zero w I get a drop down with 3 of these listed (i cannot make my laptop get a grab of the extended menu Capture

this is all that shows with an lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

i am working to get the pi with the powered hub and camera back online now

CRImier commented 5 years ago

lsusb does not show your camera. Are the connections alright? What does lsusb on the Pi3 say when the camera is connected?

egrp commented 5 years ago

I am right now trying to get the camera back up and running, when i reconnected it, it no longer worked.

egrp commented 5 years ago

ok.. I have been able to get the camera to work again in windows (my raspberry units are at the house).. Here is the reported vid/pid from a windows laptop

vid-pid

i will try again to get this to work (as it did once) with the powered usb hub, and post the results

egrp commented 5 years ago

just for fun.. here is a pic of the front and back of the cameras i am trying.. I am also looking for a way to drop the voltage to 3.3 (they are running a bit warm connected straight to a usb port). campic1 campic2

egrp commented 5 years ago

Also. I REALLY appreciate all of the assistance here.

egrp commented 5 years ago

finally, got it to work again with the powered hub and motioneye here is the pastebin link http://paste.debian.net/1084331/

CRImier commented 5 years ago

Right, it's recognized as a USB device. What happens if you plug the same camera without the hub? Can you provide dmesg in that case?

You can take 3.3V from the Raspberry Pi GPIO header - Pin 1 has 3.3V and can provide enough current for your camera. However, you will need to take a separate wire to the GPIO header from yur USB plug - in your case, a piece of wire with a female header will likely work very well (so you can plug the header onto the GPIO header). Here's an illustration, though I use a piece of wire with a male header since I get 3.3V from a female pin header:

camera VCC pin connected to ZeroPhone 3.3V pin

Make sure to disconnect the VCC from 5V before you connect 3.3V =)

BTW, I just wrote a small "guidelines" page on reusing the laptop cameras. I used a part of your photo there, hope you don't mind =)

egrp commented 5 years ago

When i connect the camera direct to the pi, it does not get recognized by motioneye. I will reconnect it tonight and get a dmesg output from it. I will also tried to connect it to the 3v pin with the same results. i will either make an adapter with 2 diodes in the power line, or i will make an adapter to use the 3v line from the gpio as a test unit. As soon as i get more data, i will post it here.,

Thank you again for the help and no, i do not mind at all that you used the pic in your directions, i only wish i had found them when i started this little trip, it would have saved me lots of time..

CRImier commented 5 years ago

I just wrote these directions, they didn't exist when you started =) Please do send the dmesg output, it will be very interesting to look at.

egrp commented 5 years ago

so.. as soon as I connected the camera to the 3.3v pin, powered it up.. now it shows up.. go figure... here is the dmesg link for the direct connect camera http://paste.debian.net/1084898/

now all i need to do is make an adapter for the usb plug to drop it to 3.3 and print a case.. 0 getting there... step by agonizing step :)

CRImier commented 5 years ago

Looking good! I'm compiling a small database of reuse-able laptop cameras, could you please send me the output of the following commands? lsusb v4l2-ctl --all v4l2-ctl --list-formats-ext

egrp commented 5 years ago

pi@raspberrypi:~ $ lsusb Bus 001 Device 002: ID 04f2:b3b2 Chicony Electronics Co., Ltd Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

egrp commented 5 years ago

pi@raspberrypi:~ $ v4l2-ctl --list-formats-ext ioctl: VIDIOC_ENUM_FMT Index : 0 Type : Video Capture Pixel Format: 'YUYV' Name : YUYV 4:2:2 Size: Discrete 640x480 Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.067s (15.000 fps) Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.067s (15.000 fps) Size: Discrete 320x240 Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.067s (15.000 fps) Size: Discrete 320x180 Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.067s (15.000 fps) Size: Discrete 424x240 Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.067s (15.000 fps) Size: Discrete 640x360 Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.067s (15.000 fps) Size: Discrete 848x480 Interval: Discrete 0.067s (15.000 fps) Size: Discrete 960x540 Interval: Discrete 0.133s (7.500 fps) Size: Discrete 1280x720 Interval: Discrete 0.133s (7.500 fps) Size: Discrete 1920x1080 Interval: Discrete 0.200s (5.000 fps) Size: Discrete 640x480 Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.067s (15.000 fps) Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.067s (15.000 fps)

    Index       : 1
    Type        : Video Capture
    Pixel Format: 'MJPG' (compressed)
    Name        : Motion-JPEG
            Size: Discrete 640x480
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
            Size: Discrete 320x240
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
            Size: Discrete 320x180
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
            Size: Discrete 424x240
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
            Size: Discrete 640x360
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
            Size: Discrete 848x480
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
            Size: Discrete 960x540
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
            Size: Discrete 1280x720
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
            Size: Discrete 1920x1080
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
            Size: Discrete 640x480
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.067s (15.000 fps)
egrp commented 5 years ago

pi@raspberrypi:~ $ v4l2-ctl --all Driver Info (not using libv4l2): Driver name : uvcvideo Card type : TOSHIBA Web Camera - FHD: TOSHI Bus info : usb-20980000.usb-1 Driver version: 4.19.42 Capabilities : 0x84A00001 Video Capture Streaming Extended Pix Format Device Capabilities Device Caps : 0x04200001 Video Capture Streaming Extended Pix Format Priority: 2 Video input : 0 (Camera 1: ok) Format Video Capture: Width/Height : 320/240 Pixel Format : 'MJPG' Field : None Bytes per Line : 0 Size Image : 153600 Colorspace : sRGB Transfer Function : Default YCbCr/HSV Encoding: Default Quantization : Default Flags : Crop Capability Video Capture: Bounds : Left 0, Top 0, Width 320, Height 240 Default : Left 0, Top 0, Width 320, Height 240 Pixel Aspect: 1/1 Selection: crop_default, Left 0, Top 0, Width 320, Height 240 Selection: crop_bounds, Left 0, Top 0, Width 320, Height 240 Streaming Parameters Video Capture: Capabilities : timeperframe Frames per second: 30.000 (30/1) Read buffers : 0 brightness (int) : min=0 max=100 step=1 default=-8193 value=50 contrast (int) : min=0 max=100 step=1 default=57343 value=32 saturation (int) : min=0 max=100 step=1 default=57343 value=32 hue (int) : min=-4 max=4 step=1 default=-8193 value=0 white_balance_temperature_auto (bool) : default=1 value=1 gamma (int) : min=1 max=16 step=1 default=57343 value=8 power_line_frequency (menu) : min=0 max=2 default=1 value=1 white_balance_temperature (int) : min=2800 max=6500 step=10 default=61432 value=5000 flags=inactive sharpness (int) : min=0 max=20 step=1 default=57343 value=4 backlight_compensation (int) : min=0 max=1 step=1 default=57343 value=0 exposure_auto_priority (bool) : default=0 value=1 pi@raspberrypi:~ $

CRImier commented 5 years ago

Thank you, will add it to the database! Can consider this issue closed?

egrp commented 5 years ago

I also did what all good troubleshooters do... I reconnected the wires straight to the usb plug and tried again.. Yep... it failed to connect

so I put the wire back in place to the 3.3v pin and back it came alive, so it is in fact not happy with running the camera at 5 volts.

now to design and make the usb plug with the 2 diodes out to the camera and see where we go from there.

egrp commented 5 years ago

Sorry.. Yes, this issue can be considered Closed, with my gratitude!

Thank you

CRImier commented 5 years ago

Happy to help!