Use a Raspberry Pi to control a Powerswitch Tail through a web interface, app, or schedule it via cron. There are many possible applications, but I use it to control a dog food dispenser. The dog gets fed automatically every morning. And if we are out of town, I can control it with an app.
- Raspberry Pi
- Powerswitch Tail (https://www.adafruit.com/products/268)
- Wires to connect Pi to the Tail
Here are the instructions I used to wire up the Pi: https://thepihut.com/blogs/raspberry-pi-tutorials/27968772-turning-on-an-led-with-your-raspberry-pis-gpio-pins
I used NetIO UI-Designer (http://netio.davideickhoff.de/) to create a basic app. I added controls for all the endpoints listed below and it looks like this:
Endpoint | Description |
---|---|
/feed/status | Current power status (0 = OFF, 1 = ON) |
/feed/enabled | Current enabled status (0 = OFF, 1 = ON) |
/feed/enabled/on | Enable the system |
/feed/enabled/off | Disable the system |
/feed/timestamp | Current system time |
/feed/timer/:seconds | Turn power on for the given number of seconds |
I configured my router with port forwarding to send all port 8080 requests to port 3000 (the express server on the Pi). This allows me to control the feeder when I am not at home.
I use crontab on the Pi to feed the dog every morning at 7:00am for 60 seconds:
0 7 * * * /usr/bin/curl http://localhost:3000/feed/timer/60 > /dev/null 2>&1
The application is set to run every time the Pi boots via the following line in /etc/rc.local (be sure to place it before the exit 0
at the end of the script):
/home/pi/feeder/app.js &
Logs are placed in the application directory and rotate daily. A maximum of seven logs are kept.