I try to check a relais. The relais is open for 5-10 minutes, then closed for until 15 minutes and so on.
I would like to start reading sensors as soon as the relais closes, in order to control the status of the sensors immediatly after closing of the relais.
After that should the program wait for the next closing.
I did write
if (pulseIn(relaispin, LOW) { ......
but it doesn't work. The sensor was readed the whole time while the relais was closed.
The Reference page for pulseIn() states that it is only good for up to 3 minutes so your 5, 10 and 15 minute timing may be the cause of your issue (assuming your parentheses error is a simple typo).
With such long timing, couldn't you simply poll the relay? Is it important to know exactly how long it was open/closed for? Your description make it seem like you just want the relay to act as an activation signal to start the sensors reading?
pulseIn is for getting the length of time that a pin was in a particular state. It doesn't make any sense in an if statement where it isn't compared to some number. Do you think digitalRead would be better? If you want to react to the relay closing then I think it would.
pulseIn is for getting the length of time that a pin was in a particular state
ok, that was a missunderstanding about the function of pulseIn. I see that is necessary to use something other instructions for my problem.
I think to use digitalRead to start the sensor sequence once and after that wait until the relay is changed and it’s time for a new digitalRead and a new sensor-reading.