In this How To, we'll demonstrate how to automatically transfer Tesla Sentry Mode and Dashcam video clips over WiFi to Storj DCS and make room for more videos the next day. We'll use a Raspberry Pi (a small, low cost, low power computer) plugged into the USB port in the dashboard to store the video files. When the Tesla pulls into your garage at night, the Raspberry Pi will connect via WiFi and upload all the videos to Storj DCS, then clear off the drive for use the next day. This will also work for videos recorded in Track Mode if you have one of the performance models, and you can easily share any of the videos with your friends.
You'll need some hardware, some software and a Storj DCS account for this project.
All in, you’re looking at right around $60 of hardware to get going (prices as of April 2021). Here’s the hardware you’ll need:
Raspberry Pi Zero W : ID 3400 : $10.00 (We used a different model, but this is better)
Adafruit Raspberry Pi Zero Case : ID 3252 : $4.75 (It should look good - you can 3d print your own for extra credit)
SanDisk 256GB High Endurance Video microSDXC Card $37 (Very important to have high quality storage with high write endurance. This gives you room for a few days in case you don’t connect to WiFi and won't wear out too quickly)
USB Cable to plug into the car USB A to Micro-B - 3 foot long
Storj DCS cloud storage 150GB free and only $0.004 per GB-month after that! Secure, private and decentralized.
Optional hardware for easier setup:
Mini HDMI to HDMI Cable - 5 feet : ID 2775: $5.95 Makes it easier to set everything up by connecting the Pi to a monitor
The code used in this tutorial is open source and uses, among other things, Rlcone which includes native support for Storj DCS. The GitHub Repository for the code is available at: https://github.com/marcone/teslausb and the project was originally described on the /r/teslamotors subreddit.
If you have not yet signed up, please do so now.
Using the software in the teslausb project with Storj DCS is a multipart process, we will accomplish the following:
Generate Credentials for Storj DSC
This occurs through the storj.io website
Configure your Raspberry Pi with the teslausb kit
Part 1 - One-step setup
This is done by flashing a preconfigured Raspbian image and then filling out a config file.
Part 2 - Rclone Configuration with Storj DCS via hosted Gateway MT
This is done by accessing the Pi via SSH and installing/configuring Rclone
If you have not yet signed up, please head here to sign up for the free tier.
Navigate to the Access page within your project and then click on Create Access Grant +. A modal window will pop up where you should enter a name for this access grant.
Assign the permissions you want this access grant to have, (in this case, just select the default permissions) then click on Continue in Browser:
Enter the Encryption Passphrase you used for your other access grants. If this is your first access grant, we strongly encourage you to use a mnemonic phrase as your encryption passphrase (The GUI automatically generates one on the client-side for you, as shown below.)
Click Next to proceed to Access Grant generation. Please then save the Access Grant in a safe place. This is usable for other integration paths not covered in this guide.
Click on the Generate S3 Gateway Credentials link above and then click on the Generate Credentials button as seen below.
Copy your Access Key, Secret Key, and Endpoint to a safe location. We will use this information later to configure Rclone with the hosted Gateway MT.
Now we have our credentials and can move on to configuring teslausb.
We will need this to view and/or retrieve clips in the browser later
Not used for this lab but please record it anyway for your reference
Gateway MT (S3) Credentials
Used to connect to the hosted gateway via Rclone
Teslausb is the open source software that will run on the Raspberry Pi to send your videos to Storj DCS. Now that you have your gateway credentials for Storj DCS, you need to set up teslausb on the Raspberry Pi and configure it for use with those Storj DCS credentials.
You'll find the one-step setup guide for testlausb in this GitHub repo: https://github.com/marcone/teslausb/blob/v2.5/doc/OneStepSetup.md
Download the latest release of the pre-built image from the repository’s releases page: https://github.com/marcone/teslausb/releases/latest
Mount the SD card to edit the initial configuration file located in the
boot directory. Create a
teslausb_setup_variables.confA sample config file is located in the
boot folder on the SD card. The latest sample is also available from GitHub via pi-gen-sources/00-teslausb-tweaks/files/teslausb_setup_variables.conf.sample.
Specifically, set the `ARCHIVE_SYSTEM` to `none`. This is because we need to boot the Pi to install some additional software to push our sentry clips in Storj DCS. Please also set your Wifi settings. Save the file when you are done editing.
Below is a small portion of the config file showing 'export ARCHIVE_SYSTEM=none' as well as the wifi settings.
# Variables for CIFS (Windows/Mac file sharing) archivingexport ARCHIVE_SYSTEM=noneexport ARCHIVE_SERVER=your_archive_name_or_ipexport SHARE_NAME=your_archive_share_nameexport SHARE_USER=usernameexport SHARE_PASSWORD=password# the cifs options below usually don't need to be specified# export SHARE_DOMAIN=domain# export CIFS_VERSION="3.0"# export CIFS_SEC="ntlm"# Wifi setup information. Note that Raspberry Pi Zero W only supports 2.4 GHz wifi.# If you are you are trying to connect to a network with a _hidden_ SSID,# edit /boot/wpa_supplicant.conf.sample and un-comment the indicated line.export SSID='your_ssid'export WIFIPASS='your_pass'
Now that Raspbian is installed and configured, it's time to set up Rclone, the software that will actually transfer the files from the Raspberry Pi to Storj DCS. (If you're not familiar with Rclone, it's Rsync for cloud storage.) Boot up that Pi and let' s keep it moving.
The Rclone Setup Guide for teslausb is available at: https://github.com/marcone/teslausb/blob/v2.5/doc/SetupRClone.md
The steps you need to follow are also provided below:
SSH into the Pi, become root and remount the file system's read-write:
curl https://rclone.org/install.sh | sudo bash
Configure Rclone with the settings and Storj DCS gateway credentials created above:
# setup rclonerclone config# select n (New Remote)# namestorj-dcs-us1-gateway# select 4 (4 / Amazon S3 Compliant Storage Provider)4# select 13 (13 / Any other S3 compatible provider)13# select 1 (1 / Enter AWS credentials in the next step \ "false")1# enter access key<access_key># enter secret key<secret_key># select 1 ( 1 / Use this if unsure. Will use v4 signatures and an empty region.\ "")1# enter endpoint (use your own endpoint, the example shows the Americas region gateway)https://gateway.us1.storjshare.io# use default location_constraint# use default ACL# edit advanced confign# review config and select default# quit configq
Create a bucket tesla-m3-cam for saving clips:
# make bucketrclone mkdir storj-dcs-us1-gateway:tesla-m3-cam
teslausb_setup_variables.conffile in the boot directory with the following information. Ensure your Wifi variables are also set. If your variables have any spaces, please put your variables in quotes like this: "variable"
# Variables for rclone archivingexport ARCHIVE_SYSTEM=rcloneexport RCLONE_DRIVE=storj-dcs-us1-gatewayexport RCLONE_PATH=tesla-m3-cam# The following is optional#export RCLONE_FLAGS=()
Shut down your Pi and plug it into your Tesla: If you are using a RPi4, you only need to plug the Pi via its USB-C cable into one of the Tesla's USB-C ports, this will provide power and data transfer. If using a RPi Zero W, you will need to use the usb/data USB port on the Pi.
To test that everything is set up correctly, you can navigate to the Pi’s web interface at <rpi ip address>:80. Enable Honk to Save Clips on your Tesla, and then under the Tools page of your Raspberry Pi’s web interface, click the Trigger archive/sync button.
Follow along on the Archive log page to see your clips being acknowledged and pushed to Storj DCS.
Finally, log in to your Storj DCS account and take advantage of the new file browser to manage and share your clips!