Introduction: IoT Power Module: Adding an IoT Power Measurement Feature to My Solar Charge Controller
Hello everyone, I hope you all are great! In this instructable I am going to show you how I made an IoT Power Measurement module that calculates the amount of power generated by my solar panels, that is being utilized by my solar charge controller to charge my lead acid battery pack. This module goes in between the solar panels and the charge controller and gives you all the necessary parameter details on your phone via the Internet. For the IoT platform I have used Blynk, which is very easy to use and can be easily customized as per your project. The limitation of the existing charge controller was that it only gave me the charging voltage and therefore the amount of power could not be determined. In this project I have added the voltage and current measurement functions to the power module which can be used to calculate power(in watts) and thus the total energy harvested. One can easily use this power module in other DC power measurement applications. This is going to be a fairly long instructable so lets get started!
- Arduino Pro Mini / Nano or equivalent
- LM2596 buck converter module
- 7805 voltage regulator
- AMS1117 3.3V regulator
- ESP8266-01 WiFi module
- OLED Display
- LM358 dual OP-Amp
- 100K,10K,2.2k and 1K resistors(1/4 watt)
- 0.1uF ceramic disc capacitors
- 22uF electrolytic capacitor
- Screw Terminals
- Male and female berg strip
- ON-OFF switch
- Perf board or veroboard
- Soldering equipments
Step 1: Gathering All the Parts and Finalizing the Layout
Once we have gathered all the necessary components, it is important that we carefully decide the layout of our board and placement of different components so that the wiring becomes simple and all the components placed close to each other. For attachment of the Arduino ,buck converter, WiFi module and Oled Display I will be using female headers instead of directly soldering the modules, this way I can use the components for maybe some other project, but you can directly solder the modules if you plan to make it permanent.
Step 2: Adding the Screw Terminals
First of all we solder the screw terminals that will be used to connect the solar panels as input and the charge controller as output to the power module. Screw terminals provide an easy way to plug in or remove devices when needed.
Step 3: Adding the Resistor Voltage Divider Network
For sensing the input voltage, a voltage divider network is used. For my application, I have make a resistor network using 10K and 1K resistor and I am measuring the voltage drop across the 1K resistor that will be given as input to the Arduino microcontroller. Additionally I have added a 0.1uF capacitor across the 1K resistor to smooth out any sudden voltage fluctuations.
Step 4: Adding the Shunt Resistor for Current Sensing
The shunt resistor is a resistor of very small value(typically in the order of milliOhms) in series with the load which creates a very small voltage drop that can be amplified using an Operational Amplifier and the output can then be given to arduino for measurement. For measuring the current, I am using the shunt resistor(which has a value of approximately 10 milliohms. I have made this using a steel wire and bending it to make a sort of a coil pattern) in the low side of the circuit,i.e, between the load and the ground. This way the small voltage drop can directly be measured with respect to ground.
Step 5: Adding the OpAmp Amplifier Circuit
The operational amplifier used here is LM358 which is a dual Op-Amp chip. We will be using only one Op-Amp as a non inverting amplifier. The gain of the non inverting amplifier can be set by using the resistor networks R1 and R2 as shown in the image. For my application I have chosen R1 as 100K and R2 as 2.2K which gives me an approximate gain of 46. The resistor and the OpAmp are not perfect so some adjustments have to be made in the arduino program to get good readings(we will discuss that in later steps).
I have also made a project on how to make a wattmeter for arduino here I have discussed more concepts in detail. You can check the project here: https://www.instructables.com/id/DIY-Power-Measurement-Module-for-Arduino/
Step 6: The Power Supply
To supply power to the Arduino, OpAmp, OLED and WiFi module I am using a LM2596 buck converter module to step down the input voltage down to about 7 volts. Then using a 7805 voltage regulator I am converting the 7 volts to 5 volts for the Arduino and the OLED and using an AMS1117 regulator, generating the 3.3V necessary for the WiFi Module. Why so much for the power supply you ask? The reason being you cannot directly plug in the solar panel to a 5 volt regulator and expect to to work efficiently(as it is a linear regulator). Also nominal voltage of a solar panel is about 18-20 volts which can be too high for the linear regulator and can fry up your electronics in a jiffy! So its better to have an efficient buck converter in place
Step 7: Fixing the Buck Converter and Regulator
First, I marked the positions where the pins of the buck converter would fit in. Then I soldered female headers to those points and male headers to the buck converter(so that I can easily remove the module, if needed). the 5V regulator goes just below the buck converter module and is connected to the output of he converter to give a smooth 5V for the control board.
Step 8: Adding a Switch
I have added a switch in between the buck converter and the solar panel inputs, in case I want to toggle ON or OFF the power module. If switched off, the power will still be delivered to the load (charge controller in my case), only the measurement and IoT functions will not work. The image above also shows the soldering process so far.
Step 9: Adding the Headers for Arduino and Fixing the 3.3v Regulator
Now I have cut the female headers in accordance to the size of Arduino pro mini and soldered it. I soldered the AMS1117 regulator directly between the Vcc and Gnd of the Arduino power supply (Arduino gets 5V from 7805 regulator which in turn supplies the AMS1117 for the 3.3v needed by the WiFi module). I have strategically placed the components in such a way that I had to use minimal wires and the parts can be connected via solder traces.
Step 10: Adding the Headers for WiFi Module
I soldered the female headers for the WiFi module just next to where the Arduino pro mini would fit.
Step 11: Adding the Components for the WiFi Module
The ESP8266 module operates on 3.3 volts and not 5 volts(applying 5 volts I observed the module gets very, very hot and most likely gets damaged if used for too long). The Arduino and the WiFi module communicate via serial communication which utilizes the Tx and Rx pins of the module. We can configure any 2 digital pins of arduino to act as serial pins using the software serial library of the arduino IDE. The Rx pin of module goes to the Tx of Arduino and vice versa. The Rx pin of ESP works on 3.3V logic so we use a voltage divider network of 2.2K and 1K to bring down the 5V logic level of Arduino to approximately 3.6V(which is still acceptable). We can directly connect the Tx of ESP to Rx of arduino as arduino is 3.3v compatible.
Step 12: Adding the OLED Display
To connect the OLED display we need 4 connections, two for power supply and 2 for he I2C communication protocol with the Arduino which is the A4 and A5 pins of the Arduino. I will be using a small jumper wire along with male header to connect the I2C pins and directly solder the power connections
Step 13: Final Look at the Modular Board
After finally completing all the soldering process this is what the board looks like! Yes I did have to use some wires at the end, but I was pretty satisfied at the outcome. The interesting part is the board is completely modular and all major components can easily be removed or replaced if need be.
Step 14: Putting It All Together
This is how the complete module looks like when everything is in place!
Lets get to the software part now...
Step 15: Programming Using FTDI Board
For programming this module I will be using the FTDI breakout board which is ideal to program Arduino Pro Mini. Its pin mapping is aligned perfectly so you won't have to use and jumpers or so.
Step 16: Schematic Diagram
This is the complete circuit diagram of the IoT power meter module. I have designed this schematic in Eagle CAD. Feel free to download and modify the schematic files as per your ideas :)
Step 17: Results!
I have completed the setup by connecting the power module between the solar panel and the charge controller and as soon as we power it up it connects to my WiFi router and the data is being constantly published on the Blynk app on my smart phone. This gives the real time data of the charging parameters no matter where I am, as far as I have internet connectivity! Feels great to see the project working nicely :)
For experimental purpose, I tested the setup using my 50 Watt solar panel and a 12V 18AH lead acid battery.
Step 18: The Arduino Code
Here is the complete Arduino code that I have used for my project.
There are a few libraries that you will need in order for this project to work properly those are:
The Blynk master Library
I hope this project was useful. Consider supporting my projects by sharing it with your community :)
Feel free to comment any feedback or queries that you have regarding this project. Have a great day !
This project helps me monitor the amount of energy I harvest from my panels. Let's take a step ahead to turn more towards renewable sources of energy to cut down carbon footprints and create a sustainable environment :)
Step 19: Tutorial Video
Participated in the