Creating an interface for the smart plug

Commercial smart plugs usually come with a nice interface, which you can use from your phone or computer to control the plug via Wi-Fi. In this section, we are going to do exactly the same: build a simple interface that we will use to control the device connected to the smart plug, and also visualize the current and power consumption of the device.

As the code for this part is quite similar to the code of the previous section, I will only highlight the differences here.

Inside the Node.js JavaScript file, we declare the public folder in which we will store the interface:

app.use(express.static('public'));

Then, we need to declare to which pin we connected the output of the smart plug:

var outputPin = 18;

Using ...

Get Building Smart Homes with Raspberry Pi Zero now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.