Who doesn't want to launch fireworks and model rockets remotely from their phone? This project will teach you how to set off any fireworks or rockets using your phone, laptop, or something else.
The concept is simple. The Raspberry Pi produces its own Wi-Fi network to serve the web app. Any device that connects to the Wi-Fi can access the launch interface through a web broswer by visiting ignitepi.local. After connecting for the first time, you can add the web app to your home screen with a custom icon to simplify the connection process in the future.
Wi-Fi over BluetoothYes, the same functionality can be accomplished with a Bluetooth board and the Blynk app, so why would you want to use a Raspberry Pi with Wi-Fi instead?
- Fast Auto-connect: Who doesn't keep their Wi-Fi on all the time?
- Connect to an existing Wi-Fi network: Control over the internet for an even longer range.
- Simple interface design: Customize your interface using HTML, CSS, and JavaScript. No need to worry about building custom iOS or Android apps and version compatibility.
In order to write scripts to toggle the GPIO pins on and off, you will need the command line tool called gpio from the WiringPi library. Most people can skip this step because it is included in most Raspbian installations. Run the following command to see if you have gpio installed:
gpio -v
If you can run this command successfully, skip this step. If not, use these instructions to install the latest version of WiringPi.
Step 2: Enable Ad Hoc NetworkIn most places where you would launch fireworks, you probably won't be near any Wi-Fi networks. Luckily, the Raspberry Pi can make its own ad hoc network that you can use instead.
To start an ad hoc network, you'll need to edit your /etc/network/interfaces file. But first, you need to make a copy of it in case you want to connect the Pi to Wi-Fi again.
cd /etc/network
sudo cp interfaces interfaces-wifi
Now, make a new file in the same location:
sudo nano interfaces-adhoc
This will open a text editor where you will paste the following code:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet static
address 192.168.1.1
netmask 255.255.255.0
wireless-channel 1
wireless-essid IgnitePi
wireless-mode ad-hoc
Now press Ctrl+X, Y, and Enter to save the file and exit the text editor.
Tip: To make things easier, you can make an alias for toggling between ad hoc and normal wifi modes.
nano ~/.bashrc
Type the following at the bottom of the file.
alias adhoc-enable="sudo cp /etc/network/interfaces-adhoc /etc/network/interfaces"
alias adhoc-disable="sudo cp /etc/network/interfaces-wifi /etc/network/interfaces"
Now save the file with a Ctrl+X, Y, and Enter. To use the new aliases, use this one-time command.
source ~/.bashrc
Now enable the ad hoc network with:
adhoc-enable
Step 3: Install DHCP ServerWe're almost ready to connect. But first, we need to install a DHCP server so that devices can connect to it automatically. Use the following commands to install it.
sudo apt-get install -y isc-dhcp-server
Next, edit the configuration file to specify the IP addresses it can lease. Let's empty the config file so we can write over it.
echo "" > /etc/dhcp/dhcpd.conf
Now, edit the file in the nano text editor:
sudo nano /etc/dhcp/dhcpd.conf
Then, paste the following lines in:
# Paste the actual code here.
# This is just a placeholder.
Save and exit with Ctrl+X, Y, and Enter.
Important: Make sure you reboot your Raspberry Pi before continuing.
Step 4: Install Apache Web ServerThe web interface is hosted by an Apache web server with PHP. This allows any phone or computer that visits the Pi's webpage to control the Pi remotely without needing to download a special app.
Install Apache and PHP with the following commands.
sudo apt-get install -y apache2
sudo apt-get install -y php5 libapache2-mod-php
Note: The -y option in the last two commands makes your life easier by automatically answering "yes" to all prompts.Step 5: Copy Code to Raspberry Pi
The Raspberry Pi is now ready to run the web app. Use this command to copy all the code from this project to your Raspberry Pi:
git clone https://github.com/frillweeman/IgnitePi.git /var/www/html
This will copy all the code to your /var/www/html directory on the Pi, which is where the live website files stored. All the code will be explained later in this tutorial, but for now, let's test out the connection.
From any device, look for a network named IgnitePi in the Wi-Fi menu, and connect to it. Now open a web browser on that device, and go to the address 192.168.1.1. You should see a webpage that looks something like the one on the phone in this picture. Congratulations! Your web server is working. Now, let's make it a little easier to connect.
Step 6: Install AvahiAvahi lets you access the Raspberry Pi using a name like ignitepi.local instead of a number like 192.168.1.1. To install Avahi, use the following command.
sudo apt-get install -y avahi-daemon
Now, change the name you will use to address your Pi by editing the hostname.
sudo nano /etc/hostname
This file will only have one line of text (usually "raspberrypi"). Change it to read "ignitepi" (without the quotes) or another name you'd like to call it. This is the name that will come before ".local" in the address.
Step 7: Wiring
Comments
Please log in or sign up to comment.