I wanted to create my own, low dollar, solution for Home Automation and such. Jason Findlay does all of the software heavy lifting for you. Assuming you have a Relay hooked up to your Raspberry Pi, follow along.
- Install Wiring PI
- git clone git://git.drogon.net/wiringPi
- cd into the directory: cd wiringPi
- Run this: sudo git pull original
- then run: ./build
- Install Apache and PHP
- Run this command: sudo apt-get install apache2 -y
- Run this command: sudo apt-get install php7.0 libapache2-mod-php7.0 -y
- Create the PHP script
- Run this command: sudo nano /var/www/html/gpio.php
- Paste this code
- Save the page. You should now have a gpio.php file. This will drive the calls from the Android app.
- Download and Configure Android APP
- Search the Play Store for PiRelay and download the app: https://play.google.com/store/apps/details?id=com.jasonfindlay.pirelaypro
- Fire up the app and click on the Hamburger Icon in the top left to show the config sections.
- Click on the Pi URL Addresses option
- Enter the address to your Pi Example: http://192.168.1.200 (or whatever the IP on your Pi is. Run an ifconfig to see the IP)
- Click the Hamburger Icon in the top right corner again and Click Number of Relays
- Enter the number of Relays you will configure
- Click Hamburger Icon in the top right corner again and Click Setup Relays
- Click Relay 1
- Enter a name for the relay
- Choose the WiringPI Pin #. Use this as a guide
- Select a Relay Icon
- Choose the appropriate Relay type. The Relays I used were Active Low. Just play around with it until it works
- Then click the back arrow.
- You should now be able to toggle the relay and turn whatever you have plugged in on and off.
This may seem like a lot of instructions, but honestly it was very easy to setup and get rolling. If you have troubles head over to https://pirelay.jasonfindlay.com for help. You can also use the gpio.php page you built above to control the relays without using the Android app.
http://{your pi IP address}.gpio.php/?pin=1&status=0
http://{your pi IP address}.gpio.php/?pin=1&status=1
Use the Pin look up image I pasted above to specify the correct Pin number, this is the WiringPi pin, not the GPIO or Raspberry PI pin numbers.
0 comments:
Post a Comment