I am confused by your code:
But first things, you test to see if it is already LOW? to say it is on, but then set it HIGH to be on? Shouldn't it maybe be, checking for HIGH versus LOW.
There are two MCP23017's.
mcp1 is driving the relays.
mcp2 is 230VAC feedback.
If the pump is running (has 230VAC) then GPA0 on mcp2 is low.
That means "Pump already running" no need to set mcp1 GPA0 (pump relay) high.
That print is a placeholder. Later i want to send the pump state back to the RFM69 button LED that i know in the bathroom that warm water is already there.
The goal is:
1. run pump only one minute and only if it did not run the last 10 minutes
2. if feedback mcp2 low (pump already running/don't turn it on) = send RF to button blue LED on for 5 seconds (tells me warm water is there)
3. if feedback mcp2 was low the last 10 minutes (don't turn pump on) = send RF to button blue LED on for 5 seconds (tells me warm water is there)
4. if feedback mcp2 longer low than 1 minute = send error message (because something is wrong)
5. if mcp1 digitalRead HIGH and feedback mcp2 LOW in under 2 seconds = send RF to button red LED on for 5 seconds (tells me the pump is working after button press)
6. if mcp1 digitalRead HIGH and feedback mcp2 not LOW in under 2 seconds = send RF to button blink red LED fast + send error message (tells me something is wrong pump does not work)
Sure the blink/LED stuff is done in the buttons microcontroller.
Your code:
So i call "recirculationPump" with my button < this does not run in a loop.
I start "checkRecirculationPumpTimeout" in the main loop when the Teensy is powered < this loop is running all day long.
The code above ignores a second start. If you instead wish to restart the timeout
I guess that is something i need to work out when i start the timer based on the goals above.
1. I can start it if the pump is really running (has 230VAC).
2. I can start it if i call "recirculationPump".
3. I can start it if mcp1 GPA0 goes HIGH.
To me number 1 makes sense.