RAK4631Board.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #include <MeshCore.h>
  3. #include <Arduino.h>
  4. #include <helpers/NRF52Board.h>
  5. // LoRa radio module pins for RAK4631
  6. #define P_LORA_DIO_1 47
  7. #define P_LORA_NSS 42
  8. #define P_LORA_RESET RADIOLIB_NC // 38
  9. #define P_LORA_BUSY 46
  10. #define P_LORA_SCLK 43
  11. #define P_LORA_MISO 45
  12. #define P_LORA_MOSI 44
  13. #define SX126X_POWER_EN 37
  14. //#define PIN_GPS_SDA 13 //GPS SDA pin (output option)
  15. //#define PIN_GPS_SCL 14 //GPS SCL pin (output option)
  16. //#define PIN_GPS_TX 16 //GPS TX pin
  17. //#define PIN_GPS_RX 15 //GPS RX pin
  18. #define PIN_GPS_1PPS 17 //GPS PPS pin
  19. #define GPS_BAUD_RATE 9600
  20. #define GPS_ADDRESS 0x42 //i2c address for GPS
  21. #define SX126X_DIO2_AS_RF_SWITCH true
  22. #define SX126X_DIO3_TCXO_VOLTAGE 1.8
  23. // built-ins
  24. #define PIN_VBAT_READ 5
  25. #define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
  26. class RAK4631Board : public NRF52BoardDCDC {
  27. public:
  28. RAK4631Board() : NRF52Board("RAK4631_OTA") {}
  29. void begin();
  30. #define BATTERY_SAMPLES 8
  31. uint16_t getBattMilliVolts() override {
  32. analogReadResolution(12);
  33. uint32_t raw = 0;
  34. for (int i = 0; i < BATTERY_SAMPLES; i++) {
  35. raw += analogRead(PIN_VBAT_READ);
  36. }
  37. raw = raw / BATTERY_SAMPLES;
  38. return (ADC_MULTIPLIER * raw) / 4096;
  39. }
  40. const char* getManufacturerName() const override {
  41. return "RAK 4631";
  42. }
  43. };