This project builds a wearable, cloud connected camera. This is useful in situations where you want a record of what the camera sees stored in the cloud as quickly as possible. Make sure you use this in compliance will all applicable laws and privacy considerations.

This is video only, no audio. If you want to add audio, then I'd love a PR to add, or wait till I get a chance to add it.

This app requires a Raspberry Pi connected to a Raspberry Pi Camera and WiFi. It continuously records short videos from the camera (by default 10 seconds in length), and uploads these to Azure blob storage. The ideal setup is a Pi Zero W due to its small size and low power requirements, tethered to a mobile phone or hotspot for internet access.

This uses a cloud service to store the videos, and therefor may incur a cost. If you have a free trial account, you can get $200 for the first 30 days which should more than cover the cost. Check out the Blob storage pricing guide for more information on the cost of the service used.

This method allow resiliency - if WiFi connection is lost the upload will keep retrying. If the device is damaged then everything already uploaded will be secure. Files are stored on the SD card and only deleted after successfully being uploaded, so if there is no internet connection, files can be grabbed off the SD card.

This also allows audit trails - each short video is named with the current timestamp, and Blob storage stores the time the file was uploaded.

The code for the project also includes a utility to download all the blobs and concatenate them into a single video file.

You can find all the code on GitHub at https://github.com/jimbobbennett/pi-hat-cam.

What's required

To make this, you will need:

  • A Raspberry Pi Zero W (must be the W with WiFi access)
  • A Raspberry Pi camera module and appropriate ribbon cable that is as long as possible. The V2 camera is the best as it is small with good quality. The HQ camera can be used but is bigger which makes it harder to mount on clothing.
  • An SD Card
  • A USB power pack and appropriate cable to power the Pi
  • A mobile phone or hotspot to tether to
  • A hat or other piece of clothing
  • Sewing materials, duct tape, bits of cloth to help affix the camera and Pi to your clothes

Set up the application

Before you can run the application, you need an Azure subscription and a storage account.

Set up your Azure Subscription

  • If you are a student aged 18 and up and have an email address from an academic institution, you can sign up for the free Azure for Students offer at azure.microsoft.com/free/students without a credit card. At the time of writing this gives you $100 of credit to use over 12 months, as well as free tiers of a number of services for that 12 months. At the end of the 12 months, if you are still a student you can renew and get another $100 in credit and 12 months of free services.
  • If you are not a student, you can sign up at azure.microsoft.com/free. You will need a credit card for verification purposes only, you will not be billed unless you decide to upgrade your account to a paid offering. At the time of writing the free account will give you US$200 of free credit to spend on what you like in the first 30 days, 12 months of free services, plus a load of services that have tiers that are always free.

Set up the storage account

An Azure storage account is a general purpose account to store data as files, queues, tables or blobs. In this app, each short video is stored as a blob in the storage account.

To create a storage account:

  1. Head to ms.portal.azure.com/#create/Microsoft.StorageAccount-ARM to go straight to the create a new storage resource blade
  2. Sign in with your Azure account if necessary
  3. Select your Azure subscription
  4. For the Resource group, select Create new. Name the resource group hatcam then select OK

    Creating a new resource group

  5. Name the storage account. This name has to be globally unique across all storage accounts...
Read more »