Home > Power Circuits >Power Circuits > Battery voltage monitoring system with WiFi module developed based on NodeMCU

Battery voltage monitoring system with WiFi module developed based on NodeMCU

Source: InternetPublisher:偷熊计划 Keywords: Monitoring system battery voltage wifi module Updated: 2024/01/19

Measuring the voltage of solar panels, UPS, and other batteries used daily can take a lot of time. If a WiFi module is added to these devices, will it be more convenient to read the voltage? To this end, the microcontroller development engineer shared a battery voltage monitoring system with WiFi module developed from abroad based on NodeMCU.

Using this system a WiFi device connected to our local home WiFi can read the voltage from the controller and update the end user with the current battery level. For this purpose, nodemcu is used in this solution

WiFi module. Not only can it be used as a controller, but it can also connect itself to a WiFi network as a server or client. The battery monitoring circuit is a traditional voltage divider circuit. I want to measure a 12 volt battery. The circuit can be modified to measure 24 volt batteries, or even more 48 volt parallel battery banks.

Nodemcu is a small device that operates on 3.3 volts. Since it operates at 3.3 volts, its pins can only source and sink 3.3 volts. Voltages greater than 5 volts can blow out pins or fry the node MCU. In our case we want to measure the 12 volt battery, nodemcu

adc (analog to digital channel) can only accept 3.3 volts. We need to play smart here. What we want to do is divide the voltage between two resistors and measure the voltage across only one resistor, the remaining resistor voltage will be calculated mathematically. A typical voltage divider circuit and formula is as follows:

Typical Voltage Divider Circuit and Formulas

Next, let's calculate the values ​​of Rtop and Rbottom. Here we need to seriously consider some important factors.

(1) Low-ohm resistors will draw a lot of current, and the wire may heat up immediately. As a result, the wire may melt within seconds. Therefore, for larger amp hour batteries, always use a sufficient number of resistors. Here a resistor Rbottom of 10k ohms is chosen.

(2) During the charging process, the battery voltage may increase to 18 volts. For example, in full sunlight, a 150-watt solar panel outputs 17 volts at 6 amps, and the output voltage can even reach over 18 volts. The solar controller also outputs a voltage approximately equal to 15 volts, which can be used to charge the battery.

Formula calculation

I will measure the voltage across Rbottom and randomly decide its value to be 10k ohms. We know Vout can be as high as 3.3 volts because the nodemcu works and accepts a maximum of 3.3 volts on its I/O pins. Vin is 18 volts when the battery is charging, now we can calculate the value of Rtop.

Calculate the value of Rtop

Now, if there is 18 volts on the battery side, the voltage will be divided between the resistors, on the 10k resistor it will drop 3.3 volts, and on the 44.54k resistor you will be left with 14.7 volts. 44.54k

Are ohm resistors available? ? Not available on the field, I will use a resistor higher than that rating, can be found in any electronics store 47k

ohm resistor. If the battery is not charged and is said to be providing 12 volts, what will be the voltage drop across the resistor?

voltage-drop.png

From the above discussion it is obvious that the voltage across Rbottom will not exceed 3.3 volts now. I hope the calculation makes sense to the reader. Now the question is how to convert 3.33 volts to 12 volts by nodemcu or how to predict the voltage on the battery side to be 12 volts from 3.33 volts. There's more math involved here. Since the resistor value is fixed, we can calculate the voltage ratio across the resistor relative to the supply and use this in the code to represent the actual voltage of the supply. The ratio is calculated as follows:

voltage-divider-ratio_orig.png

Two cases are given above, when the power supply is 18 volts and when the power supply is 12 volts, both cases the ratio is a constant value. This ratio is used in the code to predict the actual power/battery voltage. The ratio is multiplied by the actual voltage value at Rbottom.

The scheme circuit diagram is as follows. I am using nodemcu's ADC0 channel to measure battery voltage. Both the battery and the nodemcu power supply must be connected to ground to complete the circuit. This is one of the most common mistakes and will measure the voltage of two grounds that are not grounded together. If the nodemcu ground is not tied to the battery ground, the adc0 pin will become a floating pin and start reading floating values.

Scheme circuit diagram

After completing the circuit, it's time to move on to coding. The code is using arduino

Written by IDE. I'm using the ESP8266WiFi.h library in my code, so first make sure this library is installed in the arduino libraries folder. If it doesn't exist, download it from github and install it first. Then enter the SSID and password of the WiFi network you want to connect to your nodemcu. Most likely it's your home WiFi. So just enter the ssid and password. Now, upload the code into nodemcu. Before uploading, please make sure you select the correct development board from arduino development board. If nodemcu does not appear in your panel drop-down menu, then import its link from the panel manager and install its necessary files.

After clicking on the assigned IP in your browser, you will see a page showing battery status and a button. Press this button at any time to get updated temperatures.

Note: The Nodemcu and the client mobile device or desktop whose voltage you want to view must be connected to the same WiFi. If your server node computer and client mobile device or computer, laptop, etc. are connected to different networks, you won't be able to view anything after clicking on the IP.

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号