1 Reply Latest reply on Feb 8, 2020 7:56 AM by shabaz

    Omega2 as Irrigation Controller with only 3 GPIO


      I had bought a couple of Omega2 boards a while back and I thought I would use one for this project.

      The scope of the project was to use the GPIO to drive four Relays since it is a four Zone sprinkler System. Have Crontab pull the GPIO HIGH/LOW at a given time to drive the Relays to water the Lawn.


      I found out there are only three GPIO pins that can really be controlled. All of the others are tied to the CPU and such. I need four GPIO to drive the Relays as planned. However going through a Data Book for an idea on driving one or three GPIO pins to control four Outputs. I came across the 74138 that is a 3-line to 8-line Demultiplexer. However it is Active HIGH on the Outputs and pulls an Output LOW. I would think a Hex Inverter would work to "Flip the Bits" but the question is should I put the Hex Inverter on the Input of the 74138 or on the Output and tweak the Software to put the GPIO LOW to make the Output HIGH?

        • Re: Omega2 as Irrigation Controller with only 3 GPIO

          Hi Leland,


          If you want only one output high at a time, then the inverters have to be on the output of the '138, not on the input, because there's no entry in the truth table that can allow it based on any input inversion. The red highlighted area shows all rows have more than one output high in the truth table in the '138 data sheet:

          A '138 and inverter based solution means only one output can be turned on at a time, which might suit your immediate needs, but isn't very general-purpose for reuse in other projects. There are some other simpler ways. First, it is worth confirming that there really are only three pins available. If your project will never need more than 4 GPIO, then this should be easily possible with the Omega2 board according to the datasheet it has 18 I/O. But maybe you are using the remainder I/O or don't have access via some other board.


          As another idea, a more general-purpose solution is to use an I/O expanderI/O expander. It costs a bit more but it is still sub-$1. According to the Omega2 website, there is a relay board which by coincidence uses the same I/O expander IC. This means you've now potentially got the benefit of their ready-made relay control code if you use the same chip, and probably any tutorials people may have written with the Omega2 board and their relay board can be followed, such as this one: https://docs.onion.io/omega2-docs/using-relay-expansion.html

          Here's what the circuit could look like (the INT pin can be left unused) - the I/O expander datasheet has more information, or if you google that part number, there's dozens of projects/tutorials using it due to the popularity:


          With such a solution you've got 8 potential relay outputs, or you can use them for other purposes (as inputs, or for flashing LEDs etc), and you can reuse the same circuit for other projects, without running out of GPIO pins or needing inverter chips.

          1 of 1 people found this helpful