Have a problem with my wireless bridge. It works for a some time then, despite it saying everything it fine, refuses to connect wirelessly. All it needs is to be turned off and on again and it works again (for a while!).
I decided that what was needed is some form of circuit to reset the unit on a regular basis, say every 15 minutes. With my Arduino I setup a system that waits 15 minutes then cycles the bridge off for 5 seconds and on again for 15 minutes.
Step 1: Program
Here is the Adruino sketch for the circuit. The output is on pin 7 and a manual reset button is attached to pin 5. The timing is done using the millis() command so that extra functionality can be added into the loop (like scanning the manual reset button) without effecting the rest of the timing. Some other time I may look at maybe adding in a couple of 7-seg displays to display the time remaining.
The on and reset times can be changed in the relevant lines. The on time (rstdly) is set in minutes where the reset delay (rstoff) is set in seconds.
See the comments for further descriptions of the program.
#define relay 7 // Pin for output switcher
#define rstsw 5 // Pin for manual reset
// Set following to change time in min for reset delay
#define rstdly 15
// Set following to change off time in sec
#define rstoff 5
unsigned long old_time;
unsigned long cpr_time;
unsigned long dly_time;
unsigned long off_time;
byte rstswitch = 0;
void setup()
{
pinMode(relay, OUTPUT); // set relay for output
pinMode(rstsw, INPUT); // reset switch for input
off_time = rstoff * 1000; // calculate mS delay for off time
dly_time = (rstdly * 60000) – off_time; // calculate mS delay for wait time, less off time to maintain timing
}
void loop()
{
digitalWrite(relay, HIGH); // switch output on
old_time = millis(); // get current time
cpr_time = millis() – old_time; // calc how long delay been running for
while (cpr_time < dly_time) // wait for delay time
{
cpr_time = millis() – old_time;
rstswitch = digitalRead(rstsw); // get switch state
if (rstswitch == 1) {break;} // if switch pressed break loop
}
digitalWrite(relay, LOW); // turn output off
old_time = millis();
cpr_time = millis() – old_time;
while (cpr_time < off_time) // wait until off time has passed
{
cpr_time = millis() – old_time;
}
}
For more detail: Auto reset stuff with Arduino