Showing posts with label raspberry pi. Show all posts
Showing posts with label raspberry pi. Show all posts

Sunday, 21 October 2018

TeslaCamPi - Uploading the Tesla DashCam videos dynamically to AWS / DropDox

Current active github TeslaUSB project from a great team look here
https://github.com/cimryan/teslausb




<WIP>

8GB virtual USB Drive
uploads 'Saved-' files from TeslaCam to dropbox
crontab running every 5 mins

frostymccool/TeslaCamPi


Extending from:





  



MAKE A PI ZERO W SMART USB FLASH DRIVE

https://www.raspberrypi.org/magpi/pi-zero-w-smart-usb-flash-drive/

3GB for TeslaCam, 8G for Music

Create 3G TeslaCam drive file
sudo dd if=/dev/zero of=/piTeslaCam.bin bs=3M seek=1024 count=0

Create the file to user for usb fat sharing drive
sudo dd if=/dev/zero of=/piTeslaMusic.bin bs=8M seek=1024 count=0

sudo mkdosfs /piTeslaMusic.bin -F 32 -I
sudo mkdosfs /piTeslaCam.bin -F 32 -I

Mount the TeslaCam and create the key folder that the car will look for 
sudo mount -t vfat /piTeslaCam.bin /mnt/temp && sudo mkdir /mnt/temp/TeslaCam
sudo umount /mnt/temp
sudo nano /etc/fstab
Append the line below to the end of the file
/piTeslaMusic.bin /mnt/usb_share vfat users,umask=000 0 2

/piTeslaCam.bin /mnt/usb_share vfat users,umask=000 0 2

Test the mass storage gadget - … if it doesn’t work, likely a conflicting gadget is already loaded (try checking / removing  loaders from boot/configtext)
sudo modprobe g_mass_storage file=/piTeslaCam.bin stall=0 ro=0 removable=1
sudo modprobe g_mass_storage file=/piTeslaMusic.bin stall=0 ro=0 removable=1

For the normal load gadget line, they should be loaded together, only difference is that the music gadget can be loaded readonly as there is no need to allow the car to have write access to it.
sudo modprobe g_mass_storage file=/piTeslaCam.bin,/piTeslaMusic.bin stall=0,0, ro=0,1 removable=1,1


AWS S3 uploader .....

<TBD> .... event date stamp min vs file ... concatenated 10min 'saved-front-...' files ... contruct 360-saved... with just the front and structure for merging sides and rear  - assuming they will be able to be exported by Tesla soon :)

And dropbox uploader ..

https://www.raspberrypi.org/forums/viewtopic.php?t=164166


python dbupteslacam.py 


script modifications:


# Path to use for re-mounting to make sure get up to date data
umountdir = "/mnt/usb_share"
#The directory to sync
syncdir="/mnt/usb_share/TeslaCam"
#Filename prefix to test for
filenameprefix="saved-"


#Uploads files in a directory
def upload_files(path, level):
    fullpath = os.path.join(syncdir,path)
    print_output("Syncing " + fullpath,level)
    if filenameprefix:
        print_output("Syncing files with prefix only: " + filenameprefix, level) 


....

        #Loop through the files to check to upload
        for f in files:                                 
            print_output("Found File: " + f,level)   
            if upload == 1 and (f[:len(filenameprefix)]==filenameprefix) and (overwrite == 1 or not f in dfiles):



... and at the bottom ...

#re-mount the folder to make sure it's fresh
def remount():
        cmd = [ 'sudo', 'umount', umountdir ]
        p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)

        cmd = [ 'sudo', 'mount', '-a' ]
        p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)

#Start
remount()


crontab

*/5 * * * * python /home/pi/dbupteslacam.py







Issues/updates:
  • possibly need to control w/r more across the gadget and the share, there are some FSCK files appearing in the root  and 0 byte file minutes. (pre-dropbox addition)
  • check dropbox handler to make sure noop if no wifi
  • update uploader to a daemon / stop it just spinning up multiple instances
  • update / use accelerometer on pi to trigger the copy / upload.. at least it will snapshot in case user forgets to hit the button even in wifi not available.... 
  • could maybe use trigger on phone to switch on phone hotspot... then tcp - teslacampi :) - could connect and use the phone hotspot to upload



Saturday, 7 April 2018

Dig out the old Wiifit board and allow it to tell fitbit how well you are doing .. enter PiScales ...

The thought of manually typing in my daily weight into fitbit just didn't sit well.

Manual / Repetitive.

Sure fitbit have their custom scales, but where's the fun in that.

Have been experimenting the great wiifit raspberry pi tutorial form initial state..., but it was a little too much functionality / not quite what I wanted and bluetooth was playing games with me - I could easily set the code in a loop and cause too much 2.4G(assumption) noise that it messed up my local wifi , so the whole thing sat on the shelf for quite a while...

I want something that where I can turn on / off easily and ideally give clear visual feedback on what the measurement was that day with some nice small display, have the ability to measure a few times, not have to drag too many things around (too many boxes connected) and not having to switch things on / off and wait too long....

with the pi zero w released and displays getting still cheaper and custom fit to pi zero, it's time to start looking again.



  


  





Saturday, 21 May 2016

amINetConnected-Pi - Rebooting your cable modem when we can talk to the world

That frustrating time when your cable modem just locks or get's upset or just planely looks like it's happy but you can't connect to the internet...

It happens to most of us and can be very frustrating - often is :)

Looking on and off for an easy & cheap switchable mains device and a few weeks ago stumbled across this from digital-loggers.com, readily available from amazon for $20.




Often these devices aren't so cheap, but this one looks great. Sure you can use the normal 2 pole relay with a load of hand crafted wires, but I'm not up for this in this instance when we are talking about a box that needs to sit near the cable modem itself an kids are around.

The device has 2 sockets normally off and 2 normally on, and is Raspberry Pi ready, so theory goes should be just drive-able from gpio..

I figure we'll use the normally on sockets to power the cable modem and when the Pi can't talk to the outside world it will be a simple case of cycling the the sockets down via gpio...

time for the 'amINetConnected-Pi' project to be born...


Friday, 22 April 2016

Garage Pi with a dash of Amazon

The old garage door opener in the new house couldn't easily add an external pin code button outside.

Ethan needed an easy way to open the garage door when home from school without having to carry an opener with him. so finally out came an old Raspberry Pi.

Thanks to those examples online.....


Ethan and I put it together and ..



added an Amazon dash button too.

Now Ethan can use the dash when he gets home from school.

Sure it's still a button, but now can also use a simple webpage on his phone also, and it was a little fun in the process



Sunday, 17 February 2013

Wireless Raspberry Pi for Minecraft

We took some time out of our day today when Ethan simply wanted to try Minecraft on the Raspberry Pi.

1st challenge was that Chloe's room doesn't have wired ethernet connected, so we need a Pi that had wireless enabled - humm.

Ethan had successfully followed the instructions to create an SD card with the latest Wheezy from the beginning of February (2013) performed all the necessary mods with raspi-config to enlarge the filesystem, split the memory (as he as a 512MB version), but we stopped short at the wireless config stage.

Off to reliable tutorials on youtube - maybe not - they are pretty much all too old, based on older or non-wheezy distributions.

Alas Minecraft Pi style didn't quite come together in the time we had, we did try it but there were error messages being displayed on the console window and it was pretty non-responsive most of the time.

Tonight I stumbled across this quick tutorial, which has all the correct markers for what we had in out interfaces file - hopefully in the next few days we'll get chance to try it out.....

Sunday, 16 September 2012

Using your Raspberry Pi as your home Music Server

We're pretty much locked into Logitech's Squeeze Play solution - chosen amongst the alternative a few years back.

Selection was based on a balance of cost, stability(slightly challenged at the time) and open source.
Over the years the stability and source of plugins (i.e. semi-recent YouTube and Spotify) have ratified my choice :)

The house has used a variety of hardware to run the server on over the years. Initially the QNAP 209  Pro (which is still running strong), then migrating to a Joggler as it was pretty clear that the one of the performance/stability issues I suffered from was due to the QNAP.

The actually music source files are still servered up over NFS from the QNAP, so I've basically just moved the server portion.

The Joggler was and still is a great multi-purpose server for everything, and thus it servered for quite a period as the LMS (Logitech Media Server) - even though I still prefer the SqueezeServer from the naming perspective :)

Now enter Raspberry Pi - from when the first one arrived early May, it became a nice low power alternative for LMS.

Not being the expert I need to be I couldn't compile up from the source at the time, so I had to park the idea for a while and off to focus on lighting OLA :)

Now Thomas over at SqueezePlug has made a fantastic image complete with setup tool, nfs support, squeezeplay support - basically everything needed - Thank Thomas.

Now our home has been running pretty much flawlessly for over a month.
The 'pretty much' is down to those end receivers that are on the wireless network - all my wired endpoints are great. Also internet radio is not perfect, but all internal server based much is fine.

Another Raspberry Pi success!

Sunday, 26 August 2012

Car music sync with home

When the car is close enough to home to access the wireless network, the RPi can sync a music folder or collection with what's in the car.
Having a USB stick or small drive or iPod situated in the car to hold the music and either use the iPod to control (via http etc) the music output from the RPi's audio jack to aux input in car or direct output from iPod to car.
The RPi can be wireless guest when close to home or wireless AP in car. Or if myfi mobile access in car, maybe use the myfi for the AP for everything.