NestCam - how to


How To

This camera uses Power over Ethernet so that you can have a very long power cable that doesn't weigh too much. You could of course use a mains cable, but with PoE you have the option of plugging it into a modem at the mains, or (as I did) use a mobile data dongle and only need a mains supply into the PoE.

The Pi needs a PoE Hat, get one with a fan. I used a larger enclosure than needed too, to try to help with cooling.

Drill a hole for the camera and one on the other side for the cable entry. Then cover this hole with plastic, strongly glued (I used epoxy resin), creating a window for the camera to look out of. The Ethernet Cable will fit through a cable gland size PG7 or M12.

Techincally a 30W PoE injector should work, but it didn't. 60W is fine, but you can't power the Pi and also a USB 4G wifi modem (such as Huawei E5330, which would have been perfect) from the pi as well, so I used a Huawei E3372 with an unlimited data SIM from Vodafone. This worked great, as we have good Vodafone 4G reception here. Your other option is to plug a 4G router with an ethernet port (such as TP-Link Archer modems) into the PoE injector at the mains.

With a USB modem, you won't be able to connect to the Pi over SSH or VNC on the same network from your computer or phone, which is really important to check for any problems and to safely shut down the Pi if you need to. So I set up to access the Pi over the internet.

This shows the picam complete, but the router is plugged into the PoE injector rather than using a USB 4g modem directly in the pi.

For the streaming itself, you need Restreamer which runs in Docker. Nestbox Tech has a brilliant guide to setting up docker on the Pi and getting started with Restreamer - it's a lot easier than I thought it would be, and it's easy to find help on Restreamer's github page.

Youtube turned out to be a poor way to stream this. Every new stream on Youtube gets a different URL, so it's difficult to embed or point people at a live stream that regularly stops and starts. So instead, I used Twitch, this is a streaming service aimed at gamers, but is very easy to embed with a simple iFrame or just create a channel on Twitch itself.

You can then set up a Docker command that runs Restreamer and your stream, and add it to a Crontab job to run every day. To run automatically without having to start and stop the stream on Restreamer's web gui, use the environment variable RS_INPUTSTREAM and RS_OUTPUTSTREAM. For example, this is the line I use to start my stream each day:

docker run -d --restart always --name restreamer
-e "RS_USERNAME=user" -e "RS_PASSWORD=password"
-p 8080:8080 -e "RS_INPUTSTREAM=rtmp://"
-e "RS_OUTPUTSTREAM=rtmp://[streamkey]"
-v /opt/vc:/opt/vc --privileged datarhei/restreamer-armv7l:latest

Data and mobile signal - Start with a low bitrate and increase it until you have a good pay off between a smooth stream, and one where you can actually make out what the image is. In my example above, the RS_RASPICAM_BITRATE is 6400000, or 640 kbps. 640 kbps = 0.288 gb per hour, or 3.5gb for a 12 hour stream.