Skip to content

Commit

Permalink
battery voltage moved to pin 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Dewald928 committed Mar 30, 2021
1 parent a59e391 commit 69cc49b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Constants
#define PIN_DHT 15 // Digital pin connected to the DHT sensor
#define PIN_SOIL 14 // Analog pin for soil sensor
#define PIN_BATTERY 12 // Analog pin for battery level
#define PIN_BATTERY 2 // Analog pin for battery level
#define PIN_LED 33 // Pin for onboard led
#define PIN_FLASH 4 // Pin for builtin flash
#define DHTTYPE DHT22 //DHT22 sensor
Expand Down
1 change: 1 addition & 0 deletions src/sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ float get_battery_voltage(uint64_t reg_b){
WRITE_PERI_REG(SENS_SAR_READ_CTRL2_REG, reg_b);
//VERY IMPORTANT: DO THIS TO NOT HAVE INVERTED VALUES! port 14 inverts but not 12. weird.
SET_PERI_REG_MASK(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_DATA_INV);
analogSetAttenuation(ADC_11db);

int value = analogRead(PIN_BATTERY);
float battery_voltage = mapf(value, 4095, 0, 4.2, 0);
Expand Down

0 comments on commit 69cc49b

Please sign in to comment.