# Nodemcu voltage divider

In this Tutorial, you will learn how to monitor the Battery voltage from anywhere around the world and control DC light bulbs and other dc loads using 12v SPDT type relays. The battery voltage is displayed on the Gauge while the loads are controlled using the Numeric input buttons which I will explain in a minute.

I would appreciate your support in this way! This is the Voltage sensor Module that we will be using today, This Module is capable of measuring the voltages ranging from 0.

But if you want to measure voltages higher than 25volts then you can watch my tutorial on how to modify this voltage sensor for monitoring higher voltages, in this tutorial I performed all the calculations. As you can see on one side we have a block terminal, this is where we connect the voltage and ground wires coming from The batterysolar panel or any other source. The Voltage wire is connected with the vcc terminal and the ground is connected with the gnd terminal.

As you can see the resistors values used in this module are 30k and 7. Lets perform calculations for this circuit. But it will damage the Nodemcu esp module as the esp is a 3. So make sure the input voltage to this sensor never exceeds 18 volts. Always try to keep it below 18 volts.

For 18 volts you will get 3. The 12v and ground wires of the battery are connected with the VCC and ground terminals of the voltage sensor. The minus pin of the voltage sensor is connected with the ground while the S pin of the voltage sensor is connected with the analog pin A0 of the Nodemcu module. The plus pin of the voltage sensor is not connected.

This is the 5v regulated power supply based on the LM voltage regulator. J1 is the female power jack and this is where we connect the 12volts from a battery or 12v adopter or a Solar Panel. This power supply is used to power up the nodemcu esp wifi module. This is a current limiting resistor. A wire from the output of the voltage regulator is connected with the Vin pin of the nodemcu esp wifi module and ground is connected with the ground.

A two channel relay module is connected with the D0 and D1 pins of the nodemcu module. These relays can be used to control the ac or dc loads. Table of Contents. SimpleTimer timer. This means. Recommended For You. Leave a Reply Cancel reply.From Let's Control It. This article only applies to DC voltages. The ESP has an on board 10 bit analog to digital converter ADC and is therefore capable to make a digital representation of an analog tension.

The analog input is not always connected to a module pin, but the ESP does have it. The ADC has a full range limit of 1 volt, so it requires a device to measure voltages above that value. This device is called a voltage divider and it its most simpl form, it consists of a resistor network with only two resistors. Somtimes more advanced circuits are required, but that is outside the scope of this article. Hereunder a schematic representation of a two resistor voltage divider The NodeMCU and the Wemos D1 mini have this network already in place, but for a bare ESP, you have to make it yourself.

If you want to measure larger voltages, you simple enlarge R1. Navigation menu Personal tools Log in Request account. Namespaces Page Discussion. Views Read View source View history. Navigation Main page. Other Recent changes. This page was last edited on 5 Octoberat Pages:  2. Its an black ESP chip on an black breakout board.

Im trying to use the analog input A0. Many websites say that it uses an voltage of about 1V for analog reference. So ive builded a voltage divider from 3. When i connect 1. So i connected the 3. I used this simple sketch for testing: Code: [Select].

Shouldnt it be 0??? When i power on one of the dev kits there is always a new WLAN network, but my sketch does not start any network. Is that normal? Does the WLAN network interfere with the analog readings?

### NodeMCU ESP8266 Remote Temperature Using WebSockets

Also when i connect Vin pin of orig. NodeMCU dev kit to A0 i get a value of So analog reference has to be greater 3,3V. How can i change it??? These dev kits have a voltage divider on the A0 pin. I've literally just posted about this on the esp forums. I've been banging my head about this for hours. Do you know how I can change the reference voltage??

I measured it with a multimeter and it's about 3. Thank you very much. I'll continue in this thread with my follow up question: I'm trying to get an lm35 temperature sensor to work with the analog pin on the nodemcu 1. The LM35 datasheet says that the temperature changes by 1 deg C for each 10 mV. Here is my code for getting the temperature: Code: [Select].

V ADC doesn't really matter in this case. The 50mV difference you are getting could just be an ADC or sensor calibration problem.We are a strong Community of developers, hackers, and visionaries.

No, seriously, we are! Post topics, source code that relate to the Arduino Platform. By Brian J. Brian J. But before I go there, I just want to test my sketch with some fixed resistors. Building a simple voltage divider on A0 using two 5K resistors I don't get a reading on A0 of as I would expect.

The two resistors I am using both read 5. I tried two 1M resistors also 1. Is that voltage divider causing these readings? If so, how do I normalise an external voltage divider across the internal one so that I can actually calculate the resistance of what is going to be my variable resistor in the form of a 1M thermistor? Cheers, b.

Re: analog input affected by internal voltage divider? The Node MCU units that have a I think this is normally a K input and a K to ground. So the effective input impedance is now K. The source impedance will therefore be a significant factor in what result you get.

One simple strategy for your thermistor would just be to couple it between the 3. It is still just simple sums to calculate the input from the resistance values. But still testing with a fixed 1. I never once get even near the that a 1. What effect am I still seeing? Not the fluctuation range -- that I can deal with -- just that even the lowest end of the range isn't at low as it should be.

If the thermistor goes down to low resistance values then it would be worth adding an extra resistor from the input to ground to move the range down. It seems like you are describing a voltage divider in that case, yes? Or am I misunderstanding where you mean to put the resistor? I must be dense. I probably need to go as low as 1K and as high as at least 1M, maybe 2M to 3M to get a really good range -- but 1M at least on my thermistor.Battery voltage monitoring methods.

Measuring voltage of your solar panel, ups and other daily use batteries consumes a lot of time. Grabbing multi-meter, opening the battery boxes and touching both the multi-meter leads to terminals of battery takes some effort. How about developing an efficient IOT system through which you can see the status of your battery on your desktop and mobile web browsers.

Lets start and make this diy project. Since we are going to develop and IOT system which can monitor battery status and update us on our browser. A WiFi device which can connect to our local home WiFi, takes voltage reading from controller and updates the end user about the current battery level. For this purpose i decided to use nodemcu WiFi module in the project. It can not only work as controller but also it can connect it self to a WiFi network as server or client. I am going to measure 12 volt batteries.

### ESP8266 ADC – Read Analog Values with Arduino IDE, MicroPython and Lua

Voltage divider working and calculations. Nodemcu is a tiny device, it works on 3. Since it is working on 3. Voltage greater than 5 volt may blow the pin or fry the nodemcu. In our case we want to measure 12 volt battery and nodemcu adc analog to digital channel can only accept 3.

What we will do is divide the voltage between two resistors and measure only voltage across one resistor and remaining resistor voltage will be calculated mathematically. Typical voltage divider circuit and formula is given below. Voltage divider with battery circuit. Now lets calculate the values for Rtop and Rbottom. Here we need some important considerations to be taken seriously.

Low ohm resistors can sunk much current and wires could be heated instantly.

## DC Voltage divider

Consequently wires can melt down in seconds. So always use sufficient amount of resistors for bigger ampere hour batteries. I selected one resistor Rbottom to be 10k ohm. During charging battery voltage can increase to 18 volts. Solar charge controller also output voltage approximately equal to 15 volts to charge the batteries.

Formula Calculations. I am going to measure voltage across Rbottom and i decided its value randomly to be 10k ohm. We know Vout can be up to maximum 3. Vin is 18 volts when the battery is charging. Now we can find Rtop. Voltage divider resistance value calculation. Now if 18 volts are at battery side it will be divided across resistors, 3.

If battery is not charging and say supplying 12 volts what will be the voltage drop across resistors? Lets calculate it. Voltage drop across resistance of voltage divider circuit.This means that those ESP boards can read analog signals. This post is divided in three sections:. However, most ESP development boards come with an internal voltage divider, so the input range is 0 to 3.

So, in sumary:. For that, you need to wire a potentiometer to your board. You can use the preceding links or go directly to MakerAdvisor. So, you need a voltage divider circuit, as shown below. Follow the next tutorial:. View raw code. The potentiometer value will be stored on the sensorValue variable:. In the setupinitialize the Serial Monitor for debugging purposes:. In the loopwe read the analog value by using the analogRead function and passing the analogInPin as an argument.

## ESP8266 Community Forum

The value is saved on the sensorValue variable:. Finally, the readings are displayed on the Serial Monitor, so that you can actually see what is going on. You need to do this because the PWM output only has 8-bit resolution. Upload the previous code to the ESP Make sure you have the right board and COM port select. After uploading the code, open the Serial Monitor at a baud rate of The analog readings should be displayed. You also need an IDE to write and upload the code to your board.

To read analog inputs, import the ADC class in addition to the Pin class from the machine module. We also import the sleep method. Then, create an ADC object called pot on A0 pin. To read the value from the pot, use the read method on the pot object. It should return a value between 0 and Rotate your potentiometer and send the print adc. Either way, you should always be careful not to exceed the maximum recommended voltage. You may consider adding a voltage divider circuit when you need a higher input voltage range.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It only takes a minute to sign up. Some sensors give as output a voltage between 0 and 5V. The analog inputs of the NodeMCU require voltages between 0 and 3. I plan to make a voltage divider with two resistors like in this link for compatibility.

Voltmeter DC(0-25V)With Smartphone Display / Blynk / Nodemcu

To provide the desired voltage the quotient of the values of the resistances is fixed approx. However, the absolute values of the resistances are not. I think that low values must work, e. But I am unsure of VERY high resistance values because I suspect that there should be some current intensity requirements.

This effectively fixes the resistor values that can be used to scale the input of the NodeMCU. For a The low end of the values is limited by how much current your sensor can provide. I doubt that your sensor can do that. For most sensors, you would want to use resistors in the kilohm or tens of kilohm range. The high end is limited by the input impedance of the analog input pin. If your resistor values are large compared to this input impedance then the input impedance of the analog pin will affect how the voltage divider works.

If the analog input is multiplexed and the ADC has a sample-and-hold at the input, then very large resistances in the divider will not allow the sampling capacitor to charge fast enough. For most ADC inputs, you would want to use resistors in the tens or hundreds of kilohms. Sign up to join this community.