Introduction: RaspberryPi Web Server Rocket-Launcher
Have you built one of those pneumatic air cannons as a kid? Looking back, they seem quite disappointing. Hours of savagely pumping air, only for a small burst of air.
Thankfully, with a little Raspberry Pi Iot and an industrial air compressor, this childish rocket launcher will no longer be wimpy.
In this project, we will be building a web server on the Raspberry Pi, and will build an online interface for launching from anywhere in the world (or on your network).
Some HTML and PHP experience will be very helpful. However, if those languages are new to you fret not. You can easily learn them with this books and this website.
Without further a do, let's keep the excitement alive and start building.
Step 1: Bill of Materials
This will be an expensive project ~$150 if you have some electronics and ~$230 if you need to purchase them.
The Air Cannon (~$60):
- 2" PVC Pipe: 6ft total
- x2 right angle 2" PVC elbows
- x2 2" PVC connector T
- 3/8" Air vinyl tube
- 2" -> threaded 3/4" reducer
- 2" -> threaded 1" reducer
- Air Hose Component:
- 3/4" threaded -> 3/8" threaded brass reducer
- 3/8" threaded -> 3/8" vinyl tube adapter
- x2 hose clamps
- Bike valve
- Firing Mechanism (will need soldering iron, hot glue gun):
- x1 Relay (rated at least 9V for Voltage input)
- x1 diode
- x1 sad red LED
- x1 9V battery holder
- x3 servo extension cables
- x1 NPN transistor
- x1 Raspberry Pi 3 Model B (with mouse, keyboard, monitor)
- x1 Breadboard
- x1 Raspberry Pi Ribbon
- x1 Raspberry Pi Cobbler
- 22 gauge hookup wir
Paper Rockets (~5 cents):
(Grant Thompson's design + my adjustments)
- Printer Paper
- Electrical tape (lots of it)
You can get most of the electronics for cheap at here, and the hardware at Home Depot
Step 2: The Rocket Launcher
I adapted this design from MAKE's air-compressed rocket launcher, and Grant Thompson's launcher. This cannon holds about twice the volume of air as MAKE's, and uses a similar bike pump mechanism as Grant's
The build took me less than hour to cut and fit, and about five hours to dry.
1. Use a hack/buzz saw to cut the 6ft of 2" PVC into: 3ft (you may want to take off 2" to make both cylinders even), 1.5 ft, 1' 2", and two 2" pieces.
2. Bike Pump System:
- Cut of the plastic on the bottom half of the bike valve until it fits into the vinyl tubing, then clamp it shut
- Cut the vinyl tubing to desired length (longer may be better)
- Connect the other end of the tube to the 3/8" tubing adapter
- Add Teflon tape to: 3/8" tubing adapter, 3/4" male to 1" female elbow, 3/4" to 1/4" reducer
- Use a wrench to screw it all together
3. Connect the 1.5ft and the 1' 2" with the Connector T and add an end cap
4. Connect the second 2" connector T to the 2" inserts (one per side), and the two 2" elbows to the to the inserts (see picture)
5. Top Half:
- Connect the 2" to 1" reducer to the top 2" T, then thread in the 1" pipe
- Connect the Sprinkler valve to the 1" threaded pipe
- Thread in the 1" to 3/4" reducer, the 3/4" pipe, and the 3/4" to 1/2" reducer Add the 1/2" pipe
6. Once everything looks like the pictures above, prime all the joints, add PVC cement, fit them with a rubber mallet, thread in all the missing pieces, and let sit for five hours
Step 3: Electrical
The circuits here are pretty straight forward. We are using a relay to connect a 9V battery to the sprinkler valve to open it.
1. Make the circuit on a breadboard from the schematic in the first image. (You can test the relay with the Pi, you don't need an Arduino)
2. Connect one wire of the sprinkler valve to -9V, and the other to one end of the relay. Connect the other end of the relay to +9V
3. Connect the Pi to the breadboard with the Cobbler and the Ribbon, connect 5V and GND as in diagram. Use gpio 17 for base connection
2. Test the circuit with root commands to echo 1s and 0s to the pin:
$ echo 17 > /sys/class/gpio
$ cd /sys/class/gpio/gpio17
$ echo out > direction
$ echo 1 > value
Step 4: Apache Web Server
Now we're getting to the heart of the project. We will be creating our own web server on the Pi using PHP / HTML. Check out this instructables and the books mentioned in the intro if you are not familiar with these languages.
If you do not have Apache and PHP installed on the Pi, it's time to install them.
- Connect the Pi to ethernet if your wifi is weak, this will make everything run much faster, make sure your Pi is up to date, and run the following command
$sudo apt-get install apache2 php5 libapache2-mod-php5
Now, use your other computer to type in the Pi's ip address into a browzer, you should see the following information in image 2.
2. Navigate to /var/www/html, and delete index.html (with rm command), and type in
$sudo nano index.php
Between <?php and ?> is PHP code. Within these tags, write "phpinfo();" and exit nano with ^X (save it of course). Now, if you log onto your Pi's ip address you should see a purple table with lots of information.
Step 5: Adding HTML
Here is where everything comes together. We will first test the server with an LED, then replace it with the relay circuit from before.
1. Edit index.php to this
<?php include "serverside.html"; ?>
2. Copy "serverside.html" to /var/www/html (with cp) (you'll have to change the file from .txt to .html by renaming it)
3. Make a folder called PHP (with mkdir) with the following code inside "RaspPi.php", a folder called css with "page.css", and another one called images with "button.jpg". Place all those folders into /var/www/html
<html> <body> <?php
system("gpio mode 0 out"); //set pin 17 to output
//set pin HIGH for 3 seconds system ("gpio write 0 1"); sleep(3); system("gpio write 0 0");
echo $_POST["user"]."just fired the rocket on".date("l m/d/Y")." at ".date("h:i:s a");
You're done! Time to test.
Step 6: Testing
To test, log onto your pi's ip address from a separate device (phone, tablet, computer) (you MUST make sure that the device is connected to the same network that you made your server on), you should see the following (image 2) if not leave a comment and we'll work to debug
When you press the button, the LED should turn on for three seconds, then turn off.
Once the LED work, re-wire the relay circuit, pump up the cannon to ~100psi, place this rocket on the nossle, log on to the server, and launch from anywhere.
Have fun, but don't launch into your neighbors' backyards (trust me, it's much better to go to a park)
6 years ago
I love it! Never mind all the "internet of things" home automation nonsense: what we need are more web-enabled personal rocket launchers!