The Raspberry Pi relay hat I used for this project has four relays, each tied to a GPIO pin. I'm only using one relay to control a single ball valve. The project could be extended with zones, each zone on a relay, for up to four zones. Each zone would have its own schedule. We'd also need to have a flow meter for each zone, so we need to use additional GPIO pins for each flow meter.
Design changes:
- Modify UI with zone selector, 1-4. Each zone would have a start day/time schedule and a target gallons of water.
- Modify the core code to add the four zones to the state using an array. So turn this structure:
type garden struct { // omitted fields StartTime string StartDays [7]bool Gallons float64 GallonsGoal uint Running bool }
into this structure:
type zone struct {
StartTime string
StartDays [7]bool
Gallons float64
GallonsGoal uint
Running bool
}
type garden struct {
// omitted fields
Zones [4]zone
}
There would be other modifications to pass the zone number (0-3 for zero-based math) in the JSON messages that are passed around. For example, the start time message would go from:
type msgStartTime struct {
Msg string
Time string
}
to
type msgStartTime struct {
Msg string
Zone int
Time string
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.