Smart Arduino Energy Monitor | ESP32 + Raspberry Pi + Home Assistant
Introduction: Smart Arduino Energy Monitor | ESP32 + Raspberry Pi + Home Assistant
Hello to everyone, today I am going to show you a project that I've been working on for a while, it consist on an ESP32 based Smart Energy Monitor that takes current and voltage samples through sensors in our power grid and shares the data to a local server made with Home Assistant and Raspberry Pi.
If you are a visual learner I know that a video worth more than 1000 words, so here is a 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
The electronics discrete components as resistors and transistors will be attached in a BOM file in the PCB Step.
🛒Materials:
1. -Current sensor (CT)
2. -Sensor de voltaje (PT)
3. -OLED Display
4. -Adafruit ESP32 Feather
5. -Jack de audio hembra 3.5mm
6. -Conectores hembra SIL
7. -Varistor, 240v-200ma fuse,choke coil.
Step 3: Circuit Diagram
Here is the Circuit Diagram of our project:
It has all the internal connections of the circuit that will allow us to create the PCB design later.
I also attached the PDF of the Schematics so you can see it better.
Step 4: PCB Design, Gerber, BOM and Pick & Place Order
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 1-4 layers PCBs ⚡ + 🎫 SMT Coupons
⏬Download Free Gerber, BOM and Pick & Place files
Un Zip de .rar file with a software like WinRar or any other.
Step 5: Project Enclosure (TAKACHI)
I request a free sample of this TAKACHI enclosure for my project, you can instead 3D print yours with the dimensions shown in the PDF.
Step 6: Assembly of the Board
To start taking everything together follow these steps:
1. Connect the push button to the PCB
2. 382
Connect the OLED display to the PCB, the code is made for the SPI configuration.
3. Connect the AC cable in the PCB terminal block (strip wires)
4. Connect the voltage selector switch
Step 7: Programming the ESP32 (GitHub)
Go to my Github repository and follow these steps:
1. Install the Arduino IDE
2. Install the ESP32 card package by copying this URL in IDE preferences: https://dl.espressif.com/dl/package_esp32_index.j...
3. Deploy your server in Home Assistant
4. Clone this repository
5. Install the attached ZIP libraries
6. Open the Arduino code
7. Modify the **Clavis** variable with a long-term Token generated in your Home Assistant
8. Modify the variable **serverName** with "http://(IP of your Raspberry Pi):8123/api/states/sensor.meter_ai", Ex: "http://<IP_ADDRESS><PHONE_NUMBER>:8123/api/states/sensor.meter_ai "
9. Connect your ESP32 and load the program on the board
Step 8: Configure the Home Assistant Enviroment
To make everything works, follow these steps in your Home Assistant system:
1. Open your home assistant by searching it in your browser.
2. Go to Supervisor> Adds on and install InfluxDB, Grafana and File Editor.
3. Open the File Editor and search for the *Configuration.yaml* file
4. 977