Attempting to leave Dropbox, I decided to setup a cloud and sync solution. Dan from BitTorrent.com has a great blog post on how to setup both BTSync and ownCloud up on a Raspberry Pi. I decided to use the same type of setup. Jimmy, a mad iPhone developer, secured it a bit more and made a helpful guide. Not being a sysadmin, this helped me a lot.
Dan’s guide uses an ext4 formatted thumb drive as storage location. I want to use my external hard drive that’s ntfs. I don’t want to format it because I already have tons of stuff on there I don’t want to lose.
The default ntfs file system on Raspbian is read-only so you need to begin by installing ntfs-3g
1
$ apt-get install ntfs-3g
Next you need to have it auto mount on start up using /etc/fstab. Doing a basic mount /etc/sda1 /media/exthdd ntfs-3g defaults 0 0 won.t work. The reason is because by default it mounts to root and the permissions are 777. In order for ownCloud to allow the drive to be used you need 770 as permissions on whatever directory/file you want to use and you want ownCloud to be the owner.
To change permissions on a mounted HD you need to define the uid, gid, fmask and dmask options in /etc/fstab.
Depending on your distribution the uid and gid will change. See the ownCloud admin manual
In my case I want www-data to be the owner.
12
$ id -u www-data
$ id -g www-data
Say they both return 33 here is what you would add in /etc/fstab
I’m the type of guy who has way too many things on the go. An idea comes to mind, I start working on it for a weekend, then something comes up and I stop. Then if I’m lucky I get back to it 6 months later. I also have a few projects where I work on them a bit more actively but still won.t see an end in the near future. For some of these projects I have some raspberry pies running at home and a VPS for stuff that requires more power.
A while ago I noticed myself forgetting where things where, what server was what on. And I would end up spending half of my time researching stuff I already done just so I could start working on it again. The next day I had the same problem at work, except that I had a wiki to go to and quickly lookup the information.
That’s when I realised I needed to document not only my work stuff, but also my stuff at home. Leave it to a programmer to not have his stuff properly documented or even some of his projects not checked into a repo.
We use confluence at work. I have grown to like it. So I thought why not use it at home? Did you know you could have a 10 user license for only 10$ as long as you host it yourself. That’s pretty sweet. I thought about buying it and setting it up but then I also thought of what I was about to document. I really didn’t need an enterprise level wiki solution. In the end I went with Bootstrap and basic HTML. I basically ripped off the Bootstraps documentation page
The important thing though is that I have my stuff documented. I do have a git repository on my VPS that I host a few of my bigger projects, but my next step is putting up some smaller things I’ve worked on. I’m also thinking of putting up a gitlab.
So I decided it would be fun to combine both and make myself a laser trip wire activated missile launcher!
From what I could tell, Python was the easiest way to talk to the missile launcher. I don’t really know Python, but I was able to get something working.
The wiki explains how to install it for a certain device. For the Thunder Misslie Launcher its:
12
idVendor=0x2123
idProduct=0x1010
Now came time to test the stormLauncher code. It didn’t seem to work for me. I don’t remember
what errors I was getting so I decided to look into the code and strip it down to try and see if I can get it working.
I got a test working with this:
Test missile launcher
1234567
importusb.util#don't remember if this is actually neededimportusb.coreif__name__=="__main__"dev=usb.core.find(idVendor=0x2123,idProduct=0x1010)ifdevisNone:raiseValueError('Turret not found')dev.ctrl_transfer(0x21,0x09,0,0,[0x02,0x10,0x00,0x00,0x00,0x00,0x00,0x00])# Command to fire the missile
Using an arduino and photo sensor, I made a trip wire that just sends the value of the sensor through the serial cable.
I used the same circuit as in this tutorial:
http://arduino.cc/en/Tutorial/SwitchCase
The sketch is quite simple. Just output the light level.
After that I looked up how to do serial communication with python. Basically the program reads the serial input coming from the arduino.
Once the value passed by the arduino hits a certain threshold, this means the laser is no longer in contact with the light sensor so fire away!
I got the light value by testing around with the laser so that might have to change. I also added a sleep time because the missile launcher isn’t the fastest.
Note that I have code in there to remove the “Light level: ” part that is sent. I could/should have just ommited that so that I didn’t have to parse it out.
Like I said I don’t really know python so this was the result of playing around and reading a few things online. It works but it can be improved.
importserialimportusb.coreimportusb.utilimportreimporttimedefmain():# find our devicedev=usb.core.find(idVendor=0x2123,idProduct=0x1010)# was it found?ifdevisNone:raiseValueError('Turret not found')# Set up serial communication with arduinosp=serial.Serial()sp.port='COM4'sp.baudrate=9600sp.parity=serial.PARITY_NONEsp.bytesize=serial.EIGHTBITSsp.stopbits=serial.STOPBITS_ONEsp.timeout=2sp.xonxoff=Falsesp.rtscts=Falsesp.dsrdtr=Falsesp.open()pattern=re.compile('[a-zA-Z: ]*([0-9]+)')value=None#confirm we are reading data from the serial portwhilenotvalue:value=sp.readline()printvalue# loop and wait for wire to be trippedwhile1:value=sp.readline()m=pattern.match(value)lightValue=m.group(1)#print lightValueifint(lightValue)>100:print"fire in the hole"dev.ctrl_transfer(0x21,0x09,0,0,[0x02,0x10,0x00,0x00,0x00,0x00,0x00,0x00])time.sleep(5)# the missle launcher can only shoot about once every 5 secondssp.close()if__name__=="__main__":main()
My next plan is hooking up the missle launcher to my RaspberryPi and and having the light sensor hooked up to an XBee Module. This way it’s more mobile.
One thing I’m working on is controlling my living room with my Raspberry Pi. Eventually I want to get lighting and wall sockets working but for now I’m concentrating on my multimedia.
My projector and audio system work with IR remotes so I decided to use the USB-UIRT in order to control them. Unfortunately, there isn’t much up to date information on how to get it working on linux. However, most of it still works.
I’m using the Arch Linux ARM distribution for my Raspberry Pi so what I did might not work with other distributions. From what I can tell, it shouldn’t be all that different to get it working on Wheezy.
To get the USB-UIRT working you need LIRC (Linux Infrared Remote Control) using the uirt2_raw drivers.
First thing you need to do is make sure you have initscripts installed.
1
$ pacman -S initscripts
Then you can install LIRC.
1
$ pacman -S lirc
After this I plugged in the USB-UIRT and checked to see if it was detected.
1
$ dmesg | grep -i usb
Look for something like “FTDI USB Serial Device converter now attached to ttyUSB0”.
Now I know my USB-UIRT is attached to ttyUSB0. And we know we have to use uirt2_raw as the driver. Time to configure LIRC. On some sites I read that you had to configure /etc/lirc/hardware.conf but I couldn’t find the file and creating it did nothing for me.
Eventually I found that the file we want to edit is /etc/conf.d/lircd.conf. It also had different variable names. Similar but different. I tried searching for up to date documentation on the file but didn’t really find much. I didn’t really search to hard though, but it wasn’t hard to guess what to put where.
Here is my configuration file.
Now before you can send and receive ir commands from a remote, you need tell lirc about that remote.
This is done in the /etc/lirc/lircd.conf file. You can find a bunch of remotes already defined at http://lirc.sourceforge.net/remotes/.
I was lucky to find one of my remotes and load it up.
So I’m starting a blog. I’m not sure how much I’m going to post, but hopefully it’s going to be often enough. What is it about? I’m not exactly sure yet. So far the idea is to document stuff I’m working on. Posting my solutions to problems I have. Hopefully something comes of this. If you learn something, awesome.
If you can help me out in what I’m doing by pointing out stuff I miss or have wrong, even better. Ok well not better.. I guess it’s just as awesome as you learning something. I don’t want to be selfish here.
A few things to keep in mind. I’m not the best writer. I plan on using spell check. If you’re going to grammar Nazi me,
be cool about it please. No one likes a douche.
Oh and bare with me while I learn this octopress stuff.