Automatic TeslaCam And Sentry Mode Video Processing In Azure – Part 3: TeslaUSB Setup

This is part 3 of my series on ‘Automatic TeslaCam And Sentry Mode Video Processing In Azure’. Check out the overview post, or the 2nd post about how to configure the Azure resources. In this post, I describe how to configure a RaspberryPi to run the TeslaUSB project, to automatically upload your TeslaCam videos to Azure Storage! When in doubt, drop a question in the comments!

So, you got yourselve the RaspberryPi Zero W and other hardware? And you have the Azure resources ready? Grab a cup of coffee and put your geek mode on, as we are about to flash a Rasbian Linux image on your RaspberryPi Zero W, then SSH into it to set up an RClone configuration 🤓.

It’s not as difficult as it sounds.

From zero to hero

For the first steps of this ‘tutorial’, you can almost completely follow the ‘OneStepSetup’ of the TeslaUSB project: https://github.com/marcone/teslausb/blob/main-dev/doc/OneStepSetup.md. The important part is, you must specify ‘none’ as the archive method in the config file, which will configure the pi as a wifi-accessible USB drive, but will not set up the archive scripts yet.

Note: as we have not created the IFTTT webhook yet, we will add that later in the config file. (This way you will also experience how to access and update the TeslaUSB project config after it is up-and-running and ‘deployed’ to your Tesla1).

After the pi is up-and-running in your Tesla (or still at your desk, that’s also fine), SSH into it. Use your favorite SSH client (maybe Putty). If you are running an up-to-date version of Windows 10, you can simply open command prompt and use the ssh command:

ssh pi@teslausb.local

Configure RClone

Now, let’s setup/configure RClone on the pi. Execute the following commands:

sudo -i
/root/bin/remountfs_rw
curl https://rclone.org/install.sh | sudo bash
rclone config

Now go through the wizard and specify your new remote called ‘teslausbarchive’, and pick ’22’ to choose Azure Blob Storage as the type. Specify the name and key of your Azure Storage Account, and skip the SASurl and Emulator settings questions. Also, skip the advanced settings.

Then check the configuration and confirm with ‘y’. Press ‘q’ to quit.

Execute the following command to edit the TeslaUSB project settings:

nano /root/teslausb_setup_variables.conf

Change the ARCHIVE_SYSTEM line to rclone (from none):

export ARCHIVE_SYSTEM=rclone

Add these two lines to the config file, but with your values!

export RCLONE_DRIVE=teslausbarchive
export RCLONE_PATH=teslacam

I had to update the date of the pi to get the Azure data sync successfully (might not be necessary on your system):

date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"

Run the TeslaUSB setup by executing this line (choose yes at question):

/root/bin/setup-teslausb

Go go go, take your tesla on a test drive

Now, after one last reboot, the pi is ready! Put your pi in the Tesla if you have not done so already. And go drive a block and save some TeslaCam footage (press the camera icon on the screen in your Tesla). After returning home, the footage should be uploaded automatically to your Azure Storage Account.

TeslaUSB tips

Some general tips regarding the TeslaUSB project:

  1. Change the password of the pi user.
  2. If the upload of files is very slow, consider putting an (extra) WiFi access point closer to your Tesla.
  3. To power the pi, make sure you use a USB cable that transmits data (not only power). Make sure you put the cable in the data enabled USB port.
  4. If you use a USB hub in the Tesla, make sure the pi is connected to a USB port that is enabled for data (not only power).

TeslaUSB troubleshooting

tail -n 50 /mutable/archiveloop.log
tail -n 50 /boot/teslausb-headless-setup.log

or (from https://github.com/marcone/teslausb/issues/35):

sudo -i
/root/bin/setup-teslausb selfupdate
/root/bin/setup-teslausb diagnose > /mutable/diagnostics.txt

TeslaUSB reconfig

sudo -i
nano /root/teslausb_setup_variables.conf
/root/bin/setup-teslausb selfupdate

1The actual reason is I have already settled for a specific order of blog posts, and the IFTTT blog post is now scheduled as blog post #5 in the series 😁.

Pass the sauce

This Post Has 7 Comments

  1. Marco

    Thanks for explaining! The code for Azure Blob Storage is currently 22 instead of 21.

    1. Dave Ruijter

      Thank you Marco! I’ve updated the post to reflect this!

  2. Haseeb Niaz

    Kudos 😀 Can’t wait for the rest of the series. Eagerly waiting 😛

  3. Jules

    Hi Dave

    I have a problem installing rClone. Did not see any help on the github page.
    Can you help me?

    root@teslausb:~# curl -L https://raw.github.com/pageauc/rclone4pi/master/rclone-install.sh | bash
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
    100 2508 100 2508 0 0 5573 0 –:–:– –:–:– –:–:– 11557
    bash ver 1.6 written by Claude Pageau
    ——————————————————————————-
    –2020-01-23 00:25:34– https://downloads.rclone.org/rclone-current-linux-arm.zip
    Resolving downloads.rclone.org (downloads.rclone.org)… 5.153.250.7, 2a02:24e0:8:61f9::1
    Connecting to downloads.rclone.org (downloads.rclone.org)|5.153.250.7|:443… connected.
    ERROR: The certificate of ‘downloads.rclone.org’ is not trusted.
    ERROR: The certificate of ‘downloads.rclone.org’ is not yet activated.
    The certificate has not yet been activated
    unzip rclone.zip to folder rclone-tmp
    Archive: rclone.zip
    End-of-central-directory signature not found. Either this file is not
    a zipfile, or it constitutes one disk of a multi-part archive. In the
    latter case the central directory and zipfile comment will be found on
    the last disk(s) of this archive.
    unzip: cannot find zipfile directory in one of rclone.zip or
    rclone.zip.zip, and cannot find rclone.zip.ZIP, period.
    Install files and man pages
    bash: line 12: cd: rclone-tmp: No such file or directory
    cp: cannot stat ‘rclone’: No such file or directory
    chown: cannot access ‘/usr/bin/rclone’: No such file or directory
    chmod: cannot access ‘/usr/bin/rclone’: No such file or directory
    cp: cannot stat ‘rclone.1’: No such file or directory
    Purging old database entries in /usr/share/man…
    Processing manual pages under /usr/share/man…
    Purging old database entries in /usr/share/man/sv…
    Processing manual pages under /usr/share/man/sv…
    Purging old database entries in /usr/share/man/da…
    Processing manual pages under /usr/share/man/da…
    Purging old database entries in /usr/share/man/ru…
    Processing manual pages under /usr/share/man/ru…
    Purging old database entries in /usr/share/man/it…
    Processing manual pages under /usr/share/man/it…
    Purging old database entries in /usr/share/man/es…
    Processing manual pages under /usr/share/man/es…
    Purging old database entries in /usr/share/man/id…
    Processing manual pages under /usr/share/man/id…
    Purging old database entries in /usr/share/man/sl…
    Processing manual pages under /usr/share/man/sl…
    Purging old database entries in /usr/share/man/hu…
    Processing manual pages under /usr/share/man/hu…
    Purging old database entries in /usr/share/man/ko…
    Processing manual pages under /usr/share/man/ko…
    Purging old database entries in /usr/share/man/de…
    Processing manual pages under /usr/share/man/de…
    Purging old database entries in /usr/share/man/nl…
    Processing manual pages under /usr/share/man/nl…
    Purging old database entries in /usr/share/man/zh_TW…
    Processing manual pages under /usr/share/man/zh_TW…
    Purging old database entries in /usr/share/man/pt…
    Processing manual pages under /usr/share/man/pt…
    Purging old database entries in /usr/share/man/fr…
    Processing manual pages under /usr/share/man/fr…
    Purging old database entries in /usr/share/man/uk…
    Processing manual pages under /usr/share/man/uk…
    Purging old database entries in /usr/share/man/fi…
    Processing manual pages under /usr/share/man/fi…
    Purging old database entries in /usr/share/man/fr.UTF-8…
    Processing manual pages under /usr/share/man/fr.UTF-8…
    Purging old database entries in /usr/share/man/cs…
    Processing manual pages under /usr/share/man/cs…
    Purging old database entries in /usr/share/man/ja…
    Processing manual pages under /usr/share/man/ja…
    Purging old database entries in /usr/share/man/zh_CN…
    Processing manual pages under /usr/share/man/zh_CN…
    Purging old database entries in /usr/share/man/pt_BR…
    Processing manual pages under /usr/share/man/pt_BR…
    Purging old database entries in /usr/share/man/tr…
    Processing manual pages under /usr/share/man/tr…
    Purging old database entries in /usr/share/man/pl…
    Processing manual pages under /usr/share/man/pl…
    Purging old database entries in /usr/share/man/fr.ISO8859-1…
    Processing manual pages under /usr/share/man/fr.ISO8859-1…
    Purging old database entries in /usr/share/man/sr…
    Processing manual pages under /usr/share/man/sr…
    Purging old database entries in /usr/local/man…
    Processing manual pages under /usr/local/man…
    0 man subdirectories contained newer manual pages.
    0 manual pages were added.
    0 stray cats were added.
    0 old database entries were purged.
    Deleting rclone.zip and Folder rclone-tmp
    rm: cannot remove ‘rclone.zip’: No such file or directory
    rm: cannot remove ‘rclone-tmp’: No such file or directory
    ERROR – Problem Installing rclone. Please Investigate
    rclone installed at /usr/bin/rclone
    ——————————————————————————-
    INSTRUCTIONS Google Drive Example

    1 You will be required to have a login account on the remote storage service
    Open putty SSH login session to RPI and execute command below

    rclone config

    Follow rclone prompts. For more Details See
    https://github.com/pageauc/rclone4pi/wiki/Home
    2 At name> prompt specify a reference name eg gdmedia
    3 At storage> prompt Enter a remote storage number from List
    4 Select Auto Config, At Link: prompt, left click
    and highlight rclone url link (do not hit enter)
    5 on computer web browser url bar right click paste and go.
    6 On computer web browser security page, Confirm access.
    7 Copy web browser access security token and paste
    into RPI SSH session rclone prompt. Enter to accept
    8 To test remote service access. Execute the following where
    gdmedia is the name you gave your remote service

    rclone ls gdmedia:/

    Example sync command make source identical to destination

    rclone sync -v /home/pi/rpi-sync gdmedia:/rpi-sync

    To upgrade

    cd rpi-sync
    ./rclone-install.sh upgrade

    For more Details See https://github.com/pageauc/rclone4pi/wiki/Home
    Bye

    root@teslausb:~#

  4. Winter

    Dave, What happened to part 5?

    1. Dave Ruijter

      Still in draft I’m afraid. I don’t expect I’ll ever finish that post, I’m sorry.

Leave a Reply