read voltage from Hazzah32 battery connector
This commit is contained in:
parent
5d951eba47
commit
1e3a247a4b
@ -83,6 +83,9 @@ NeoPixelBus<NeoGrbwFeature, Neo800KbpsMethod> *strip;
|
|||||||
ESPAsyncE131 *e131 = new ESPAsyncE131();
|
ESPAsyncE131 *e131 = new ESPAsyncE131();
|
||||||
Preferences prefs;
|
Preferences prefs;
|
||||||
|
|
||||||
|
//// static hardware
|
||||||
|
const uint8_t battery_sense = A13; //Hazzah32 battery connected to A13
|
||||||
|
|
||||||
//// Global button variables
|
//// Global button variables
|
||||||
bool pressed = false; // track button state
|
bool pressed = false; // track button state
|
||||||
uint32_t change_time; // time of button press (ms)
|
uint32_t change_time; // time of button press (ms)
|
||||||
@ -161,6 +164,20 @@ bool loadConfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Read the battery level
|
||||||
|
*/
|
||||||
|
float batteryVoltage() {
|
||||||
|
float v;
|
||||||
|
v = analogRead(battery_sense); // 12bit reading
|
||||||
|
v /= 4095.0f; // percent of range
|
||||||
|
v *= 2.0f; // doubled
|
||||||
|
v *= 3.3f; // percent of referance voltage
|
||||||
|
v *= 1.1f; // multiply by ADC resolution (V)
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Arduino powerup
|
Arduino powerup
|
||||||
*/
|
*/
|
||||||
@ -189,6 +206,9 @@ void setup() {
|
|||||||
|
|
||||||
|
|
||||||
//// start fixtures hardware:
|
//// start fixtures hardware:
|
||||||
|
// battery monitor
|
||||||
|
pinMode(battery_sense, INPUT);
|
||||||
|
|
||||||
// button
|
// button
|
||||||
if (config.button_enable) {
|
if (config.button_enable) {
|
||||||
Serial.println("Initializing OSC button");
|
Serial.println("Initializing OSC button");
|
||||||
|
Loading…
Reference in New Issue
Block a user