ESP8266 analog input and reference voltage

Hi,

I have some experience with Arduino but I am just starting with ESP. For programming I use the Arduino IDE. At the moment I try to get a NTC temperature sensor running. First I tested it with an arduino. The NTC is setup as a voltage divider with a 10k resistor. I use 3.3V and I also connected the V_ref pin of the Arduino to the 3.3V. Additionally I connected a SHT45 I2C temperature sensor to the arduino. The SHT45 showed 23.85°C and the NTC showed 23.89°C. So I guess the script and the setup of the NTC is correct.

Now I connected the NTC to a ESP8266 Node MCU V3 which already had a 2.8TFT screen connected. The ESP is powered by 5V at V_IN and I cut the power supply line of the USB cable but connected it to the PC to be able to connect to the serial monitor. The voltage divider with the NTC was powered by 3.3V. The same script was used to determine the temperature of the NTC. Now the NTC showed 21.28°C.

As a next setup I disconnected the TFT from the ESP. I used a USB cable to power the ESP and only connected the voltage divider with the NTC to the ESP. Now the NTC showed 23.04 °C

So my question is, what is happening here? I reed that Node MCU A0 works with 0-3.3V. But what is the reference voltage. I guessed that it is the voltage which is supplied by the 3.3V PIN but that doesn´t seem to be the case. Is there a possibility to set a reference voltage for analog input?

Or is the problem something complete different?

Thank you for your help

Arduino Arti

An NTC is the wrong choice for an ESP processor.
The ESP has the wrong type of A/D (absolute vs, ratiometric), which makes the returned value also depending on supply voltage (as you have noticed).
Nothing you can do about that.
Use a digital sensor, like the DS18B20.
Leo..

P.S. Aref of an ESP8266 is about 1volt, but a NodeMCU has a 100k:220k voltage divider fitted to increase A0 range to ~3.2volt. That voltage divider will also interfere with your NTC.

Thank you for your feedback. I infomed myself about the differences in the ADCs of Arduino and ESP and now I understand the problem.

The plan for the project was to use 2 analog sensor with an multiplexer at A0. The second sensor is a PH4502C which i have in stock already.

So, at the moment, my idea is to switch to an external ADC like ADS1115.

Do you think this is a feasable solution?

Would the ADS115 be the correct choice or are there better options ?

What accuracy do you need for the temperature measurements?

Since I would use the ADC for a PH-meter also, I don´t know the required accuracy. I need to check that.

I red the data sheet of the ADS1115 and now I have some question.

The ADS115 has an programmable gain amplifer (PGA) and an internal reference voltage. An external reference voltage can not be used.

That means I can only measure absolute voltage values in the range which is set in the PGA. Since I do not know the voltage which is applied to the voltage divider (resistor & NTC ) I need to make 2 measurements (voltage drop at NTC and at resistor) in order to be able to calculate the resistance of the NTC. Ist this correct ?

And if this is correct I should also be able to use an analog multiplexer instead of the ADS1115, and measure the 2 values and calculate the resistance of the NTC, right?

No.
As @Wawa pointed out the 8266 node mcu board has a voltage divider in front of the ADC which will interfere with the thermistor voltage divider.

You could connect an op-amp buffer to the node mcu A0 input and then connect the analog MUX to the buffer.

The ADS1115 is also the wrong A/D for an NTC.
Forget about an NTC, use a digital temp sensor.

The ESP is a good match for a PH-meter, which has a voltage output.
You don't need an A/D with a high resolution for that, because of the limited PH levels (15)

If...you need more analogue inputs then move to an ESP32.
Even the smallest single-core C3, which replaces the obsolete ESP8266, has more analogue inputs.
Leo..

OK. I am not shure if I understood the problem with the ESP ADC properly. Why is the PH meter which has an output of 0-3,3V a good mach for the ESP.

Just to undertstand it. You wrote that the NTC is interfering with the internal 100K:220K voltage divider. If I got it right it should look like on the picture, right. So the problem is the combination of the 2 voltage dividers.

Why do you expect that this kind of problem can´t occure at the PH4502C ph meter. Can I assume that an analog sensor like the ph meter provides a voltage which does not interfere with the internal voltage divider? And if yes why?

The point that I cannot set a reference voltage at the ESP is no problem with the sensor module since the measured voltage is independent from the VCC of the module and I just can calibrate the sensor with at least 2 values, right?

Why don't you use the SHT45 with the NodeMcu?

https://www.esp8266learning.com/sht40-temperature-humidity-sensor-and-esp8266-example-using-the-arduino-ide.php

That's not the only problem.
The ESP has the wrong type of A/D for an NTC.
You will never get it right, because that combination of NTC and A/D also varies with supply voltage variations.

Not sure why you insist on using a thermistor over a much better digital temp sensor.

Some A/Ds measure absolute voltages, some measure ratios ( of the supply).
The PH sensor expects an absolute A/D.
Research "ratiometric vs. absolute".
Unfortunately not many understand the concept, not even Google or Ai.
Leo..

Q: what voltage do you expect on point A0, given the NTC is 10k (temp = 25C).
A: (3.3/2) * 1/3.2 = 0.515625V

Now connect a TFT screen to the 3.3volt supply.
Expect the 3.3volt supply to drop to 3.2volt because of that load, with some noise variation.
What would that do to the voltage on A0...

Only an A/D that measures the ratio between VCC and A0 would give consistent values. Only the ratio of 1: (0.515625 / 3.3) = 1 : 0.1744318 would stay the same.

That is what I'm assuming.
If the pH meter has a low impedance output, then the on board voltage divider will have a negligible affect on the measured voltage.

But as I already mentioned an op-amp buffer will solve that problem.

The point that I cannot set a reference voltage at the ESP is no problem with the sensor module since the measured voltage is independent from the VCC of the module and I just can calibrate the sensor with at least 2 values, right?

Correct

See post #7

I need a waterproof sensor for measuring water temperature. So at least the SHT45 sensor which I have are not suitable.

I understood the difference between the two kind of ADCs. If I would use the ADC oft the ESP I would measure the voltage drop at both the 10k resistor and the NTC and then I can calculate the resistance of the NTC independent from the applied voltage.

At the end I dont´care which temperature sensor is used. I am just pushing the issue because I do not understand why the NTC is influenceing the measured value and the pH sensor is not and I want to know this for future projects. But jim-p already gave me a hint on this.

I think that´s the point I was struggling with (even you gave me the info in one of your last posts). Impedance and resistance is the same here, right? So if I have a NTC10K +10K resistor the overall resistance is 20k and that would have an influence on the measurement. For the phmeter a small resistance is expected which will not influence the measurement.

For the case that the impedance of the sensor is also a to high, there is the possibilty to use an op-amp buffer which is placed between the sensor and the analog input. The function of the op-amp buffer is to mirror the exact same voltage which it gets at the input to the output. But with a much smaller impedance which will not influence the measurement.

Can someone recommend a op-amp for this case?

Th LM358 is very common but the supply voltage need to be at least 2V higher than the voltage you wiil be measuring.

So if the max voltage you want to measure is 3.3V then the Vcc for the opamp should be 5.3V. However in many situations at room temperature a Vcc that's 1.5V higher will work, so 5V Vcc is good

Digi-key has the MCP6001 which is rail-rail input/output, so you could power it with 3.3V

I see that some PH4502C boards come with a DS18B20.
A (waterproof) DS18B20 (post#2) is a far better solution than an NTC.

All schematic diagrams I have seen from various PH4502C boards are already fully opamp buffered. Please post a link to the board you actually have.
Leo..