DNS-323 Autostart after Power Failure

DNS-323 Autostart after Power Failure

I have a few old DNS-323 that I picked up for cheap. Although they are around 10 years old (as of 2016), thanks to some community firmware, they support drives larger than 2Tb. They’re not fast, but as a remote backup target they’re an excellent choice, since they can do OpenVPN, as well as rsync.

One major limitation is that they must be turned on when they’re first plugged in. This means if the power fails, the device will remain off until someone intervenes and presses the power button. My goal is to use these in a remote location that I will be able to access once every 2-3 years, so I needed a solution to automatically power them on should they experience a power failure.

When the device is off  but plugged in, the power supply is still delivering power. I chose to tap the power supply’s 5V to power the ATTiny and tap off the power LED on the device to determine if the power is currently on or off. The code below is a simple check that if the ATTiny85 is running (we have power), but the power LED is not on, then we must press the power button.

#define SENSE A3
#define POWERSW 1

void setup() {
  pinMode(SENSE, INPUT);
  pinMode(POWERSW, OUTPUT);
  digitalWrite(POWERSW, 1);
  delay(5000); // wait 5s before actually proceeding
}

void loop() {
  int systemStatus;
  systemStatus = analogRead(SENSE);
  if (systemStatus < 360) { // 0-1024; generally off is <10 and on is around 750, so 360 is halfway between off/on
    digitalWrite(POWERSW, 0);
    delay(2000); // must always hold the power switch when turning on; hold it for 2s
    digitalWrite(POWERSW, 1);
  }
  else {
    delay(2000);
  }
}

The DNS-323 has various versions of the hardware. In Revision B of the hardware, pressing the power button shorts a pin to GND. This means that my ATTiny85 will need to provide 5V to simulate the button not being pressed (if the device is running), and 0V if we want to simulate the button press. The code above does exactly that.

With the code finished and flashed to an ATTiny, I proceeded to locate the appropriate connections on the DNS-323 circuit board. Below is an image of the connections
dns-323

Red and black are +5V and GND respectively; brown is “Sense” (the power LED) and white is “PowerSw” (attached to the power button).

The ATTiny is soldered “dead bug” style, with a 1K resistor between the power on button and GPIO1. Since the ATTiny will be trying to keep GPIO1 at +5V, pressing the power button would directly short this to ground and blow the output buffer. The 1K resistor will prevent any problems here and is enough to signal the system to start up.

attin85-dns323

All of this is stuffed neatly back into the case. I’ll be running it for a few weeks, with a few simulated power outages before finally installing it in the remote location.

test