Professional Documents
Culture Documents
Engineering
Microcontrollers
Programming U2
Product 2
Voltage divider
Student
Esquivar Genesta Efrain Enrique
Balam Poot Carlos José
Table of images
1
List of materials
• Protoboard of 6,4 x 17,2 cm with 830 perforations.
• 1 1k ohms resistor.
• 1 330 ohms resistor.
• Computer.
• ESP32.
• 1 1k Ohms Resistance
• 1 330 Ohms Resistance.
• Du-pont wire .
Development
The objective of the practice is to make the outline proposed by the teacher:
Since this, we can understand that we are supposed to obtain the voltage output of the circuit
in such a way that we have to measure it from the 330 ohms resistor. We expect this result
on the serial monitor of the arduino IDE. Let's move on to the explanation of the
programming code.
First of all, it was necessary to develop the code, that practically is considering the reading
of the ADC and applying a formula:
As a first point, the Analog pin has to be declared.
In the void setup, the bauds for the Serial to print the results has to be defined; on the other
hand, in the void loop, a variable for the ADC reading was declared just to memorize the
value. A float variable corresponding to the volts read was necessary, in such a way that the
formula was stablished.
Finally, the function for the volts to be printed was written and then the delay.
2
Code
#define Analog 36
void setup() {
Serial.begin(115200);
}
void loop() {
int ADC=analogRead(Analog);
float volts=(3.3*ADC)/4095;
Serial.print("Value: ");
Serial.println(volts);
delay(1000);
}
Results
The printed result of the volts according to the formula was shown on the Serial monitor.
3
Conclusion
In this practice we basically made a voltage divider, which consists of obtaining the output
voltage result of a pair of variable ohm resistors, in this case resistance 1 was 1k and
resistance 2 was 300. We apply the formula which gave us 0.818. but beware that here we
have not applied the resolution for the ADC output.
The ADC range is the maximum and minimum ADC input (e.g., 0 to + 3.3V). The ADC
resolution is the smallest distinguishable change in input (e.g., 3.3V / 4095, which is about
0.81 mV). The resolution is the change in input that causes the digital output to change by 1.
Once the obtained is multiplied by this quotient, we obtain the 0.69mV
References
[1] Sparkfun, (2018). “Voltage Dividers”. Taken from
https://learn.sparkfun.com/tutorials/voltage-dividers/all
Recovered on January 28, 2021.