We've set an Arduino uno that controls a relay board. The relays are excited when set to LOW, and do nothing while receiving a HIGH signal. This relays are used to open/close doors and we're facing a big issue because the doors are being opened "by their own" maybe 1 time per day or maybe 1 time in 2 or 3 days (random fashion)...
We've seen that our system doesn't send (AT) commands to open the doors and we are suspecting that the Arduino HIGH output voltages may drop for some ms and then the relay board detects this as a signal and the relay gets excited...
So, now the software question...
How can I read the real pins output and check if there are any moments where the voltages become LOW while these OUTPUT pins are set to HIGH? To do this, I've read other questions on SO and I've done the following:
const int PIN_GARAGE = 3;
void setup() {
Serial.begin(9600);
pinMode(PIN_GARAGE, OUTPUT);
digitalWrite(PIN_GARAGE, HIGH);
}
void loop() {
// Ommited code that processes commands sent to the Arduino
if (!digitalRead(PIN_GARAGE)) {
Serial.print(millis());
Serial.print(" LOW VOLTAGE ON PIN ");
Serial.println(PIN_GARAGE);
}
}
I'm not sure if doing a digitalRead()
on an OUTPUT
pin set to HIGH will always return 1
instead of the current real value, which is what I do need.