Blog

10 Minute secure webcam with RaspberryPi and Remote.it

April 10, 2023

Getting Started: Secure Webcam with Raspberry Pi

The purpose of this guide is for the novice and advanced Raspberry Pi user to set up a camera with useful software for the first time. Then hosting your own secure webcam with remote.it that can be accessed from desktops, mobile devices and the web over ANY internet connection. This is all done for free without needing to buy domains, forward ports in your router or setup a vpn. Your webcam will only be available to you and those who you explicitly share it with.

If you have already installed an operating system and connected to the internet with your pi you can jump to “Boot Pi and Enable Camera“:

A user of this guide should be comfortable with using the terminal and ssh.

Needed Materials:

  • Raspberry Pi
  • Raspberry Pi Camera
  • MicroSD Card + Reader
  • Raspberry Pi Power Supply
  • Raspberry Pi case + camera case (optional)
  • Terminal Software (putty for windows, terminal for Mac/Linux)
  • This project is a great way to get started with a RasperberryPi and a dedicated camera. With the added benefit of securing your camera and Pi against hackers while making it accessible to you (and who you decide to share it with) over the internet.

    It’s the dream– a cheap, private and quick webcam over the internet!

    Step 1: Installing the Camera to your Raspberry Pi

    Lift up on both sides of the black tab – it will not come off completely.

    Insert the ribbon cable and push down on the black tab to secure

    Make sure the ribbon is facing the correct direction based on the images above.

    Create remoteit Account

    https://app.remote.it/

    Sign up for free to get started! Connect to any of your devices in a simple secure way from and to any network.

    Download desktop and mobile apps

    Desktop Downloads

    Step 2: Prepare OS for the Pi

    Write image to SD Card

    Download and install Raspberry Pi imager

    Select the desired OS – the current selections differ on whether or not they contain a graphical desktop. We’re going with the standard 32bit OS with GUI

    Write the file to disk and wait for it to complete. It will automatically eject, unplug and plug back into your computer

    Turn on ssh, wifi prior to boot

    If you have a Raspberry Pi with wifi built in. Otherwise Jump to SSH

    Make a text file called wpa_supplicant.conf which allows your pi to immediately connect to wifi on boot. Replace the text below with your wifi credentials. You can add as many network configurations you need by duplicating the network section below.

    Copy the file to the main directory on the Boot drive.

    If you need to change your wifi after booting from the terminal its recommended you use sudo raspi-config -> system options -> Wireless Lan and enter the network name and password

    country=US
    ctrl_interface=DIR=/var/run/wpa_supplicant
    GROUP=netdev
    update_config=1

    network={
    ssid="Your network name"
    psk="Password for network"
    }

    Allow SSH on Boot

    create an empty file called ssh or ssh.txt. Copy the file to the main directory on the Boot drive.

    This just starts SSH on first boot for easy access

    Eject your SD card

    Step 3: Boot Pi and Enable Camera

    Install your SD card and connect the power cable to boot your Raspberry Pi.

    local connection to Pi

    You have multiple options to connect –

    Option 1: You can plug in a HDMI cable from your pi to a monitor and connect a keyboard/mouse. This route will allow you to view the desktop. Open the terminal to complete these rest of this guide.

    Option 2: You can SSH to the pi from your computer.This logs you directly into the terminal where you will complete the guide.From the terminal or command prompt confirm it has connected to your local network.

    This thread gives additional options https://raspberrypi.stackexchange.com/questions/13936/find-raspberry-pi-address-on-local-network

    ping raspberrypi

    connect to it with the below and default password raspberry if you haven’t changed it yet

    ssh pi@raspberrypi

    Step 4: Enable Camera Access

    Let’s enter into the configuration to complete the device setup. Exit and reboot when complete.

    sudo raspi-config

    Required Configuration

    Enable Camera – Select Option Interfacing Options, then Camera, then Yes

    Recommended Configurations

    Change Password – Select System Options, then Password, change your password from the default

    Change Computer Name – Select System Options, then Hostname, set to a unique name to make your device easier to find

    Exit, Reboot your Pi and reconnect in a minute if using the terminal.

    ssh pi@NewHostNameif you changed the hostname reconnect with the new name

    Step 5: Install remoteit device package and register the Raspberry Pi

    On the Raspberry Pi

    Enter each command below to download and install remoteit device package and webcam software. Check the downloads page for the latest package version.

    sudo wget https://downloads.remote.it/remoteit/v4.13.5/remoteit-4.13.5.armhf.rpi.deb
    sudo apt update
    sudo apt install ./remoteit-4.13.5.armhf.rpi.deb

    type Y and enter to continue if it asks.

    At the end of installation there will be a “Claim Code”. Record that for the next step.

    On the remoteit Desktop app

    Insert that claim code into the desktop application

    Name your device Add two new services with these details.

    We have registered the device with remote.it so we can monitor it for being online. Now we need to create services that will create secure connections to specific ports on the Raspberry Pi.

    Our example will create two connections but there are thousands of ports that different software can listen on for applications like VNC, RDP, Samba, FTP…

    Both these connections are typically only available on your local network but with the remote.it platform its available everywhere to only you.

    The first connection will be SSH. This allows us to securely login to the terminal of the Raspberry Pi where you or the Raspberry Pi is connected to the internet.

    The second connection is over HTTP. Our webcam is being served by an apache webserver directly on the Raspberry Pi and it is waiting for connections on port 80.

    Step 6: Install webcam software

    To view more details on installation and use you can access the below site where this project is maintained. Summarizing here if you’ve followed this guide step by step and want to use the basic installation. All you need to do is hit enter when the installation wizard starts.

    Full Guide

    git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git
    cd RPi_Cam_Web_Interface
    ./install.sh

    Step 7: Connect to your webcam via remote.it from anywhere!

    Go to the Remote.It Desktop

    Add the HTTP service to your network and click connect. This will automatically open a browser with a secure connection to your webcam!

    This URL will be persistent so you can bookmark it and skip adding it before connecting.

    I’m using my webcam to check on the status of my bread proofing for the oven!

    This the view on the webpage – I could use better lighting and positioning.

    You can record still and videos directly from the webcam view.

    Even do a timelapse directly from the browser and download it from the cam.

    You can now explore the camera and webcam settings. This URL is only available to you via the remoteit software and you can connect to it anywhere you have internet access.

    Connect via remoteit mobile app

    You can access it exactly the same from the mobile app and check my bread proof progress from down the street!

    Take it Further

    Use remoteit for your SSH or HTTP connection from anywhere. If you connect to another network you’ll be unable to just do ssh pi@raspberrypi. With remoteit installed you can take this example deeper with the included software – The camera software contains motion and light sensor libraries. Our remote.it software allows you to securely connect to this device over any protocol, even do software development remotely on the Pi.

    If you have any questions or comments drop us a line at support@remote.it

    Related Blogs