Skip to content

Commit

Permalink
Added ADC input control and battery voltage measurement for ARDUINO_h…
Browse files Browse the repository at this point in the history
…eltec_wifi_lora_32_V3
  • Loading branch information
matthias-bs committed Apr 27, 2024
1 parent d6548fc commit a9b8ac3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/adc/adc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
// 20240414 Added ESP32-S3 PowerFeather
// Added getSupplyVoltage()
// 20240423 Added define ARDUINO_heltec_wifi_lora_32_V3
// 20240427 Added ADC input control and battery voltage measurement
// for ARDUINO_heltec_wifi_lora_32_V3
//
// ToDo:
// -
Expand Down Expand Up @@ -81,7 +83,12 @@ uint16_t getBatteryVoltage(void)
// Not implemented - no default VBAT input circuit (connect external divider to A0)
return 0;
#elif defined(ARDUINO_heltec_wifi_32_lora_V3) || defined(ARDUINO_heltec_wifi_lora_32_V3)
return 0;
// Enable ADC input switch, measure voltage and disable ADC input switch
pinMode(ADC_CTRL, OUTPUT);
digitalWrite(ADC_CTRL, LOW);
delay(100);
getVoltage();
pinMode(ADC_CTRL, INPUT);
#elif defined(ARDUINO_M5STACK_Core2) || defined(ARDUINO_M5STACK_CORE2)
uint16_t voltage = M5.Power.getBatteryVoltage();
log_d("Voltage = %dmV", voltage);
Expand Down

0 comments on commit a9b8ac3

Please sign in to comment.