Modifications

Sauter à la navigation Sauter à la recherche
990 octets ajoutés ,  25 avril 2016 à 20:20
Ligne 19 : Ligne 19 :     
{{ADFImage|FEATHER-M0-Alimentation-20.jpg|640px}}
 
{{ADFImage|FEATHER-M0-Alimentation-20.jpg|640px}}
 +
 +
== Mesurer l'accu ==
 +
 +
If you're running off of a battery, chances are you wanna know what the voltage is at! That way you can tell when the battery needs recharging. Lipoly batteries are 'maxed out' at 4.2V and stick around 3.7V for much of the battery life, then slowly sink down to 3.2V or so before the protection circuitry cuts it off. By measuring the voltage you can quickly tell when you're heading below 3.7V
 +
 +
To make this easy we stuck a double-100K resistor divider on the '''BAT''' pin, and connected it to '''D9''' (a.k.a analog #7 '''A7'''). You can read this pin's voltage, then double it, to get the battery voltage.
 +
 +
<nowiki>#define VBATPIN A7
 +
 
 +
float measuredvbat = analogRead(VBATPIN);
 +
measuredvbat *= 2;    // we divided by 2, so multiply back
 +
measuredvbat *= 3.3;  // Multiply by 3.3V, our reference voltage
 +
measuredvbat /= 1024; // convert to voltage
 +
Serial.print("VBat: " ); Serial.println(measuredvbat);</nowiki>
 +
 +
{{ADFImage|FEATHER-M0-Alimentation-30.jpg|640px}}
    
{{FEATHER-M0-TRAILER}}
 
{{FEATHER-M0-TRAILER}}
29 917

modifications

Menu de navigation