Main Content

Power Meter with ESP8266

Well I saw the smart air cooler project by Moiz where he switched the cooler on/off from his web app and I thought of extending it a little. While controlling an appliance from phone is cool, it doesn’t save you any money, right! So I thought what if we could see how our appliance is consuming power and tune our usage around that and eventually reduce our electricity bills by a few percent. So in this tutorial, I’ll show you how I built my IoT power meter that monitors current and power of appliances similar to the cooler. The power meter shows the current and power consumption graphs in the web app on my phone.

Let’s Talk Business!
I’m designing my power meter from the same commercial and production point of view as Moiz did: a company producing power meters and selling it to real users. So when the power meters hit the market, there will be real users buying them and using them.

Making them light and cheap gave me the idea of showing the current flow and power consumption in a web app (mobile app) instead of attaching an LCD on the meter (LCDs that can plot graphs are not an option for a $4 power meter).

Since I have real users, there are some issues here. Will my app contain all the power meters I ever sold till date? So when a customer downloads my web app, will he/she have to find his/her power meter from a huge list of all those power meters to see its power consumption? This not only makes it more complex than it needs to be but also compromises other users’ privacy. No way. There needs to be a mechanism that shows a user only his/her devices when he/she opens the web app. This hooked me up to the idea of setting up user accounts. Each customer would have to register his/her account on the web app when he/she buys a device from me for the very first time. To see his devices and their data, he/she would have to log in just like you do on facebook (you see your friends, your own posts, and your own groups, not everyone else’s). Now let’s move to the second issue. When a user logs in, how will the app know which devices (from the devices that I sold) does this particular user own? Pairing scheme solves our troubles here. When a user logs into the app, he/she sees empty list, and an “Add a device” button, on clicking which he could enter the device ID (which I would print on the device itself), and that device would be added to his/her devices list. What it’d do, under the hood, is it’ll pair that power meter with that user account making that account the owner of that device, and only he/she can see the device data.

Now to implement this, I went through the most common tools out there including Blynk. While those tools are good for prototyping a hardware project, they do not solve issues of commercializing an IoT product. Blynk’s app is non-customizable which means saying goodbye to my brand, it’s energy based model gets pretty expensive when you scale it to a few hundred power meters, and it solves none of the accounts and pairing issues for me. Not just for this power meter, if I’m selling anything in the market to real users, Blynk app looks very immature.

That’s when Grandeur Cloud came to the rescue. It’s pretty much designed for the IoT businesses. It is offered as a backend that solved pretty much all business, app, and hardware hassles involved in developing an IoT product (their words, not mine!). It’s open-ended. What that means is I can develop my own power meter (on device-end) and my own app (on user-end) and just connect them together with Grandeur Cloud as their integrator. So I no longer have to rely on the same Blynk app for every product I make — I can make separate standalone apps for each. They made available these SDKs to program the hardware (Arduino, ESP, Raspberry Pi) and apps (Javascript, Android, and iOS). In the App SDK, there’s this Auth API which lets you perform user authentication in the app. This means I can build register/login functionalities. And there’s the Device API, which lets you send/fetch data to/from the hardware device. It also has the pairing feature that I need. Feels neat!

Objective
Now that we know the base platform I’d develop my power meters on, let’s officially define our project:

An IoT power meter using ESP8266 and ACS712 current sensor that would send current and power readings to the app where I’d push those readings to a graph in real-time.

Along with this, a user would be able to pair a device and monitor the current and power readings in realtime after he/she logs into the app. Okay then”

Link to article