TMC is an independent, primarily volunteer organization that relies on ad revenue to cover its operating costs. Please consider whitelisting TMC on your ad blocker and becoming a Supporting Member. For more info: Support TMC

Pi Zero W - Dashcam and Music Sync Control from Browser

Discussion in 'Model 3' started by cbutters, Oct 21, 2018.

  1. cbutters

    cbutters Member

    Joined:
    Jan 25, 2017
    Messages:
    314
    Location:
    Utah
    I just finished up Version 2 of this.

    Video Showing Features Here:


    Still working on a few things but thought we could get some discussion going.

    Features:
    • Sync Dashcam Footage wirelessly to your computer or network share.
    • Sync Music to your Tesla
    • Control Interface from your Tesla Browser
    • Repair FAT32 file structure on TeslaCam Partition without unplugging
    Specific Hardware Used (any pi should work):
    Pi Zero W w/ plastic clear case: https://amzn.to/2q5aeCD
    Samsung 256 Card: https://amzn.to/2PIgw6A

    I have my scripts available; however it still requires a lot of manual configuration because there are so many variables:
    for example:
    • How you want to partition your card
    • The size of your card
    • The network source you want to sync to
    • The protocol of the network source you want to sync to.
    • The dynamic DNS settings to connect to the pi from your Tesla Browser.
    That said here are my scripts for reference:
    rpi scriptsv2.zip

    Additional Tips
    • You actually don't HAVE to run this from your Tesla Browser, you could do it on your phone or computer as well; that way you wouldn't need to use a WAN based IP for access.
    • If you want to use this on the go; you can do it; but you have to set up a ddns and port forwarding with a wireless hotspot.
    • You can turn the raspberry pi and this interface remotely from the Tesla APP by turning Climate Control ON. That way you don't even have to go out to your car to initiate a sync. You can do it entirely remotely.
     
    • x 10
    • x 5
    • x 1
    • x 1
    • x 1
  2. Darmie

    Darmie Supporting Member

    Joined:
    Jan 13, 2016
    Messages:
    688
    Location:
    Clear Lake TX. (Currently in Lake Charles LA)
    Great video. I have a few Pi Zero w left over from messing with digital ham radio spots. I'll need to get one running with a pi OS
     
  3. cbutters

    cbutters Member

    Joined:
    Jan 25, 2017
    Messages:
    314
    Location:
    Utah
    [​IMG] Did some more tweaking... changelog:
    • Now shows size of dashcam and music drives and % full
    • fixed filename issue not showing special characters for music filenames
    • cleaned up one-click sync script
    • added music partition to the FAT32 repair process.
    New Scripts here: v3: rpi scriptsv3.zip
     
    • Like x 1
    • Love x 1
  4. laudbrian

    laudbrian Member

    Joined:
    Sep 5, 2018
    Messages:
    68
    Location:
    Alameda, Ca
    Hi @cbutters, this looks fantastic and thank you for sharing. I was working on building this one out cimryan/teslausb, yet to finish though as I just received my rPI 0/w and work stuff in the way. My friend told me with this one I linked he has had no issues for over a week if that helps and he leaves climate cooling on for 15-20 minutes for the wireless upload of his recordings. Nice to see and hear different ways of doing this, hotspot, dns, etc...

    Should there be a step to stop the recording before unmounting the drive to avoid getting the dirty bit that needs to be cleaned out or do you think this does not matter?
    Do you have version control somewhere to see progress or would you rather us follow this post as you enhance/update your work?
    I ask because as I see the title Version 2 in your yt video.

    Regardless, great stuff and following to see progress. I'm going share to others in the groups I am in to help you with feedback. :)
     
  5. tllt

    tllt Member

    Joined:
    Sep 4, 2017
    Messages:
    144
    Location:
    California
    Awesome work! I was thinking about putting something like together, but didn't get around to it. Have you considered adding a script to join the mp4 files together into larger chunks with ffmpeg or something similar before syncing them? That would be a great feature to reduce the number of files.
     
    • Like x 1
  6. Glamisduner

    Glamisduner Active Member

    Joined:
    Aug 2, 2017
    Messages:
    2,957
    Location:
    Escondido, CA
    So essentially your running the interface through a webserver on the pie 0? I'm tempted to buy one to play with :p
     
  7. insaneoctane

    insaneoctane Active Member

    Joined:
    Apr 6, 2016
    Messages:
    2,798
    Location:
    Southern California
    #7 insaneoctane, Oct 22, 2018
    Last edited: Oct 22, 2018
    Sorry if this is obvious, but is the Rpi plugged into the USB port on the Tesla and the car sees it as a drive?
    Power source for Rpi?
     
  8. hd-2

    hd-2 Member

    Joined:
    Aug 6, 2018
    Messages:
    46
    Location:
    Chicago
    Just bought the starter kit to try this out, can't wait to test it.
     
  9. cbutters

    cbutters Member

    Joined:
    Jan 25, 2017
    Messages:
    314
    Location:
    Utah
    Yep Rpi is plugged into the USB port on the Tesla. The Rpi is running a special mode so the car sees an image file on the Rpi as a usb storage device. On demand you can unmount it from the Tesla and mount it to the Rpi's system to then sync files over wireless. The Power source is a single usb cable into the tesla and requires no outside power (I'm even using it with a splitter for my Nomad)
     
    • Informative x 1
  10. cbutters

    cbutters Member

    Joined:
    Jan 25, 2017
    Messages:
    314
    Location:
    Utah
    There SHOULD be a step to stop the recording. But there is no way I know of to initiate that from the web browser. (The pi interface does have an option to repair the file system though.)

    my version control is just in the file package name. I don't have any github experience or anything. I should probably play around with it. but for now I'll just update this thread and my youtube channel as well.[/user]
     
    • Helpful x 1
  11. cbutters

    cbutters Member

    Joined:
    Jan 25, 2017
    Messages:
    314
    Location:
    Utah
    @tllt just wrote these amazing setup instructions if any of you are having setup difficulties. I'll include this with my next update in the zip file.
     

    Attached Files:

    • Like x 2
  12. noam

    noam Member

    Joined:
    Jul 14, 2018
    Messages:
    40
    Location:
    Boston
    Is it possible to have the rpi mount the dashcam filesystem read only so you don't need to unmount it from the tesla while you copy? If so you could have it automatically copy the files locally every 15 mins, and then remotely sync from your local store when you are home. You would have a more durable store of video files (since the Tesla will automatically remove non-saved files after an hour) and you reduce the likelihood of filesystem corruption.
     
  13. cbutters

    cbutters Member

    Joined:
    Jan 25, 2017
    Messages:
    314
    Location:
    Utah
    That's a great question. I'll play around with that and see if it is possible. It could be the image file is inaccesible.... but worth a shot.
     
  14. Glamisduner

    Glamisduner Active Member

    Joined:
    Aug 2, 2017
    Messages:
    2,957
    Location:
    Escondido, CA
    Couple questions. If you run with the RPi, don't you need to shut it down before turning off the car? Won't the PI itself be subject to memory corruption otherwise? Can you charge a phone and run a RPi off the same port?
     
  15. barjohn

    barjohn Member

    Joined:
    Sep 23, 2017
    Messages:
    547
    Location:
    Riverside, CA
    Can you provide instructions to do this from a Mac?
     
  16. cbutters

    cbutters Member

    Joined:
    Jan 25, 2017
    Messages:
    314
    Location:
    Utah
    Ideally yes you need to shut down the Pi before turning off the car; but impossible to pull off right now as there is no way for the Tesla to signal the Pi that it is about to shut down. I suppose you could give a shutdown command option in the web interface; but it would be impractical to try to press that button every time you unlock and lock your car. So far I haven't experienced any corruption on the pi data volumes themselves. *knock on wood*
     
  17. Glamisduner

    Glamisduner Active Member

    Joined:
    Aug 2, 2017
    Messages:
    2,957
    Location:
    Escondido, CA
    I think this is a nifty idea, and I still kind of want to do this, but I might wait and see if you get corruption issues. The car turns itself on and off allot. I just setup an old wireless G router in the garage with DDWRT on it as an access point, so the tesla can get a more reliable, albeit, slower signal connection. (I figure it's good enough for light usage anyways). Tesla shows 1 bar when it connects to the N home internet, so I set it to use the AP instead (it's right above it).
     
  18. barjohn

    barjohn Member

    Joined:
    Sep 23, 2017
    Messages:
    547
    Location:
    Riverside, CA
    @cbutters I need some help please:
    When I run this (step k):
    sudo /etc/init.d/nginx restart

    [....] Restarting nginx (via systemctl): nginx.serviceJob for nginx.service failed because the control process exited with error code.

    See "systemctl status nginx.service" and "journalctl -xe" for details.

    failed!
    it isn't clear if steps k & l are supposed to edited into the file at step 12 or they are supposed to be run after saving and closing the file created in step 12.

    I also don't know how to perform steps 13 and 14. I try drag and drop but that doesn't work help on how to do this from a file folder on the computer that I am running terminal from would be helpful.
    Thanks
     
  19. insaneoctane

    insaneoctane Active Member

    Joined:
    Apr 6, 2016
    Messages:
    2,798
    Location:
    Southern California
    Any advice on recommended vendor for RPi Zero W? I know the links suggest Amazon ($22 & free prime shipping) and Adafruit ($10 & $5 shipping). Coupons for free Adafruit shipping or comments/suggestions? Amazon with prime seemed like a pretty high premium....
     
  20. barjohn

    barjohn Member

    Joined:
    Sep 23, 2017
    Messages:
    547
    Location:
    Riverside, CA
    @cbutters
    After is allocated 8G in step 15 and created 2 4G partitions, at step 19 I get the following error:
    [email protected]:~ $ sudo mkdir /mnt/TeslaCam

    mkdir: cannot create directory ‘/mnt/TeslaCam’: No space left on device

    The memory card is a 16GB card.
    Please help.
     

Share This Page

  • About Us

    Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.
  • Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.


    SUPPORT TMC