Introduction: Auto Reset Stuff With Arduino

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;
  }
}

Step 2: Circuit

The circuit is a simple button and transister switch. The transistor could be changed to a relay so that larger voltages/currents could be switched. As the bridge I use runs off of 9v its power supply can power both the Arduino, breadboard circuit and the bridge, no need for additional PSUs.

I haven't done an Eagle file for this as it is quite simple and I have had problems with Instructables website changing file names (no offence Instructables!). So a small apology for the hand drawn circuit! As it is so simple construction on a breadboard is easy so I haven't worried about that here.

The transistor needs to be able to carry the load that you are going to be placing on it.