Skip to content

Commit

Permalink
Merge pull request #2 from matthias-bs/feature-esp32s3-powerfeather
Browse files Browse the repository at this point in the history
Added ESP32-S3 PowerFeather
  • Loading branch information
matthias-bs authored Apr 15, 2024
2 parents 49277e3 + c71d122 commit a2a9897
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
#- esp32:esp32:heltec_wifi_lora_32_V2
#- esp32:esp32:featheresp32
- esp32:esp32:m5stack-core2
- esp32:esp32:esp32s3_powerfeather
- esp32:esp32:adafruit_feather_esp32s2
- rp2040:rp2040:adafruit_feather:dbgport=Serial

Expand Down Expand Up @@ -85,7 +86,8 @@ jobs:
"[email protected]"
"[email protected]"
"[email protected]"
"[email protected]")
"[email protected]"
"[email protected]")
for i in "${required_libs[@]}"
do
arduino-cli lib install "$i"
Expand Down
1 change: 1 addition & 0 deletions BresserWeatherSensorLW.ino
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
// Added M5Stack Core2 initialization
// 20240414 Added separation between LoRaWAN and application layer
// Fixed battLevel calculation
// 20240415 Added ESP32-S3 PowerFeather
//
// ToDo:
// -
Expand Down
16 changes: 14 additions & 2 deletions config.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
///////////////////////////////////////////////////////////////////////////////
// config.h
//
// RadioLib / LoRaWAN specific configuration including radio module wiring
// RadioLib / LoRaWAN specific configuration including radio module wiring
//
// based on https://github.com/radiolib-org/radiolib-persistence
// based on https://github.com/radiolib-org/radiolib-persistence
//
// created: 04/2024
//
Expand Down Expand Up @@ -34,6 +34,7 @@
// History:
//
// 20240412 Created
// 20240413 Added ESP32-S3 PowerFeather
//
// ToDo:
// -
Expand Down Expand Up @@ -110,6 +111,17 @@ const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0
#pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS")
#define LORA_CHIP SX1276

#elif defined(ARDUINO_ESP32S3_POWERFEATHER)
#define PIN_LORA_NSS 15
#define PIN_LORA_RST 45
#define PIN_LORA_IRQ 16
#define PIN_LORA_GPIO 18
#define PIN_LORA_DIO2 RADIOLIB_NC
#pragma message("NOT TESTED!!!")
#pragma message("ARDUINO_ESP32S3_POWERFEATHER defined; assuming RFM95W FeatherWing will be used")
#pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS")
#define LORA_CHIP SX1276

#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040)
// Use pinning for Adafruit Feather RP2040 with RFM95W "FeatherWing" ADA3232
#define PIN_LORA_NSS 7
Expand Down
31 changes: 31 additions & 0 deletions src/adc/adc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
// 20240405 Created
// 20240410 Added RP2040 specific implementation
// 20240413 Refactored ADC handling
// 20240414 Added ESP32-S3 PowerFeather
// Added getSupplyVoltage()
//
// ToDo:
// -
Expand All @@ -43,6 +45,9 @@

#if defined(ARDUINO_M5STACK_Core2) || defined(ARDUINO_M5STACK_CORE2)
#include <M5Unified.h>
#elif defined(ARDUINO_ESP32S3_POWERFEATHER)
#include <PowerFeather.h>
using namespace PowerFeather;
#endif


Expand Down Expand Up @@ -78,10 +83,36 @@ uint16_t getBatteryVoltage(void)
uint16_t voltage = M5.Power.getBatteryVoltage();
log_d("Voltage = %dmV", voltage);
return voltage;
#elif defined(ARDUINO_ESP32S3_POWERFEATHER)
uint16_t voltage;
Result res = Board.getBatteryVoltage(voltage);
if (res == Result::Ok) {
log_d("Voltage = %dmV", voltage);
return voltage;
} else {
return 0;
}
#elif defined(ADC_EN)
return getVoltage();
#else
return 0;
#endif
}

uint16_t getSupplyVoltage(void)
{
#if defined(ARDUINO_ESP32S3_POWERFEATHER)
uint16_t voltage;
Result res = Board.getSupplyVoltage(voltage);
if (res == Result::Ok) {
log_d("Voltage = %dmV", voltage);
return voltage;
} else {
return 0;
}
#elif defined(PIN_SUPPLY_IN)
return getVoltage(PIN_SUPPLY_IN, SUPPLY_SAMPLES, SUPPLY_DIV);
#else
return 0;
#endif
}
10 changes: 10 additions & 0 deletions src/adc/adc.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,14 @@ uint16_t getVoltage(uint8_t pin = PIN_ADC_IN, uint8_t samples = UBATT_SAMPLES, f
*/
uint16_t getBatteryVoltage(void);

/*!
* \brief Get supply voltage
*
* Returns the battery voltage or zero if not available (board specific)
*
* \returns Voltage in mV or zero if not available
*/

uint16_t getSupplyVoltage(void);

#endif // _ADC_H

0 comments on commit a2a9897

Please sign in to comment.