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:
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:
Change the ARCHIVE_SYSTEM line to rclone (from none):
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):
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.
Some general tips regarding the TeslaUSB project:
- Change the password of the pi user.
- If the upload of files is very slow, consider putting an (extra) WiFi access point closer to your Tesla.
- 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.
- 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).
tail -n 50 /mutable/archiveloop.log tail -n 50 /boot/teslausb-headless-setup.log
sudo -i /root/bin/setup-teslausb selfupdate /root/bin/setup-teslausb diagnose > /mutable/diagnostics.txt
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 😁.