Added default temperature from ESP32 MCU and NRF52 MCU
Added NRF52Board.h and NRF52Board.cpp Modified NRF52 variants to extend from NRF52Board to share common feature
This commit is contained in:
@@ -173,6 +173,12 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
|
|||||||
|
|
||||||
telemetry.reset();
|
telemetry.reset();
|
||||||
telemetry.addVoltage(TELEM_CHANNEL_SELF, (float)board.getBattMilliVolts() / 1000.0f);
|
telemetry.addVoltage(TELEM_CHANNEL_SELF, (float)board.getBattMilliVolts() / 1000.0f);
|
||||||
|
|
||||||
|
float temperature = (float)board.getMCUTemperature();
|
||||||
|
if(!isnan(temperature)) { // Supported boards with built-in temperature sensor. ESP32-C3 may return NAN
|
||||||
|
telemetry.addTemperature(TELEM_CHANNEL_SELF, (float)board.getMCUTemperature()); // Built-in MCU Temperature
|
||||||
|
}
|
||||||
|
|
||||||
// query other sensors -- target specific
|
// query other sensors -- target specific
|
||||||
if ((sender->permissions & PERM_ACL_ROLE_MASK) == PERM_ACL_GUEST) {
|
if ((sender->permissions & PERM_ACL_ROLE_MASK) == PERM_ACL_GUEST) {
|
||||||
perm_mask = 0x00; // just base telemetry allowed
|
perm_mask = 0x00; // just base telemetry allowed
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#define MAX_HASH_SIZE 8
|
#define MAX_HASH_SIZE 8
|
||||||
#define PUB_KEY_SIZE 32
|
#define PUB_KEY_SIZE 32
|
||||||
@@ -42,6 +43,7 @@ namespace mesh {
|
|||||||
class MainBoard {
|
class MainBoard {
|
||||||
public:
|
public:
|
||||||
virtual uint16_t getBattMilliVolts() = 0;
|
virtual uint16_t getBattMilliVolts() = 0;
|
||||||
|
virtual float getMCUTemperature() { return NAN; }
|
||||||
virtual bool setAdcMultiplier(float multiplier) { return false; };
|
virtual bool setAdcMultiplier(float multiplier) { return false; };
|
||||||
virtual float getAdcMultiplier() const { return 0.0f; }
|
virtual float getAdcMultiplier() const { return 0.0f; }
|
||||||
virtual const char* getManufacturerName() const = 0;
|
virtual const char* getManufacturerName() const = 0;
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Temperature from ESP32 MCU
|
||||||
|
float getMCUTemperature() override {
|
||||||
|
return temperatureRead();
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t getStartupReason() const override { return startup_reason; }
|
uint8_t getStartupReason() const override { return startup_reason; }
|
||||||
|
|
||||||
#if defined(P_LORA_TX_LED)
|
#if defined(P_LORA_TX_LED)
|
||||||
|
|||||||
23
src/helpers/NRF52Board.cpp
Normal file
23
src/helpers/NRF52Board.cpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#if defined(NRF52_PLATFORM)
|
||||||
|
#include "NRF52Board.h"
|
||||||
|
|
||||||
|
// Temperature from NRF52 MCU
|
||||||
|
float NRF52Board::getMCUTemperature() {
|
||||||
|
NRF_TEMP->TASKS_START = 1; // Start temperature measurement
|
||||||
|
|
||||||
|
long startTime = millis();
|
||||||
|
while (NRF_TEMP->EVENTS_DATARDY == 0) { // Wait for completion. Should complete in 50us
|
||||||
|
if(millis() - startTime > 5) { // To wait 5ms just in case
|
||||||
|
NRF_TEMP->TASKS_STOP = 1;
|
||||||
|
return NAN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NRF_TEMP->EVENTS_DATARDY = 0; // Clear event flag
|
||||||
|
|
||||||
|
int32_t temp = NRF_TEMP->TEMP; // In 0.25 *C units
|
||||||
|
NRF_TEMP->TASKS_STOP = 1;
|
||||||
|
|
||||||
|
return temp * 0.25f; // Convert to *C
|
||||||
|
}
|
||||||
|
#endif
|
||||||
12
src/helpers/NRF52Board.h
Normal file
12
src/helpers/NRF52Board.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <MeshCore.h>
|
||||||
|
|
||||||
|
#if defined(NRF52_PLATFORM)
|
||||||
|
|
||||||
|
class NRF52Board : public mesh::MainBoard {
|
||||||
|
public:
|
||||||
|
float getMCUTemperature() override;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
#ifdef HELTEC_MESH_SOLAR
|
#ifdef HELTEC_MESH_SOLAR
|
||||||
#include "meshSolarApp.h"
|
#include "meshSolarApp.h"
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
||||||
|
|
||||||
|
|
||||||
class MeshSolarBoard : public mesh::MainBoard {
|
class MeshSolarBoard : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
// built-ins
|
// built-ins
|
||||||
#define PIN_VBAT_READ 4
|
#define PIN_VBAT_READ 4
|
||||||
#define PIN_BAT_CTL 6
|
#define PIN_BAT_CTL 6
|
||||||
#define MV_LSB (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
|
#define MV_LSB (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
|
||||||
|
|
||||||
class T114Board : public mesh::MainBoard {
|
class T114Board : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
#ifdef XIAO_NRF52
|
#ifdef XIAO_NRF52
|
||||||
|
|
||||||
class IkokaNanoNRFBoard : public mesh::MainBoard {
|
class IkokaNanoNRFBoard : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
#ifdef XIAO_NRF52
|
#ifdef XIAO_NRF52
|
||||||
|
|
||||||
class IkokaStickNRFBoard : public mesh::MainBoard {
|
class IkokaStickNRFBoard : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
class KeepteenLT1Board : public mesh::MainBoard {
|
class KeepteenLT1Board : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
uint8_t btn_prev_state;
|
uint8_t btn_prev_state;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
// built-ins
|
// built-ins
|
||||||
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
|
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
#define PIN_VBAT_READ (4)
|
#define PIN_VBAT_READ (4)
|
||||||
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
|
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
|
||||||
|
|
||||||
class TechoBoard : public mesh::MainBoard {
|
class TechoBoard : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
// built-ins
|
// built-ins
|
||||||
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
|
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
#define PIN_VBAT_READ (4)
|
#define PIN_VBAT_READ (4)
|
||||||
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
|
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
|
||||||
|
|
||||||
class TechoBoard : public mesh::MainBoard {
|
class TechoBoard : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
// built-ins
|
// built-ins
|
||||||
#define PIN_VBAT_READ 29
|
#define PIN_VBAT_READ 29
|
||||||
#define PIN_BAT_CTL 34
|
#define PIN_BAT_CTL 34
|
||||||
#define MV_LSB (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
|
#define MV_LSB (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
|
||||||
|
|
||||||
class HeltecMeshPocket : public mesh::MainBoard {
|
class HeltecMeshPocket : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
// LoRa and SPI pins
|
// LoRa and SPI pins
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
#define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
|
#define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
|
||||||
|
|
||||||
|
|
||||||
class MinewsemiME25LS01Board : public mesh::MainBoard {
|
class MinewsemiME25LS01Board : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
uint8_t btn_prev_state;
|
uint8_t btn_prev_state;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
// LoRa radio module pins
|
// LoRa radio module pins
|
||||||
#define P_LORA_DIO_1 (32 + 10)
|
#define P_LORA_DIO_1 (32 + 10)
|
||||||
@@ -34,7 +35,7 @@
|
|||||||
#define PIN_VBAT_READ (0 + 2)
|
#define PIN_VBAT_READ (0 + 2)
|
||||||
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
|
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
|
||||||
|
|
||||||
class NanoG2Ultra : public mesh::MainBoard {
|
class NanoG2Ultra : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
#define P_LORA_NSS 13 //P1.13 45
|
#define P_LORA_NSS 13 //P1.13 45
|
||||||
#define P_LORA_DIO_1 11 //P0.10 10
|
#define P_LORA_DIO_1 11 //P0.10 10
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
#define PIN_VBAT_READ 17
|
#define PIN_VBAT_READ 17
|
||||||
#define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
|
#define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
|
||||||
|
|
||||||
class PromicroBoard : public mesh::MainBoard {
|
class PromicroBoard : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
uint8_t btn_prev_state;
|
uint8_t btn_prev_state;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
// LoRa radio module pins for RAK4631
|
// LoRa radio module pins for RAK4631
|
||||||
#define P_LORA_DIO_1 47
|
#define P_LORA_DIO_1 47
|
||||||
@@ -28,7 +29,7 @@
|
|||||||
#define PIN_VBAT_READ 5
|
#define PIN_VBAT_READ 5
|
||||||
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
|
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
|
||||||
|
|
||||||
class RAK4631Board : public mesh::MainBoard {
|
class RAK4631Board : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
// built-ins
|
// built-ins
|
||||||
#define PIN_VBAT_READ 5
|
#define PIN_VBAT_READ 5
|
||||||
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
|
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
|
||||||
|
|
||||||
class RAKWismeshTagBoard : public mesh::MainBoard {
|
class RAKWismeshTagBoard : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
class SenseCapSolarBoard : public mesh::MainBoard {
|
class SenseCapSolarBoard : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
class T1000eBoard : public mesh::MainBoard {
|
class T1000eBoard : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
uint8_t btn_prev_state;
|
uint8_t btn_prev_state;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
// built-ins
|
// built-ins
|
||||||
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
|
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
#define PIN_VBAT_READ (4)
|
#define PIN_VBAT_READ (4)
|
||||||
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
|
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
|
||||||
|
|
||||||
class ThinkNodeM1Board : public mesh::MainBoard {
|
class ThinkNodeM1Board : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
class WioTrackerL1Board : public mesh::MainBoard {
|
class WioTrackerL1Board : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
uint8_t btn_prev_state;
|
uint8_t btn_prev_state;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
#ifdef WIO_WM1110
|
#ifdef WIO_WM1110
|
||||||
|
|
||||||
@@ -10,7 +11,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#define Serial Serial1
|
#define Serial Serial1
|
||||||
|
|
||||||
class WioWM1110Board : public mesh::MainBoard {
|
class WioWM1110Board : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
#include <MeshCore.h>
|
#include <MeshCore.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <helpers/NRF52Board.h>
|
||||||
|
|
||||||
#ifdef XIAO_NRF52
|
#ifdef XIAO_NRF52
|
||||||
|
|
||||||
class XiaoNrf52Board : public mesh::MainBoard {
|
class XiaoNrf52Board : public NRF52Board {
|
||||||
protected:
|
protected:
|
||||||
uint8_t startup_reason;
|
uint8_t startup_reason;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user