Controlling a WiFi smart plug with the Raspberry Pi

Lead Image © Dietmar Hoepfl, 123RF.com

Power Play

A switched and programmable electrical plug lets you start the Raspberry Pi at predefined times, saving power consumption, and a little Python code keeps you independent of the manufacturer's cloud infrastructure.

Switched electrical plugs are common, but the selection becomes smaller when the requirements for the plug include that it access a WiFi network and have a programmable interface. These features allow the Raspberry Pi to determine a start time on its own. The hack in this article succeeds with an Edimax smart plug and some Python code.

Forums are full of perplexed conversations concerning time-controlled shutdown and bootup for the Raspberry Pi because this small PC is known for its minimal power consumption. The thinking goes that the energy savings for a time-controlled setup would probably be limited. This argument stops short of actual reality, however, because the Rasp Pi rarely works alone. It often needs peripherals in the form of hard drives and USB devices, which consume considerably more power than the computer itself.

Familiar services such as atd and crond, or the shutdown command itself, can perform a time-controlled shutdown. For example, the following command shuts the computer down 10 minutes after entering the command:

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content