Professionals Know This!

Introduction: Professionals Know This!

About: Do you like technology? Follow my channel on Youtube and my Blog. In them I put videos every week of microcontrollers, arduinos, networks, among other subjects.

Today we are going to talk about “ ESP32 automated ADC calibration ”. It may seem like a very technical subject, but I think it's very important for you to know a little about it.

This is because it is not just about the ESP32, or even the ADC calibration only, but rather of everything that involves analog sensors that you might want to read.

Most sensors are not linear, so we are going to introduce an automated prototype calibrator for analog digital converters. Also, we are going to make a correction of an ESP32 AD.

Step 1: Introduction

There is a video in which I talk a little about this subject: Didn't you know? ESP32 ADC adjustment. Now, let's talk in an automated way that prevents you from doing the entire polynomial regression process. Check it out!

Step 2: Resources Used

· Jumpers

· 1x Protoboard

· 1x ESP WROOM 32 DevKit

· 1x USB cable

· 2x 10k resistors

· 1x 6k8 resistor or 1x 10k mechanical potentiometer for adjusting the voltage divider

· 1x X9C103 - 10k digital potentiometer

· 1x LM358 - Operational amplifier

Step 3: Circuit Used

In this circuit, the LM358 is an operational amplifier in the “voltage buffer” configuration, isolating the two voltage dividers so that one does not influence the other. This allows to obtain a simpler expression since R1 and R2 can, with a good approximation, no longer be considered in parallel with RB.

Step 4: Output Voltage Depends on the Variation of the Digital Potentiometer X9C103

Based on the expression we obtained for the circuit, this is the voltage curve at its output when we vary the digital potentiometer from 0 to 10k.

Step 5: Controlling the X9C103

· To control our X9C103 digital potentiometer we will feed it with 5V, coming from the same USB that powers the ESP32, connecting in VCC .

· We connect the UP / DOWN pin to GPIO12.

· We connect the pin INCREMENT to GPIO13.

· We connect DEVICE SELECT (CS) and VSS to GND.

· We connect VH / RH to the 5V supply.

· We connect VL / RL to GND.

· We connect RW / VW to the voltage buffer input.

Step 6: Connections

Step 7: Capture on the Oscilloscope of the Up and Down Ramps

We can observe the two ramps generated by the ESP32 code.

The values of the rise ramp are captured and sent to the C# software for evaluation and determination of the correction curve.

Step 8: Expected Versus Read

Step 9: Correction

We will use the error curve to correct the ADC. For this, we will feed a program made in C#, with the values of the ADC. It will calculate the difference between the value read and the expected, thus creating an ERROR curve as a function of the ADC value.

Knowing the behavior of this curve, we will know the error and we will be able to correct it.

To know this curve, the C# program will use a library that will perform a polynomial regression (like those performed in previous videos).

Step 10: Expected Versus Read After Correction

Step 11: Program Execution in C#

Step 12: Wait for the Ramp START Message

Step 13: ESP32 Source Code - Example of a Correction Function and Its Use

Step 14: Comparison With Previous Techniques

Step 15: ESP32 SOURCE CODE - Declarations and Setup ( )

Step 16: ESP32 SOURCE CODE - Loop ( )

Step 17: ESP32 SOURCE CODE - Loop ( )

Step 18: ESP32 SOURCE CODE - Pulse ( )

Step 19: SOURCE CODE OF THE PROGRAM IN C# - Program Execution in C #


Step 21: SOURCE CODE OF THE PROGRAM IN C # - Namespace , Class and Global


Step 23:

Step 24: Download the Files

Be the First to Share


    • Barbecue Speed Challenge

      Barbecue Speed Challenge
    • Arduino Contest

      Arduino Contest
    • Toys & Games Contest

      Toys & Games Contest