Browse Source
Merge pull request #1206 from IoTThinks/MCdev-MCUTemperature-for-repeaters-202512
Added default temperature from ESP32 MCU and NRF52 MCU
pull/1236/head
ripplebiz
6 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with
86 additions and
19 deletions
-
examples/simple_repeater/MyMesh.cpp
-
src/MeshCore.h
-
src/helpers/ESP32Board.h
-
src/helpers/NRF52Board.cpp
-
src/helpers/NRF52Board.h
-
variants/heltec_mesh_solar/MeshSolarBoard.h
-
variants/heltec_t114/T114Board.h
-
variants/ikoka_nano_nrf/IkokaNanoNRFBoard.h
-
variants/ikoka_stick_nrf/IkokaStickNRFBoard.h
-
variants/keepteen_lt1/KeepteenLT1Board.h
-
variants/lilygo_techo/TechoBoard.h
-
variants/lilygo_techo_lite/TechoBoard.h
-
variants/mesh_pocket/MeshPocket.h
-
variants/minewsemi_me25ls01/MinewsemiME25LS01Board.h
-
variants/nano_g2_ultra/nano-g2.h
-
variants/promicro/PromicroBoard.h
-
variants/rak4631/RAK4631Board.h
-
variants/rak_wismesh_tag/RAKWismeshTagBoard.h
-
variants/sensecap_solar/SenseCapSolarBoard.h
-
variants/t1000-e/T1000eBoard.h
-
variants/thinknode_m1/ThinkNodeM1Board.h
-
variants/wio-tracker-l1/WioTrackerL1Board.h
-
variants/wio_wm1110/WioWM1110Board.h
-
variants/xiao_nrf52/XiaoNrf52Board.h
|
|
|
@ -173,6 +173,12 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t |
|
|
|
|
|
|
|
telemetry.reset(); |
|
|
|
telemetry.addVoltage(TELEM_CHANNEL_SELF, (float)board.getBattMilliVolts() / 1000.0f); |
|
|
|
|
|
|
|
float temperature = board.getMCUTemperature(); |
|
|
|
if(!isnan(temperature)) { // Supported boards with built-in temperature sensor. ESP32-C3 may return NAN
|
|
|
|
telemetry.addTemperature(TELEM_CHANNEL_SELF, temperature); // Built-in MCU Temperature
|
|
|
|
} |
|
|
|
|
|
|
|
// query other sensors -- target specific
|
|
|
|
if ((sender->permissions & PERM_ACL_ROLE_MASK) == PERM_ACL_GUEST) { |
|
|
|
perm_mask = 0x00; // just base telemetry allowed
|
|
|
|
|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
#pragma once |
|
|
|
|
|
|
|
#include <stdint.h> |
|
|
|
#include <math.h> |
|
|
|
|
|
|
|
#define MAX_HASH_SIZE 8 |
|
|
|
#define PUB_KEY_SIZE 32 |
|
|
|
@ -42,6 +43,7 @@ namespace mesh { |
|
|
|
class MainBoard { |
|
|
|
public: |
|
|
|
virtual uint16_t getBattMilliVolts() = 0; |
|
|
|
virtual float getMCUTemperature() { return NAN; } |
|
|
|
virtual bool setAdcMultiplier(float multiplier) { return false; }; |
|
|
|
virtual float getAdcMultiplier() const { return 0.0f; } |
|
|
|
virtual const char* getManufacturerName() const = 0; |
|
|
|
|
|
|
|
@ -42,6 +42,11 @@ public: |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
// Temperature from ESP32 MCU
|
|
|
|
float getMCUTemperature() override { |
|
|
|
return temperatureRead(); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t getStartupReason() const override { return startup_reason; } |
|
|
|
|
|
|
|
#if defined(P_LORA_TX_LED) |
|
|
|
|
|
|
|
@ -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 |
|
|
|
@ -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 <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
#ifdef HELTEC_MESH_SOLAR |
|
|
|
#include "meshSolarApp.h" |
|
|
|
@ -20,7 +21,7 @@ |
|
|
|
#define SX126X_DIO3_TCXO_VOLTAGE 1.8 |
|
|
|
|
|
|
|
|
|
|
|
class MeshSolarBoard : public mesh::MainBoard { |
|
|
|
class MeshSolarBoard : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,13 +2,14 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
// built-ins
|
|
|
|
#define PIN_VBAT_READ 4 |
|
|
|
#define PIN_BAT_CTL 6 |
|
|
|
#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: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,10 +2,11 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
#ifdef XIAO_NRF52 |
|
|
|
|
|
|
|
class IkokaNanoNRFBoard : public mesh::MainBoard { |
|
|
|
class IkokaNanoNRFBoard : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,10 +2,11 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
#ifdef XIAO_NRF52 |
|
|
|
|
|
|
|
class IkokaStickNRFBoard : public mesh::MainBoard { |
|
|
|
class IkokaStickNRFBoard : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,8 +2,9 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
class KeepteenLT1Board : public mesh::MainBoard { |
|
|
|
class KeepteenLT1Board : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
uint8_t btn_prev_state; |
|
|
|
|
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
// built-ins
|
|
|
|
#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 REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB) |
|
|
|
|
|
|
|
class TechoBoard : public mesh::MainBoard { |
|
|
|
class TechoBoard : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
// built-ins
|
|
|
|
#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 REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB) |
|
|
|
|
|
|
|
class TechoBoard : public mesh::MainBoard { |
|
|
|
class TechoBoard : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,13 +2,14 @@ |
|
|
|
|
|
|
|
#include <Arduino.h> |
|
|
|
#include <MeshCore.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
// built-ins
|
|
|
|
#define PIN_VBAT_READ 29 |
|
|
|
#define PIN_BAT_CTL 34 |
|
|
|
#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: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
// LoRa and SPI pins
|
|
|
|
|
|
|
|
@ -20,7 +21,7 @@ |
|
|
|
#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: |
|
|
|
uint8_t startup_reason; |
|
|
|
uint8_t btn_prev_state; |
|
|
|
|
|
|
|
@ -4,6 +4,7 @@ |
|
|
|
|
|
|
|
#include <Arduino.h> |
|
|
|
#include <MeshCore.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
// LoRa radio module pins
|
|
|
|
#define P_LORA_DIO_1 (32 + 10) |
|
|
|
@ -34,7 +35,7 @@ |
|
|
|
#define PIN_VBAT_READ (0 + 2) |
|
|
|
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB) |
|
|
|
|
|
|
|
class NanoG2Ultra : public mesh::MainBoard { |
|
|
|
class NanoG2Ultra : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
#define P_LORA_NSS 13 //P1.13 45
|
|
|
|
#define P_LORA_DIO_1 11 //P0.10 10
|
|
|
|
@ -19,7 +20,7 @@ |
|
|
|
#define PIN_VBAT_READ 17 |
|
|
|
#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: |
|
|
|
uint8_t startup_reason; |
|
|
|
uint8_t btn_prev_state; |
|
|
|
|
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
// LoRa radio module pins for RAK4631
|
|
|
|
#define P_LORA_DIO_1 47 |
|
|
|
@ -28,7 +29,7 @@ |
|
|
|
#define PIN_VBAT_READ 5 |
|
|
|
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000) |
|
|
|
|
|
|
|
class RAK4631Board : public mesh::MainBoard { |
|
|
|
class RAK4631Board : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,12 +2,13 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
// built-ins
|
|
|
|
#define PIN_VBAT_READ 5 |
|
|
|
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000) |
|
|
|
|
|
|
|
class RAKWismeshTagBoard : public mesh::MainBoard { |
|
|
|
class RAKWismeshTagBoard : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,8 +2,9 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
class SenseCapSolarBoard : public mesh::MainBoard { |
|
|
|
class SenseCapSolarBoard : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,8 +2,9 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
class T1000eBoard : public mesh::MainBoard { |
|
|
|
class T1000eBoard : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
uint8_t btn_prev_state; |
|
|
|
|
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
// built-ins
|
|
|
|
#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 REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB) |
|
|
|
|
|
|
|
class ThinkNodeM1Board : public mesh::MainBoard { |
|
|
|
class ThinkNodeM1Board : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,8 +2,9 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
class WioTrackerL1Board : public mesh::MainBoard { |
|
|
|
class WioTrackerL1Board : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
uint8_t btn_prev_state; |
|
|
|
|
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
#ifdef WIO_WM1110 |
|
|
|
|
|
|
|
@ -10,7 +11,7 @@ |
|
|
|
#endif |
|
|
|
#define Serial Serial1 |
|
|
|
|
|
|
|
class WioWM1110Board : public mesh::MainBoard { |
|
|
|
class WioWM1110Board : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|
|
|
|
@ -2,10 +2,11 @@ |
|
|
|
|
|
|
|
#include <MeshCore.h> |
|
|
|
#include <Arduino.h> |
|
|
|
#include <helpers/NRF52Board.h> |
|
|
|
|
|
|
|
#ifdef XIAO_NRF52 |
|
|
|
|
|
|
|
class XiaoNrf52Board : public mesh::MainBoard { |
|
|
|
class XiaoNrf52Board : public NRF52Board { |
|
|
|
protected: |
|
|
|
uint8_t startup_reason; |
|
|
|
|
|
|
|
|