Zum Inhalt springen

Wemos LOLIN32: Unterschied zwischen den Versionen

Reox (Diskussion | Beiträge)
Keine Bearbeitungszusammenfassung
Reox (Diskussion | Beiträge)
Zeile 44: Zeile 44:


Unfortunately, no direct method of battery voltage measurement is built into the system.
Unfortunately, no direct method of battery voltage measurement is built into the system.
But it should be quite easy to implement such a thing: Use a voltage divider on the battery to get a 3.3V max. For a 4.2V cell, this can be achieved using a 27k and 100k resistor.
But it should be quite easy to implement such a thing: Use a voltage divider on the battery to get a 1.1V max. For a 4.2V cell, this can be achieved using a 27k and 100k resistor.
Note, that the ADC of the ESP32 is set to 1.1V range by default! You can use the attenuation but this is not available on every platform.


   ^  V_bat
   ^  V_bat
   |
   |
   R1 = 27k
   R1 = 100k
   |
   |
   +----o ADC
   +----o ADC
   |
   |
   R2 = 100k
   R2 = 27k
   |
   |
  GND
  GND


Now you can measure the voltage on the battery using the ADC. As the ADC is 12bit, you can get the actual voltage by multiplying the reading by ((27+100)/100) * 3.3 / 2**12, or in more general terms: ((R1 + R2) * V_ref) / (R2 * 2**Resolution).
Now you can measure the voltage on the battery using the ADC. As the ADC is 12bit, you can get the actual voltage by multiplying the reading by ((27+100)/27) * 1.1 / 2**12, or in more general terms: ((R1 + R2) * V_ref) / (R2 * 2**Resolution).


== Battery ==  
== Battery ==