Automated power strips allow on-demand and timer based control of AC outlets (110v or 220v). They are one of the easiest to build yet most useful controllers using reef-pi. For example, a power controller can turn on/off light or skimmer daily as well as allow on-demand controls like switching off ATO and return pump during water changes. This guide will go through step by step process of building a four outlet power controller. A beginner friendly guide is also available on adafruit.com.
The reef-pi software uses the Raspberry Pi’s GPIO pins to control digital relays, which in turn controls high voltage, high current AC or DC equipment. This mechanism is used across timer or sensor based (like temperature or ATO controllers) equipment controls.
Choice of relay: Controlling high AC voltages via Raspberry Pi involves relays. Relays can be optocouplers, mechanical or solid state. Mechanical relays are cheapest, optocouplers are safest and expensive. Solid state relays are somewhere in the middle, safer, more expensive and last longer than mechanical relays but cheaper more readily available that optocoupler. We recommend optocoupler based relays where price is not a factor, solid state relays where current requirements are low (less than 2 amp) and mechanical relays for beginners or anything else.
Relay capacity: Almost all relays are rated to work with a voltage and current range. Most mechanical relays are rated for 10 amp, 240volt AC, while solid state relays are generally rated for 240volt AC, 2 amp. Depending upon what type of equipment you will be powering, choose appropriate relays. Equipment is generally rated in watts, and watt = volt x ampere. For example, a 100-watt heater will require at least 1 amp relay to be powered safely by 110volt AC.
Number of relay channels: The number of channels in a relay board determines how many AC connections can be controlled. Since we are building a 4 outlet power strip, we’ll go with a 4 channel SSD relay. We’ll need one GPIO pin of Raspberry Pi for each channel on the relay. It is possible to control around 18 channel relays using the Raspberry Pi alone (it can be extended to thousands using an IO expander).
Follow the reef-pi installation guide to setup reef-pi on Raspberry Pi zero.
Enable equipment capability and turn off dev mode under setting section on system tab
Click on the Update button to save settings followed by Reload button to ensure the changes are loaded immediately. Refresh your browser (since reef-pi is reloading, it may take few seconds). You should see the Equipments tab now.
Navigate to System tab again and declare outlets. Use the GPIO pin numbers (not serial number) to define one outlet per relay channels. You can use the recommend pinout scheme to decide which GPIOs to use. They should mimic the exact wiring.
Note: the pin number represents the GPIO Pin number, not their position on the Raspberry Pi. Refer Raspberry Pi pinout diagram for GPIO numbers.
The outlet declaration is one-time procedure; it will not change unless electronics are updated.
Next declare equipments under the Equipment tab. Each equipment should have an assigned outlet.
That’s it, you should be able to use reef-pi to control all four equipments.
Any equipment specified in the configuration file can be switched on or off any time using reef-pi web interface. Use the equipment tab to navigate to the list of equipment and click on the on/off button to switch the equipment on/off. Every equipment should have a dedicated button indicating the equipment’s real-time state.
Timers in reef-pi allows automation of an action on a piece of equipment on a defined schedule.
In the following example, we are setting up the heater to start at night 10:00 PM and stop at morning 6:00 AM. Use the “Timers” tab to define two timers. Each timer represents an action reef-pi takes.
The first job starts the heater at night. reef-pi allows us to specify which equipment to take action against, time details (day of the month, hour, minute, second etc) and the action (on or off). Notice “*” is used to denote every day of the month.
And another job to stop the heater every morning 6 AM.
reef-pi uses cron style specification for denoting time schedule, this allows much more elaborate way of specifying schedules.
A typical schedule specifies day and time related details for the timer.
Following is a summary of the specification
Other than their mentioned ranges, each of this field can also take few special entries.
More details can be found in the underlying library’s documentation
Timers can be used to automate use cases like two part dosing, refugium light etc.
reef-pi uses one GPIO for rach outlet control. Thus, a single reef-pi can control at most 26 outlets (because there are 26 GPIOs). But a build using all 26 GPIO will not be able to support most other modules, since water level sensor (used for ATO) and mechanical swicthes/push buttons also uses GPIOs. But if you do want to use reef-pi this way, Disable spi, one wire , i2c and pwm via raspi-config utility to use all 26 GPIO.
It is safe to use reef-pi build can control at most 22 outlets. Enable i2c, pwm and disable spi,uart to use 22 GPIO pins. This leave 1 GPIO for water level sensor, 1 for temperature sensor and two for i2c communication (for pca9685 pwm IC).
If all GPIO pins are used up for relays, then none can will be left to be used for ATO or any other modules that require inlets (where GPIOs are used to read data). While planning, consider how many inlets (ATO, leak detector) or any other use (like mechanical push buttons, buzzers etc), total number of outlets and inlets has to be less or equal to total available GPIO pins. For example, a build for 2 ATO, 1 leak detector, 1 buzzer, 1 push button can support 17 outlet relays at max (2+1+1+1 + 17 == 22), while allowing temperature and ph probes.