Do the following:
-
Get one of these (relay power strip): https://www.amazon.com/gp/product/B00WV7GMA2/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1
-
Make one of these (Octopi): http://octoprint.org/ (I suggest this for simplicity https://github.com/guysoft/OctoPi)
Once you have Octoprint up and running…
-. Hardware and setup:
- The relay only needs a GPIO pin (3.3v) and a ground pin. I used board pins 7&9
- Install WiringPi (https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/)
- Edit the init.d/octoprint file as described under https://github.com/foosel/OctoPrint/wiki/Controlling-a-relay-board-from-your-RPi#using-a-grove-relay-with-the-octopi-image
- Edit the config.yaml script under .octoprint and under the system section, add the two clocks of scipt; one for ON, one for OFF
Remember, there are two ways to refer to GPIO pins; board, and BCM. Board means the physical pin number, BCM means the port number. Above, when adding the line to the init.d/octoprint file, the entry assumes BCN. So in this case, if you are using physical GPIO pin 7, its BCM address is 4.
So what you have in the end is this:
init.d/octoprint:
gpio export 4 out (line 77, where export makes GPIO available to octoprint, 4 sets the BCM pin number (pysical GPIO pin 7), and “out” sets the GPIO as outputing the state [1 or 0, on or off] )
RETVAL="$?" (existing line)
Your config. yaml looks like this:
**system:
actions:
- action: printer on
command: gpio -g write 7 1
name: Turn on the printer - action: printer off
command: gpio -g write 7 0
confirm: You are about to turn off the printer.
name: Turn off the printer**
Note: You can make the text in “Name” and “Confirm” anything you want.
So there ya go, what you get in the end is an install of "WiringPi ", a pair of normally OFF and a pair of normally ON plugs in a relay controlled power strip. Two wires leading out the side that plug into your Raspberry Pi, and a couple of new commands in Octoprint for turning stuff on and off.
Credits go to:
Gina Häußge (foosel) aka Ms. Octoprint!
Digital Loggers Direct (https://www.amazon.com/gp/help/seller/at-a-glance.html/ref=oh_aui_sellerprofile_o00_s00?ie=UTF8&isAmazonFulfilled=1&marketplaceSeller=1&orderID=106-4833551-0540255&seller=A3D4241373L385) for making cool stuff like this relay.