mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-26 09:59:01 +00:00
Master to Develop
This commit is contained in:
parent
f632933b93
commit
94cb100e3f
@ -10,7 +10,6 @@
|
|||||||
;default_envs = heltec-v2.0
|
;default_envs = heltec-v2.0
|
||||||
;default_envs = heltec-v2.1
|
;default_envs = heltec-v2.1
|
||||||
;default_envs = tlora-v1
|
;default_envs = tlora-v1
|
||||||
;default_envs = tlora-v1
|
|
||||||
;default_envs = tlora_v1_3
|
;default_envs = tlora_v1_3
|
||||||
;default_envs = tlora-v2
|
;default_envs = tlora-v2
|
||||||
;default_envs = tlora-v2-1-1.6
|
;default_envs = tlora-v2-1-1.6
|
||||||
@ -108,4 +107,4 @@ lib_deps =
|
|||||||
adafruit/Adafruit INA260 Library@^1.5.0
|
adafruit/Adafruit INA260 Library@^1.5.0
|
||||||
adafruit/Adafruit INA219@^1.2.0
|
adafruit/Adafruit INA219@^1.2.0
|
||||||
adafruit/Adafruit SHTC3 Library@^1.0.0
|
adafruit/Adafruit SHTC3 Library@^1.0.0
|
||||||
adafruit/Adafruit LPS2X@^2.0.4
|
adafruit/Adafruit LPS2X@^2.0.4 adafruit/Adafruit SHT31 Library@^2.2.0
|
||||||
|
@ -114,6 +114,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define SHTC3_ADDR 0x70
|
#define SHTC3_ADDR 0x70
|
||||||
#define LPS22HB_ADDR 0x5C
|
#define LPS22HB_ADDR 0x5C
|
||||||
#define LPS22HB_ADDR_ALT 0x5D
|
#define LPS22HB_ADDR_ALT 0x5D
|
||||||
|
#define SHT31_ADDR 0x44
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Security
|
// Security
|
||||||
|
@ -191,6 +191,10 @@ void scanI2Cdevice()
|
|||||||
nodeTelemetrySensorsMap[TelemetrySensorType_MCP9808] = addr;
|
nodeTelemetrySensorsMap[TelemetrySensorType_MCP9808] = addr;
|
||||||
DEBUG_MSG("MCP9808 sensor found\n");
|
DEBUG_MSG("MCP9808 sensor found\n");
|
||||||
}
|
}
|
||||||
|
if (addr == SHT31_ADDR) {
|
||||||
|
DEBUG_MSG("SHT31 sensor found\n");
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_SHT31] = addr;
|
||||||
|
}
|
||||||
if (addr == SHTC3_ADDR) {
|
if (addr == SHTC3_ADDR) {
|
||||||
DEBUG_MSG("SHTC3 sensor found\n");
|
DEBUG_MSG("SHTC3 sensor found\n");
|
||||||
nodeTelemetrySensorsMap[TelemetrySensorType_SHTC3] = addr;
|
nodeTelemetrySensorsMap[TelemetrySensorType_SHTC3] = addr;
|
||||||
|
@ -196,6 +196,17 @@ Channel &Channels::getByIndex(ChannelIndex chIndex)
|
|||||||
return *ch;
|
return *ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Channel &Channels::getByName(const char* chName)
|
||||||
|
{
|
||||||
|
for (ChannelIndex i = 0; i < getNumChannels(); i++) {
|
||||||
|
if (strcasecmp(channelFile.channels[i].settings.name, chName) == 0) {
|
||||||
|
return channelFile.channels[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getByIndex(getPrimaryIndex());
|
||||||
|
}
|
||||||
|
|
||||||
void Channels::setChannel(const Channel &c)
|
void Channels::setChannel(const Channel &c)
|
||||||
{
|
{
|
||||||
Channel &old = getByIndex(c.index);
|
Channel &old = getByIndex(c.index);
|
||||||
|
@ -40,6 +40,9 @@ class Channels
|
|||||||
/** Return the Channel for a specified index */
|
/** Return the Channel for a specified index */
|
||||||
Channel &getByIndex(ChannelIndex chIndex);
|
Channel &getByIndex(ChannelIndex chIndex);
|
||||||
|
|
||||||
|
/** Return the Channel for a specified name, return primary if not found. */
|
||||||
|
Channel &getByName(const char* chName);
|
||||||
|
|
||||||
/** Using the index inside the channel, update the specified channel's settings and role. If this channel is being promoted
|
/** Using the index inside the channel, update the specified channel's settings and role. If this channel is being promoted
|
||||||
* to be primary, force all other channels to be secondary.
|
* to be primary, force all other channels to be secondary.
|
||||||
*/
|
*/
|
||||||
|
@ -35,7 +35,9 @@ typedef enum _TelemetrySensorType {
|
|||||||
/* 6-Axis inertial measurement sensor */
|
/* 6-Axis inertial measurement sensor */
|
||||||
TelemetrySensorType_QMI8658 = 10,
|
TelemetrySensorType_QMI8658 = 10,
|
||||||
/* 3-Axis magnetic sensor */
|
/* 3-Axis magnetic sensor */
|
||||||
TelemetrySensorType_QMC5883L = 11
|
TelemetrySensorType_QMC5883L = 11,
|
||||||
|
/* High accuracy temperature and humidity */
|
||||||
|
TelemetrySensorType_SHT31 = 12
|
||||||
} TelemetrySensorType;
|
} TelemetrySensorType;
|
||||||
|
|
||||||
/* Struct definitions */
|
/* Struct definitions */
|
||||||
@ -91,8 +93,8 @@ extern "C" {
|
|||||||
|
|
||||||
/* Helper constants for enums */
|
/* Helper constants for enums */
|
||||||
#define _TelemetrySensorType_MIN TelemetrySensorType_SENSOR_UNSET
|
#define _TelemetrySensorType_MIN TelemetrySensorType_SENSOR_UNSET
|
||||||
#define _TelemetrySensorType_MAX TelemetrySensorType_QMC5883L
|
#define _TelemetrySensorType_MAX TelemetrySensorType_SHT31
|
||||||
#define _TelemetrySensorType_ARRAYSIZE ((TelemetrySensorType)(TelemetrySensorType_QMC5883L+1))
|
#define _TelemetrySensorType_ARRAYSIZE ((TelemetrySensorType)(TelemetrySensorType_SHT31+1))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "Sensor/INA219Sensor.h"
|
#include "Sensor/INA219Sensor.h"
|
||||||
#include "Sensor/SHTC3Sensor.h"
|
#include "Sensor/SHTC3Sensor.h"
|
||||||
#include "Sensor/LPS22HBSensor.h"
|
#include "Sensor/LPS22HBSensor.h"
|
||||||
|
#include "Sensor/SHT31Sensor.h"
|
||||||
|
|
||||||
BMP280Sensor bmp280Sensor;
|
BMP280Sensor bmp280Sensor;
|
||||||
BME280Sensor bme280Sensor;
|
BME280Sensor bme280Sensor;
|
||||||
@ -29,6 +30,7 @@ INA260Sensor ina260Sensor;
|
|||||||
INA219Sensor ina219Sensor;
|
INA219Sensor ina219Sensor;
|
||||||
SHTC3Sensor shtc3Sensor;
|
SHTC3Sensor shtc3Sensor;
|
||||||
LPS22HBSensor lps22hbSensor;
|
LPS22HBSensor lps22hbSensor;
|
||||||
|
SHT31Sensor sht31Sensor;
|
||||||
|
|
||||||
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
|
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
|
||||||
#define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true
|
#define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true
|
||||||
@ -93,6 +95,8 @@ int32_t EnvironmentTelemetryModule::runOnce()
|
|||||||
if (lps22hbSensor.hasSensor()) {
|
if (lps22hbSensor.hasSensor()) {
|
||||||
result = lps22hbSensor.runOnce();
|
result = lps22hbSensor.runOnce();
|
||||||
}
|
}
|
||||||
|
if (sht31Sensor.hasSensor())
|
||||||
|
result = sht31Sensor.runOnce();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
@ -211,6 +215,8 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
|
|||||||
m.variant.environment_metrics.temperature = 0;
|
m.variant.environment_metrics.temperature = 0;
|
||||||
m.variant.environment_metrics.voltage = 0;
|
m.variant.environment_metrics.voltage = 0;
|
||||||
|
|
||||||
|
if (sht31Sensor.hasSensor())
|
||||||
|
sht31Sensor.getMetrics(&m);
|
||||||
if (lps22hbSensor.hasSensor())
|
if (lps22hbSensor.hasSensor())
|
||||||
lps22hbSensor.getMetrics(&m);
|
lps22hbSensor.getMetrics(&m);
|
||||||
if (shtc3Sensor.hasSensor())
|
if (shtc3Sensor.hasSensor())
|
||||||
|
31
src/modules/Telemetry/Sensor/SHT31Sensor.cpp
Normal file
31
src/modules/Telemetry/Sensor/SHT31Sensor.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include "../mesh/generated/telemetry.pb.h"
|
||||||
|
#include "configuration.h"
|
||||||
|
#include "TelemetrySensor.h"
|
||||||
|
#include "SHT31Sensor.h"
|
||||||
|
#include <Adafruit_SHT31.h>
|
||||||
|
|
||||||
|
SHT31Sensor::SHT31Sensor() :
|
||||||
|
TelemetrySensor(TelemetrySensorType_SHT31, "SHT31")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t SHT31Sensor::runOnce() {
|
||||||
|
DEBUG_MSG("Init sensor: %s\n", sensorName);
|
||||||
|
if (!hasSensor()) {
|
||||||
|
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||||
|
}
|
||||||
|
status = sht31.begin();
|
||||||
|
return initI2CSensor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHT31Sensor::setup()
|
||||||
|
{
|
||||||
|
// Set up oversampling and filter initialization
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SHT31Sensor::getMetrics(Telemetry *measurement) {
|
||||||
|
measurement->variant.environment_metrics.temperature = sht31.readTemperature();
|
||||||
|
measurement->variant.environment_metrics.relative_humidity = sht31.readHumidity();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
16
src/modules/Telemetry/Sensor/SHT31Sensor.h
Normal file
16
src/modules/Telemetry/Sensor/SHT31Sensor.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include "../mesh/generated/telemetry.pb.h"
|
||||||
|
#include "TelemetrySensor.h"
|
||||||
|
#include <Adafruit_SHT31.h>
|
||||||
|
|
||||||
|
class SHT31Sensor : virtual public TelemetrySensor {
|
||||||
|
private:
|
||||||
|
Adafruit_SHT31 sht31 = Adafruit_SHT31();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void setup() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SHT31Sensor();
|
||||||
|
virtual int32_t runOnce() override;
|
||||||
|
virtual bool getMetrics(Telemetry *measurement) override;
|
||||||
|
};
|
@ -66,3 +66,4 @@
|
|||||||
//has 32768 Hz crystal
|
//has 32768 Hz crystal
|
||||||
#define HAS_32768HZ
|
#define HAS_32768HZ
|
||||||
|
|
||||||
|
#define USE_SH1106
|
Loading…
Reference in New Issue
Block a user