Building on my previous IoT presentation I thought that I would follow up with two additional project which were in a similar vein.
These project both relate to IoT but focus more around the subject of streaming data rather than poling a sensor for a value.
Raspberry Pi-based IP camera
I built this device as the result of finding the existing market of IP cameras to be lacklustre at best. The more options which provided the feature I was looking for were too expensive, and the ones in a more reasonable price range had terrible image quality and next to no feature. So naturally I decided that a Raspberry Pi could be used to build my own.
The hardware for this project consisted of:
- Raspberry Pi model A+
- Raspberry Pi Camera Module
- Loblaws plastic container
- USB cable
- Small power cube
The total cost of this build two years ago came out to around $75. This could probably be reduced significantly (to around $30) if you get a cheap Pi Zero.
I have tested two different Software solutions for this IP camera project. With the Pi running linux it would also be possible to use existing linux tools to build your own solution.
RPi Cam Web Interface
This software is a tool that you install onto an existing Raspbian installation. It has been designed to be used with the Raspberry Pi Camera Module and supports a wide range of functionality like images and video streaming, timelapses, and motion-sensing. The primary advantage of RPi Cam Web Interface is that it is lightweight, which is an advantage when you are trying to run it on a less powerful version of the Pi. Due to the lightweight nature of the solution it also meant that I was able to stream a higher resolution image than the alternative.
While this seems like it would be perfect for the project I am trying to put together it had two flaws.
The first was that the streaming in the browser was limited to a preview of the stream, and not something that was available fullscreen. The streaming was intended to be done to a network location. This was less than ideal as I had hoped to do a majority of my viewing in a web browser.
The second issue was that the software tented to be quite unreliable. The camera would drop off the network frequently The setup I had configured the Pi in had it running on Wifi hanging in a window. This meant that is was less than ideal if I need to troubleshoot any issues. As a result I ended up discarding this solution in favour of the second option. That being said, should stability and streaming improve I would definitely consider moving back.
motionEyeOS is a pre-configured linux distribution designed for single board computers (like the Raspberry Pi). This operating system uses a motion backend, and motionEye frontend to turn your Pi into a surveillance station.
This operating system provides a wide range of standard functionality like images and video streaming, time-lapses, and motion-sensing just like RPi Cam Web Interface. It also provides many advanced features like Multi-camera, multi-device, centralised server implementations, Samba, SSH, FTP stream saving, and Fast network camera option (using MJPEG) for lower power Raspberry Pi’s. motionEyeOS also provides a direct feed of the camera in the browser.
With all this added functionality though, comes additional overhead. motionEyeOS functions best of a Raspberry Pi 2 or 3. There are significant trade-offs in frame rate from running this software on an older or less powerful Pi.
Additionally, I found this software to be more than RPi Cam Web Interface which meant that at the end of the day a reduced framerate was worth the network consistency.
Pi IP Camera Considerations
There are a few point to consider, in general, when it comes to building your own IP camera’s.
If you are planning on placing the device someone with tough environments then the added cost of building a solid case might not be worth the time or money, especially if what you build doesn’t work.
With the nature of the Pi model A+ having no Ethernet (and the project being over wifi and in a case) you will need to have either another Pi or a USB hub and peripherals available when you are setting it up.
I have yet to experiment with overclocking the Pi foe this specific project. Overclocking paired with a better power supply (wouldn’t have fit in the case) might make the model A+ perform better.
One main advantage of devices like the Nest Camera is that it comes with the ability to stream it to the web. That is a lot more complex with a home project, especially when you don’t want to port forward through your router.
Finally, throughout building your own IP Security Camera setup you should always consider whether you should “just buy a CCTV system”.
Software Defined Radios
These devices have the ability to tune to a wide range of frequencies without changing the hardware. Through the availability of software decoding that supports a wide range of modulation techniques, and cheap integrated circuits making devices affordable, and you have a powerful combination.
The inspiration for this project came from a web stream of an SDR I saw online a few years ago. When I looked into SDRs more recently again I wanted to see what was being broadcast, and had a spare Pi to try it out on.
The RTL2832U SDR I am using I bought for cheap on aliexpress for $10 each. They use an MCX connector, come with a shitty antenna, and should probably be used with a powered USB hub. Throw away the remote and CD.
It is worth noting that you will need to buy/build a better antenna if you want to receive anything of note with this system. I have not yet, but would like to, explore filters and amplifiers to further increase what I am able to receive.
The primary software used for this project is rtl-sdr, which bills itself as being a “cheap software defined radio that uses a DVB-T TV tuner dongle based on the RTL2832U chipset”
Software defined radios have a wide range of used such as listening to FM/AM radio, ATC, Fire/Police, and Marine Radio. A”Full” list of use cases is available from rtl-sdr.
The specific component of rtl-sdr that I am using is rtl_tcp. This program allows you to stream incoming data from the radio over network. You can also tune the radio (and adjust other settings) remotely.
This means that I can place the SDR in some remote location with better reception and connect to the device from the comfort of my desk.
To manage running the rtl_tcp application at boot, and make sure the service stays online I a using Upstart.
In order to connect to the device you need a program to receive and decode the data. I have used SDR# and GQRX, but there are other options out there.
A full installation guide, along with code examples, for this project can be found on Github.