ThinkNodeM6Board.cpp 839 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "ThinkNodeM6Board.h"
  2. #include <Arduino.h>
  3. #ifdef THINKNODE_M6
  4. #include <Wire.h>
  5. void ThinkNodeM6Board::begin() {
  6. NRF52Board::begin();
  7. Wire.begin();
  8. #ifdef P_LORA_TX_LED
  9. pinMode(P_LORA_TX_LED, OUTPUT);
  10. digitalWrite(P_LORA_TX_LED, LOW);
  11. #endif
  12. delay(10); // give sx1262 some time to power up
  13. }
  14. uint16_t ThinkNodeM6Board::getBattMilliVolts() {
  15. int adcvalue = 0;
  16. digitalWrite(PIN_ADC_CTRL, HIGH);
  17. analogReference(AR_INTERNAL_3_0);
  18. analogReadResolution(12);
  19. delay(10);
  20. // ADC range is 0..3000mV and resolution is 12-bit (0..4095)
  21. adcvalue = analogRead(PIN_VBAT_READ);
  22. digitalWrite(PIN_ADC_CTRL, LOW);
  23. // Convert the raw value to compensated mv, taking the resistor-
  24. // divider into account (providing the actual LIPO voltage)
  25. return (uint16_t)((float)adcvalue * REAL_VBAT_MV_PER_LSB);
  26. }
  27. #endif