Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By hundsmiachn
#61080 Hi

After a whole day of testing I came to the conclusion the ADC of the esp is pretty useless for such measurement. I tried 3 different modules, all of them showed me values in the range of (700-800) for a voltage of 0.95V. The first thing is, that they values differ too much(value should always be the same). Second that the value 1024 is reached at about 1.3V on one module and 1.45V on the other. Thats pretty useless unless I want to calibrate every single one of them.
How is your experience with the ADC measuring exact voltages ?
Am I missing something here ?

thanks in advance
regards
Erich
User avatar
By trackerj
#61083 If you want better ADC results you need a external dedicated ADC.
I have used for my nEXT EVO Analog extension board the MCP3421 ADC. Way more precise and also easy to be used.

The MCP3421 is a single channel, low-noise, high accuracy delta-sigma A/D converter with differential inputs and up to 18 bits of resolution in a small SOT-23-6 package. The on-board precision 2.048V reference voltage enables an input range of ±2.048V differentially.

The device uses a two-wire I2C compatible serial interface and operates from a single power supply ranging from 2.7V to 5.5V.

This device has an onboard programmable gain amplifier (PGA). User can select the PGA gain of x1, x2, x4, or x8 before the analog-to-digital conversion takes place. This allows the MCP3421 device to convert a smaller input signal with high resolution.

For more details about MCP3421 please read the related article: MCP3421 - 18bit I2C ADC - Driver
User avatar
By warwick
#61085 Erich,

I have only used the ESP8266 A/D converter for a keypad, where the keypad applies voltages from different resistor dividers to the A/D converter depending on which key is pressed. The A/D converter works quite acceptably in this case and the results seem quite consistent - we checked on a few samples and the A/D readings were within around 20 counts from ESP12F to ESP12F.

The ESP8266 creates quite a noisy environment, especially when wifi is active. Did you have a capacitor (such as 100nf) on the input to the A/D converter input? Did you take averages of a number of samples? We would normally use a rolling average of at least 16 samples. And what was your source of the 0.95V? This could also be a source of noise.

That said, I agree with trackerj that you are likely to get limited accuracy for your temperature measurements using the built in A/D converter with NTC thermistors.

NTC thermistors are most convenient and accurate when used with a ratiometric A/D converter. I normally use them with PIC micro controllers, where the supply to the NTC/fixed resistor divider (eg 5V) is the same as the reference for the A/D converter, so that any variations in the 5V supply are applied equally to the reference to the A/D converter and cancel out. In that case, the main sources of measurement error are the tolerance of the fixed resistor and NTC resistor.

With the ESP8266 case, where it uses a fixed internal voltage reference, your measurement will also depend on the tolerance of the ESP8266 internal voltage reference (which is not well specified), as well as the tolerance of your supply the the NTC/fixed resistor divider, as these wont cancel out in this case.

An alternative to trackerj's suggestion to use an external A/D converter would be to use an I2C or 1 wire temperature sensor, such as DS18B20. I haven't had any experience using these, but you should be able to connect many of them to one bus (solving your multiple sensors problem) and wired assemblies seem to be available reasonably inexpensively from Aliexpress, in case you need a wired solution.

There are also examples of projects using these sensors with ESP8266 as a reference:

http://www.instructables.com/id/Low-cos ... ed-on-ESP/
User avatar
By hundsmiachn
#61091 Hi

I added 3 capacitors in my curcuit, one 10u before the lm1117 one 10u after it and a 100n near the ESP VCC/GND pins. I also made an average of 20 values when reading the A0 pin. I used a voltage divider to feed the ADC (12k and 4k7 (ADC on the 4k7)).
Prior to your posts I have found the ADS1115 (can use the 3.3V directly) and I ordered a bunch of them. It has 4 channels and 16bit, should be enough for my needs and hopefully easy to use, it uses I2C also.
As I mentioned in the first post, I cannot use the DS18B20 ( I used it in all other projects, and it is very simple to use and very accurate, I love it), because it is too big. I only have about 2-3mm to put the sensors in.
So I will leave it there till the ADS1115 arrives from china....

thanks for your help!
regards
Erich