Skip to content

Commit 85ea29d

Browse files
committed
add vbat for metro, clean up
1 parent 8c4767f commit 85ea29d

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

libraries/Bluefruit52Lib/examples/Hardware/adc_vbat/adc_vbat.ino

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
#include <Arduino.h>
2+
3+
uint32_t vbat_pin = PIN_VBAT; // A7 for feather nRF52832, A6 for nRF52840
14

25
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
36

47
#ifdef NRF52840_XXAA // if this is for nrf52840
5-
#define VBAT_PIN (A6)
6-
#define VBAT_DIVIDER (0.5F) // 150K + 150K voltage divider on VBAT
8+
#define VBAT_DIVIDER (0.5F) // 150K + 150K voltage divider on VBAT
79
#define VBAT_DIVIDER_COMP (2.0F) // Compensation factor for the VBAT divider
810
#else
9-
#define VBAT_PIN (A7)
1011
#define VBAT_DIVIDER (0.71275837F) // 2M + 0.806M voltage divider on VBAT = (2M / (0.806M + 2M))
1112
#define VBAT_DIVIDER_COMP (1.403F) // Compensation factor for the VBAT divider
1213
#endif
@@ -27,7 +28,7 @@ float readVBAT(void) {
2728
delay(1);
2829

2930
// Get the raw 12-bit, 0..3000mV ADC value
30-
raw = analogRead(VBAT_PIN);
31+
raw = analogRead(vbat_pin);
3132

3233
// Set the ADC back to the default settings
3334
analogReference(AR_DEFAULT);

variants/feather_nrf52840_express/variant.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static const uint8_t A7 = PIN_A7 ;
8686
#define ADC_RESOLUTION 14
8787

8888
// Other pins
89-
#define PIN_AREF (PIN_A7)
89+
#define PIN_AREF PIN_A7
9090
#define PIN_VBAT PIN_A6
9191
#define PIN_NFC1 (33)
9292
#define PIN_NFC2 (2)

variants/metro_nrf52840_express/variant.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ static const uint8_t A7 = PIN_A7 ;
8686
#define ADC_RESOLUTION 14
8787

8888
// Other pins
89-
#define PIN_AREF (PIN_A7)
89+
#define PIN_AREF PIN_A7
90+
#define PIN_VBAT PIN_A6
9091
#define PIN_NFC1 (2)
9192
#define PIN_NFC2 (51)
9293

0 commit comments

Comments
 (0)