RAK4631Board.h 783 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma once
  2. #include <MeshCore.h>
  3. #include <Arduino.h>
  4. #include <helpers/NRF52Board.h>
  5. // built-ins
  6. #define PIN_VBAT_READ 5
  7. #define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
  8. class RAK4631Board : public NRF52BoardDCDC {
  9. protected:
  10. #ifdef NRF52_POWER_MANAGEMENT
  11. void initiateShutdown(uint8_t reason) override;
  12. #endif
  13. public:
  14. RAK4631Board() : NRF52Board("RAK4631_OTA") {}
  15. void begin();
  16. #define BATTERY_SAMPLES 8
  17. uint16_t getBattMilliVolts() override {
  18. analogReadResolution(12);
  19. uint32_t raw = 0;
  20. for (int i = 0; i < BATTERY_SAMPLES; i++) {
  21. raw += analogRead(PIN_VBAT_READ);
  22. }
  23. raw = raw / BATTERY_SAMPLES;
  24. return (ADC_MULTIPLIER * raw) / 4096;
  25. }
  26. const char* getManufacturerName() const override {
  27. return "RAK 4631";
  28. }
  29. };