RK-1 | Mobile Robot Build
RK-1 | Catalogue of Mobile Robot Chassis
building an automated photo booth. The total build cost was around $150 as I re-used a lot of the components and materials I already had in my garage – in addition to what I could salvage from scrap yards.
Why? – I decided to build my own photo booth after trying to rent one from local photography studios. The going rate for a rented photo booth is around $600 in addition to the hourly rate of the attendent to watch over the equipment. As this was not in my wedding budget, and I did not want to deal with an additional vendor, I decided to build my own for under $200.
My Goal – Build an automated photo booth for under $200 – that could be easily operated by anyone at a party – and is durable and compact enough to fit into a compact car.
(Note* this photo booth does not print pictures. I have been working on a script that automatically uploaded the photo to flickr, but I did not finish it in time for the wedding. I’ll try and include that in a future post )
Step 1: How it works
The photo booth operation is simple. Users walk up to the back side of the camera – See themselves on the screen – Press a button and strike a pose.
The mechanics of the photo booth are a little bit more complicated, but ideally, the user never has to know what is going on under the hood.
The guts behind this photo booth are based on OSX lion. With Lion, the photobooth application can be extended to full screen and it can be set to use an external camera. So I connect a logitech web cam and an external monitor to a laptop running OSX Lion. The only thing i needed to build in addition to this hardware setup was an array of lights and a button (mapped to the enter key) to trigger the photobooth application to take a picture.
The “business end” of the photo booth can be seen in this step.
A few months ago I had left for a business trip and couldn’t remember if I had closed the garage door. Nearly all of us have done this at one point in our lives. I promised myself this would never happen again, and a new project was spawned!
- An Android application which posts commands to a web service. The Android application retrieves an authorization token from Google and sends it along with the requested command.
- The web service which listens for commands and credentials. These credentials are posted to Google to verify they are authentic. Once the user is verified, the command is executed.
I will be giving an overview of the project, but it is by no means a step-by-step tutorial. There have been similar projects online, but I couldn’t find any with detailed code on both sides (client + server). This should be a good reference for anyone who wants to do things like:
- Run Tomcat on their Raspberry Pi
- Authenticate users with Google’s OAuth 2 (both getting the token and authenticating the token)
- Interact with the GPIO pins of the Raspberry Pi directly in Java
- See how a basic Service to Activity (interaction / communication) model can look like in Android. I find this to be one of the most common questions asked by new developers
- Raspberry Pi Model B – It can act as the web service and physically interface with the garage door all in one device (rather than purchasing something like an Arduino, which would need a more powerful computer sitting in front of it to run the web service). Less is more.
- Edimax EW-7811Un USB Wi-Fi N Dongle – Since I don’t have CAT6 run out to my garage door opener (yet), I had to accept using Wi-Fi which I generally avoid at all costs. The chipset in this dongle (RTL8188CUS) is compatible right out of the box with the Raspberry Pi.
- Magnetic Switch – This is to determine whether the garage is opened or closed. This particular switch is fantastic for one reason; depending on which contact points you hook up to, it can be made either normally open or normally closed.
- Sainsmart Relay Module – Great little board that has relay isolation components already built into it. Separates the power supply from the signal with an optocoupler which protects your other components when the coil’s magnetic field collapses.
- Resistors – Miscellaneous resistors. Supplied link is a great pack that gives you a little bit of everything for home projects.
- Wiring of your choice.
- Control (toggle) the garage remotely, whether 5 feet away, or 5 countries away
- Check the state of the garage door, without needing to toggle / close it
- Do so from within an Android application
- Use Google as the application’s authenticator
- Take advantage of Android’s AccountManager
- Be accessible via HTTP so it could be extended to any platform in the future such as iPhone, iPad, or a simple web browser
- Run HTTPS so eavesdropping / replay attacks would not be possible
- Use an unsigned TLS certificate. There is no need to pay for one if you are the developer!
- WAF needs to be high.
- Low cost
- Must not affect normal operation of the door
- No pre-built solutions
- Rarely demonstratively secure
- Not extensible
- Not fun =P
- Authenticates the request with Google OAuth 2.0 with an subclass of RealmBase, GoogleRealm.
- Authorizes the user with a local file containing a line delineated list of valid users
- If there was a successful authentication and authorization, perform the required action, namely:
- Toggle the garage
- Get the state of the garage
- Pi4J – Java bindings which allows interaction with the GPIO pins on the Raspberry Pi. Being Tomcat is the web server, Pi4J was a perfect complement.
- json-simple – Java library which parses and extracts JSON messages.
In this application, the BasicAuthenticator is used to retrieve credentials. You may have been able to guess that BasicAuthenticator retrieves the username and password from HTTP basic access authentication. The username field contains the Google authorization token and the password field contains a shared secret among all users. The authorization token is requested with the scope oauth2:https://www.googleapis.com/auth/userinfo.email which, when posted to Google, allows the verifier to view the email address of the account that the authentication token is associated with.
I originally did not have this shared password in place but I soon realized that there was a security vulnerability in the application. Any service that you authenticate with using your Google account could post its own authorization token to your garage door opener and open your garage. In computer security, this is called the confused deputy problem. This can be mitigated by requiring an additional secret with all authorized users. With a shared secret, third party sites need an additional piece of information that only authorized users posses.
Once the user’s request is authenticated it is then checked for authorization against a line delineated local file which has a list of email addresses allowed to interact with the application. If that email exists, the proper Principal is then added to the request session and passed to servlet routing.
- Toggling the garage
- The garage door was fairly straight forward to interact with physically. I had a wall mounted control which toggles the garage door when two wires are shorted together (this is the behavior of most any door).
- When this module is activated, the garage is toggled. This module is controlled via the following wires: (Note – make sure you know which revision of the Raspberry Pi you have as their pins have changed!)
- 5V – Pin 02 on the Raspberry Pi diagram below (upper right pin) to label G on the relay diagram. This powers the relay coil.
- 3.3V – Pin 17 (fifth from the bottom, left row) to label F. This provides 3.3V as a signal current to the relay.
- 0V – Pin 25 to label E. This grounds the 5V supply. Note that the 5V and 0V are isolated via an optocoupler from the 3.3V connection(The schematic can be found here.)
- GPIO – Pin 11 (GPIO 17) to label B. This is going to be configured as an OUTPUT pin, and set LOW, which will activate the relay.
- The two top most screw-down relay holes (in the upper left) are what will be connected to each other when the relay triggers. These two wires will need to be run to your garage door in a manufacturer / model dependent fashion.
|Notated relay board|
- Checking the garage state
- This was accomplished with the magnetic switch listed above. One half of the switch is connected to the swinging door, the other half is attached to the door frame. In this case half of it was attached to the wall above the garage door, and half of it was attached to the garage door itself. When the garage door is closed, these two halves are within about a 1/4 inch of each other.
- Make a wire with an inline 1k ohm resistor (to prevent accidentally blowing out a GPIO pin).
- 3.3V – Connect this wire from Pin 1 on the Raspberry Pi and connect it to one side of the magnetic switch mentioned above (red, or white wire in diagram below)
- Connect a wire from the opposite side of the magnetic switch and run it to pin 12 (GPIO 18).
- When the door is closed, this circuit should be closed.
|This is the magnetic switch. The front side (closest in this picture) is attached to the moving door, the rear side is screwed into the wall. When they come within about 1/4 inch of each other, it toggles.|
|Sorry for the mediocre picture… it’s mounted on top of the opener.|
There are three interaction points in the application that this token is used for:
- Toggle the garage (actuate the relay which in turns activates the door)
- Close the the garage (toggles the garage if it is not in a closed state)
- Display the status of the garage (open / closed)
|Configuration Screen (accessible by hitting menu button)|
- Download the web service from Github.
- The Pi will need to be flashed with a soft-float OS in order to support Java. I used Debian Wheezy. You may find these downloads here.
- Open the GarageDoor project in eclipse (the web service)
- Export the following classes into a jar file and put them inside Tomcat’s lib folder
- Export the following classes into a jar file and put them inside Tomcat’s lib folder
- Create a file called “garage_users” and place it inside the home directory of the user that Tomcat is running as
- Add a user by entering an email on the first line of this file, with no spaces.
- Configure Tomcat to use a self-signed SSL certificate for the web app.
- Generate a war file in eclipse and load that file into the Tomcat manager.
- After the SSL certificate is generated above, we can generate our custom keystore that the application will use. Again, follow the directions on crazybob’s blog.
- Copy the generated file to res/raw/mystore.bks
- Change the password in GarageSSLSocketFactory to whatever was used when generating the keystore.
Odds are, you’ve played either Portal or Portal 2 and thoroughly enjoyed yourself in the process. And we can’t blame you – the game is incredibly unique and addicting! One Portal fan took his love of the game to the next level by modeling Atlas in 3D (from scratch), printing the model, and painting it by hand. Plus, he even used a 3D printed 1500 Megawatt Aperture Science Heavy Duty Super-Colliding Super Button as a base for Atlas. Read more: http://bit.ly/14e6sDr
Want to know more about 3D printer, visit our blog: http://www.sainsmart.com/blog/
So I’ve been messing around with arduino for about a year and a half or so now and still don;t have much hardware to show for it but I have learned enough to last me.
Currently I’ve gotten the arduino working with stepper motors, simple ethernet web servers, bluetooth communications, and use with the labview drivers. This post is for a project to entertain party guests with lights synced to music.
You can get the signal from the music being played by either splitting the signal going to the speakers by purchasing an audio splitter cable or you can use a microphone. While the latter doesn’t offer as much in ease of employment it is readily available in breakout module form from various micro-electronics shops.
I decided to go with the microphone approach, above you see the analog mic (right) and the audio analyzer (left)both from DF Robot. The mic sensor means I can utilize any audible source of sound for my lights or other uses. The analyzer takes in the music signal and produces data regarding the intensities at different frequencies in the signal, thus allowing us to hone out things in the music to use to activate the relays for the lights like the bass, mid, and treble of a song or just make the most ridiculous sounds we can to see where our voices register in the frequencies. The analyzer also comes with a arduino library to make things extra easy for us which can be found at DF Robot’s wiki site for the analyzer…you will need these libraries installed on your computer to be able to use my code example provided below.
The next step is reading the info from the analyzer and doing something with it. This is where my code and their library come in. I uploaded my code to media file HERE. After uploading the code to the arduino we need a way for the pins to de/activate the lights so we use some relays. Since mechanical relays have a finite life and create a bit of sound and typically require more than 5v to trigger, I went with a solid state relay. To keep things compact I ordered a pre-made 4 channel 5v SSR board from SainSmart which is perfect for the arduino. The arduino code defines which digital pins to hook the relay inputs to as well as which to hook the analyzer inputs to if you missed those in the analyzer wiki page.
At this point it is assumed you have the microphone hooked into the analyzer which is sending its data to the arduino which is telling the relay board which relays to activate. Now all that is left is hooking up the lights to the relay board. USA mains outlets have a Live and a Neutral and a Gnd, most light strands are only two wires though…dafuq?? No worries this is a common practice since when working with ac power we can use the N as a “ground” to complete the circuit thus eliminating the need for an individual ground wire, this is typically only used for low energy circuits such as led strips since they don’t require a heavy duty ground. To hook the light strands up to the relays simply find the L in the power cable and cut it leaving the N intact. Then plug the ends of the L wire into the screw terminals on the relay board and tighten them down. Plug the light cables into a wall outlet or power strip and you’re ready to jam. Below is a video of a 3 light (Bass\Mid\Treble) set up I fashioned my apartment with before a party. Definitely makes for an interesting beer pong game.
The device could be expanded to include a stepper motor or similar suitable output that would recreate the knocks exactly, just replace the output buzzer.
You could also use the piezo input sensor as the output buzzer by altering the code.
- An Arduino UNO or compatible board.
- An LED and appropriate resistor (I used 220R).
- A piezo sensor.
- A 1M pull-down resistor.
- A piezo buzzer or alternative output device (see page one notes).
- A breadboard and wires.
Step Two: Assemble
The configuration of the device is fairly simple.
- Connect the LED to pin 9 (via the resistor) and GND.
- Connect the output buzzer to pin 8 and GND.
- Connect the knock senzor to analog pin 0 AND GND.
- Connect your 1M resistor to the positive wire of the knock sensor and GND. This is used as a pull-down resistor.
Note: Be sure to check that my resistor recommendations are correct for the components you are using, including the lack of resistors on the two piezo buzzers.
Step Three: The Sketch
Upload the following to your Arduino.
Step Four: Knock it ’till you’ve tried it”