todd-herbert
8 hours ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
14 additions and
6 deletions
-
variants/promicro/PromicroBoard.h
-
variants/promicro/platformio.ini
-
variants/promicro/variant.h
|
|
|
@ -17,8 +17,14 @@ |
|
|
|
#define SX126X_DIO2_AS_RF_SWITCH true |
|
|
|
#define SX126X_DIO3_TCXO_VOLTAGE (1.8f) |
|
|
|
|
|
|
|
#define PIN_VBAT_READ 17 |
|
|
|
#define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
|
|
|
|
// Default values for battery monitoring voltage divider
|
|
|
|
// To override, either:
|
|
|
|
// - set build flags in variant's platformio.ini file
|
|
|
|
// - use cli to 'set adc.multiplier' (repeaters / rooms)
|
|
|
|
|
|
|
|
#ifndef ADC_MULTIPLIER |
|
|
|
#define ADC_MULTIPLIER (2.0f) // Dependent on voltage divider resistors. Default 1MOhm resistors
|
|
|
|
#endif |
|
|
|
|
|
|
|
class PromicroBoard : public NRF52BoardDCDC { |
|
|
|
protected: |
|
|
|
@ -32,14 +38,14 @@ public: |
|
|
|
#define BATTERY_SAMPLES 8 |
|
|
|
|
|
|
|
uint16_t getBattMilliVolts() override { |
|
|
|
analogReadResolution(12); |
|
|
|
analogReadResolution(ADC_RESOLUTION); |
|
|
|
|
|
|
|
uint32_t raw = 0; |
|
|
|
for (int i = 0; i < BATTERY_SAMPLES; i++) { |
|
|
|
raw += analogRead(PIN_VBAT_READ); |
|
|
|
} |
|
|
|
raw = raw / BATTERY_SAMPLES; |
|
|
|
return (adc_mult * raw); |
|
|
|
return (raw * (AREF_VOLTAGE * 1000) * adc_mult / (1 << (ADC_RESOLUTION))); |
|
|
|
} |
|
|
|
|
|
|
|
bool setAdcMultiplier(float multiplier) override { |
|
|
|
|
|
|
|
@ -23,6 +23,7 @@ build_flags = ${nrf52_base.build_flags} |
|
|
|
-D ENV_INCLUDE_BMP280=1 |
|
|
|
-D ENV_INCLUDE_INA3221=1 |
|
|
|
-D ENV_INCLUDE_INA219=1 |
|
|
|
; -D ADC_MULTIPLIER=2.0f |
|
|
|
build_src_filter = ${nrf52_base.build_src_filter} |
|
|
|
+<helpers/sensors> |
|
|
|
+<../variants/promicro> |
|
|
|
|
|
|
|
@ -22,8 +22,9 @@ |
|
|
|
#define PIN_EXT_VCC (21) |
|
|
|
#define EXT_VCC (PIN_EXT_VCC) |
|
|
|
|
|
|
|
#define BATTERY_PIN (17) |
|
|
|
#define ADC_RESOLUTION 12 |
|
|
|
#define PIN_VBAT_READ (17) |
|
|
|
#define ADC_RESOLUTION (14) |
|
|
|
#define AREF_VOLTAGE (3.6f) // Using default analog reference (AR_INTERNAL), which maps ADC reading to 0 ... 3.6V
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Number of pins
|
|
|
|
|