DIY Real Energy Meter With Arduino and ESP8266

22,074

88

16

Introduction: DIY Real Energy Meter With Arduino and ESP8266

About: I'am an Electronics student that really enjoy making new things from garbage, and DIY projects. I am here to share my knowledge with you, and learn with you too.

It is not a mystery that we usually have doubts about the energy consumption records presented by the bills.

For this reason I set out to create my own energy meter to be sure of what is really happening, if we are being lied to and if we are really being deceived.

Here I leave you a tutorial with all the information so you can make your own version.

If you are a visual learner I know that a video worth more than 1000 words, so here is a 2 parts Tutorial video. (I am a Spanish speaker, so please consider turning on English subtitles):

Step 1: Skills Required:

This project may seem difficult or very complex, but it is definitely not completely, since you will have all the guidance for the construction, it was difficult for me to design it to make life a little easier for you. Any conceptual doubt, you are free to ask it without problems.

You should have an understanding of:

  • Basic electronics. (We are going to be using some electronics principles that are good to know to understand how this meter works).
  • Handling of cutting tools and drills.
  • How to solder. (To place the components we need).
  • How to use a meter intruments as multimeters and clamp meters.
  • Writing code in C. (if you want to make any modification to the main code that is provided).

Step 2: Components and Parts List

Step 3: Circuit Diagram

Here is the Circuit Diagram of our project:

It has all the internal conections of the circuit that will us allow to create the PCB design later.

I also attached the PDF of the Schematics so you can see it better.

Step 4: PCB Design and Ordering

For the implementation of a good project we need a reliable assembly for the circuit that makes it up, and there is no better way to do it than with a good PCB.

Here you can download the Gerber, BOM and Pick & Place Files, the ones you need to order your PCB on your PCB manufacturing company.

I suggest JLCPCB:

📦$2 for 5 PCBs & cheap SMT (2 Coupons)

Un Zip de .rar file with a software like WinRar or any other.

Step 5: 3D Base for the Circuit

We are going to put (well, in my case), the circuit inside the Breakers box of my house, so I designed a plastic protection base for the circuit to be apart of the metal parts and wires that are inside the panel.

You can download the STL file to print your own if you have a 3D printer o Hand make it with plastic, cardboard or something that isolate electricity.

Step 6: Programming the Arduino Board and the ESP8266

We are using an Arduino nano because of it ADC pins, pins that we don't have on the ESP, so we first need to upload the program into the Arduino board that will be reading the data from the sensors and making all the maths that will allow us to get the Real Power, Power factor, Current, Voltage, and on.

1- To program the Arduino we need to connect it directly to our PC through the USB cable, open the Code "Arduino-Code", install the libraries that I also attached and click on upload.

2- To program the ESP8266 we need to place the jumper on (PROG position), connect the USB to TTL converter to our PCB on it respectives pins and then to our PC, install the libraries and then upload. (Need to have the ESP8266 Packaje installed on your IDE).

HERE YOU CAN DOWNLOAD THE CODE AND LIBRARIES

Step 7: Install the APP and Set It

  1. Go to Google Play Store and install the app (Just for Android by now, Apple Developer Fee is high for me).
  2. Open it and it will show you a big blue button (Config), click on it.
  3. Select your Ubidots Plan.
  4. Intro your Ubidots Token.
  5. Write the name of your device ("This device will be created automaticaly on Ubidots when you hit save button").
  6. Intro your Electric rates. (it's in dominican pesos by now because I don't know how other countries count your consumtion of energy, let me this in the comments about your country for an App Update).
  7. Place the Alarm Kwhs number and activate the toggle button (when the energy used this day exceed this number, you will get a notification).
  8. You will be able to see all your configurations down in the screen, and you are able to change it or delete it swiping the configs to the left and clicking "delete".

Step 8: Turning the Meter On

Before turning on the device, change the prog-use jumper to use mode.

The board is powered by the micro usb arduino connector. (connect it to a 5v usb adapter).

The board will automaticaly generate a Wifi network called ESP#######, click on it, and a WiFi manager will appear.

Scan and select your house network and you will be able to see that the screen will start showing data, and the App too.

They won't be real measurements because we don't have our sensors connected yet.

Step 9: Placing the Device

  1. Measure and drill some holes to the metal cover of the breakers panel.
  2. Screw the board with the 3D printed protector, place the sensors inside the box and connect them to the board.

Step 10: Ubidots Enviroment

Once you have installed the app and set all your credentials, "TOKEN" and "Device Name".

In your Ubidots device section will appear the device you called before and a bunch of 8 variables organized as you can see in the picture (It's important tha they are in this order).

There are 3 especial variables, the Green ones, that won't be green in your screen, but you will need to click on them, take note of their "api label", delete them and click on "add variable" > "synthetic" > name it as the green ones I showed you, and in the synthetic expression textbox add the text you see in the pictures in the respective textbox.

For kwlm = sum( {{kwh}}, "1M" )

For kwm = sum( {{kwh}}, "1M" )

For kwt = sum( {{kwh}}, "1D")

Note if this changes mess up the order of the variables, please delete them all and start creating them in order:

  1. "irms" (Raw).
  2. "kwlm" (synthetic). = sum( {{kwh}}, "1M" )
  3. "kwm" (synthetic). = sum( {{kwh}}, "1M" )
  4. "kwt" (synthetic). sum( {{kwh}}, "1D")
  5. "kwh" (Raw).
  6. "pf" (Raw).
  7. "potencia" (Raw).
  8. "voltios" (Raw).

Then you can create an Ubidots Dashboard with the charts and widgets you want, showing the data of your variables.

Step 11: Testing It

Here you can see that we have the measurments made by real instruments and the data showed by our device and they are plenty the same, that means that our system is doing a great job.

During the days the device is working and taking notes of the consumption data, you will be able to watch it in the app like the pictures shows.

Be the First to Share

    Recommendations

    • Metal Contest

      Metal Contest
    • Fruit and Veggies Speed Challenge

      Fruit and Veggies Speed Challenge
    • First Time Author Contest

      First Time Author Contest

    16 Comments

    0
    MyTechRock
    MyTechRock

    10 months ago

    Really Great And Very Nice Project ... Is It Possible To Use 2-3 CT Sensor ........

    0
    mcmchris
    mcmchris

    Reply 10 months ago

    Yes, there's a library that allows you to measure from +1 CT sensors!

    0
    guillermov38
    guillermov38

    10 months ago

    Great project! sadly pcb design does not complies with espressiff recomendations. The ESP01 antenna must have 15 mm clearance in all directions, including above and below. this is for optimal RF range

    0
    mcmchris
    mcmchris

    Reply 10 months ago

    Thanks for the advice, I haven´t read the espressiff recomendations, it is a good point to have in mind for a next version!

    0
    langtupt
    langtupt

    1 year ago

    hello mr. TheCyclist, i have funding for you download code, maybe covert code to esp8266 or eps32 using blynk or mqtt code?.
    Thank you very much

    0
    mcmchris
    mcmchris

    Reply 1 year ago

    Many thanks! Can you please tell me what you wonder or want the code to be?

    0
    langtupt
    langtupt

    Reply 1 year ago

    Yes, i want to code using mqtt and using blynk, kindly please help?

    0
    TheCyclist
    TheCyclist

    Reply 1 year ago

    @Mcmchris
    I would be open to assist with adapting to Blynk with Mcmchris's permissions since he's created an application

    0
    mcmchris
    mcmchris

    Reply 1 year ago

    Yes, Of course, do it! And share with me your creation! Enjoy the project

    0
    TheCyclist
    TheCyclist

    Reply 1 year ago

    I will work on this shortly and post a reply. I am currently working with this and an ESP32s

    0
    langtupt
    langtupt

    Reply 1 year ago

    @Mcmchris kindly please aprove for the code to Blynk.

    0
    vazquezjm
    vazquezjm

    Question 1 year ago

    Buen tutorial Chris! Te dejo una pregunta, se podria usar un ADC como el ADS1115 para reducir aun mas el hardware y por ende utilizar menos piezas? Me pregunto si los calculos los podria hacer el ESP8266 y enviarlos por ejemplo via MQTT (en mi caso). Gracias

    0
    mcmchris
    mcmchris

    Answer 1 year ago

    Realmente eso sería ideal, en mi caso la forma en que estoy intentando reducir el hardware es usando el ESP32 y sus pines ADC.

    En caso del ADS, si este nos brinda lecturas que podemos vincular a una variable que pudieramos integrar con la librería, pudiera funcionar.

    0
    opengreenenergy
    opengreenenergy

    1 year ago

    Excellent tutorial. This project is very useful.
    Thanks for sharing.

    0
    mcmchris
    mcmchris

    Reply 1 year ago

    Many thanks, thats my purpose actually by creating! 🙌