How to automatically turn off/on a laptop when plugged in/off

9,548

Solution 1

Sleeping the computer when power is lost

Power management in Windows has supported the ability to put a computer to sleep when disconnected from power (running on batteries) for years. Open your Power Management controls to do this: powercfg.cpl

Waking the computer when power is restored

This one is harder because it requires a hardware signal. Some BIOS support the ability to turn the computer back on when power is restored, but exactly a case like this, however I have not seen any laptop BIOS that offer this option, only desktops.

The best option would be "Wake On LAN" which is more likely to be supported by your BIOS. However, this will require an additional piece of hardware that can send a "magic packet" which is what provides the signaling part of the Wake-On-LAN function, and finding this piece of hardware will be the more difficult part of this setup.

Some routers may offer this function, as may some UPSes with network capability. In my experience though, the equipment that offers this function tends to be enterprise-class, which for you means "pricey". A router running third-party firmware could possibly be configured to send a Magic Packet when it is powered back on, and, frankly, if your laptop supports Wake On LAN, this option has the best chance of being the cheapest possible decently reliable way to accomplish what you want.

Solution 2

Your laptop should have a lid close sensor, which is typically magnetic. It's easy to locate if you slide a steel object around the keyboard, touchpad and screen: it will get attracted by a permanent magnet at some point. The sensor is located on the opposite side from the magnet (so, if the magnet is in the display, the sensor will be in the keyboard and vice versa).

It's usually possible to fool this sensor using an electromagnet to simulate the lid open / close events, which can then be assigned actions in power management. The advantage is that electromagnets are quite cheap and easy to find, and you don't need to open the laptop and modify anything inside to install one. However, you may need to experiment quite a bit to get this working. In my experience, a small relay coil connected to a wall wart in series with a large capacitor generates a sequence of lid close and lid open events which consistently wakes up my laptop. YMMV.

Share:
9,548

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin almost 2 years

    I have a Dell Inspiron n5110 laptop and I'm hoping to set it up as a 24/7 home server. Power outages are very common in the part of the world where I live, so I was hoping to set up something which will automatically put my laptop to sleep when power cut happens and automatically wakes it up once the power is back. My laptop battery only lasts about 50 minutes when the laptop is running but it can last days when it is in sleep mode.

    • Admin
      Admin over 7 years
    • Admin
      Admin over 7 years
      This is not a duplicate of that question @acejavelin as OP has asked both how to shut down AND how to turn on when power is restored. There is an existing question for the power restore question, but it has not been answered yet, and offers no clues for this.
    • Admin
      Admin over 7 years
      @music2myear Perhaps, but this is really two distinct issues. Shutting down on loss of AC power is a function of the OS and powering on when it's restored it would be the job of the BIOS.
    • Admin
      Admin over 7 years
      And a full answer would include both of those points.