mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-23 17:13:38 +00:00
This reverts commit 5d9800b7c2
.
This commit is contained in:
parent
676319a9ca
commit
ac22a503de
@ -133,3 +133,4 @@ lib_deps =
|
|||||||
https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17
|
https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17
|
||||||
adafruit/Adafruit LSM6DS@^4.7.2
|
adafruit/Adafruit LSM6DS@^4.7.2
|
||||||
mprograms/QMC5883LCompass@^1.2.0
|
mprograms/QMC5883LCompass@^1.2.0
|
||||||
|
https://github.com/Sensirion/arduino-i2c-sht4x#1.1.0
|
||||||
|
@ -126,7 +126,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
|
#define SHT31_4x_ADDR 0x44
|
||||||
#define PMSA0031_ADDR 0x12
|
#define PMSA0031_ADDR 0x12
|
||||||
#define RCWL9620_ADDR 0x57
|
#define RCWL9620_ADDR 0x57
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ class ScanI2C
|
|||||||
INA3221,
|
INA3221,
|
||||||
MCP9808,
|
MCP9808,
|
||||||
SHT31,
|
SHT31,
|
||||||
|
SHT4X,
|
||||||
SHTC3,
|
SHTC3,
|
||||||
LPS22HB,
|
LPS22HB,
|
||||||
QMC6310,
|
QMC6310,
|
||||||
|
@ -292,7 +292,18 @@ void ScanI2CTwoWire::scanPort(I2CPort port)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
SCAN_SIMPLE_CASE(SHT31_ADDR, SHT31, "SHT31 sensor found\n")
|
case SHT31_4x_ADDR:
|
||||||
|
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 2);
|
||||||
|
if (registerValue == 0x11a2) {
|
||||||
|
type = SHT4X;
|
||||||
|
LOG_INFO("SHT4X sensor found\n");
|
||||||
|
} else {
|
||||||
|
type = SHT31;
|
||||||
|
LOG_INFO("SHT31 sensor found\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
SCAN_SIMPLE_CASE(SHTC3_ADDR, SHTC3, "SHTC3 sensor found\n")
|
SCAN_SIMPLE_CASE(SHTC3_ADDR, SHTC3, "SHTC3 sensor found\n")
|
||||||
SCAN_SIMPLE_CASE(RCWL9620_ADDR, RCWL9620, "RCWL9620 sensor found\n")
|
SCAN_SIMPLE_CASE(RCWL9620_ADDR, RCWL9620, "RCWL9620 sensor found\n")
|
||||||
|
|
||||||
@ -357,4 +368,4 @@ TwoWire *ScanI2CTwoWire::fetchI2CBus(ScanI2C::DeviceAddress address) const
|
|||||||
size_t ScanI2CTwoWire::countDevices() const
|
size_t ScanI2CTwoWire::countDevices() const
|
||||||
{
|
{
|
||||||
return foundDevices.size();
|
return foundDevices.size();
|
||||||
}
|
}
|
||||||
|
@ -541,6 +541,7 @@ void setup()
|
|||||||
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMC5883L, meshtastic_TelemetrySensorType_QMC5883L)
|
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::QMC5883L, meshtastic_TelemetrySensorType_QMC5883L)
|
||||||
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::PMSA0031, meshtastic_TelemetrySensorType_PMSA003I)
|
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::PMSA0031, meshtastic_TelemetrySensorType_PMSA003I)
|
||||||
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::RCWL9620, meshtastic_TelemetrySensorType_RCWL9620)
|
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::RCWL9620, meshtastic_TelemetrySensorType_RCWL9620)
|
||||||
|
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X)
|
||||||
|
|
||||||
i2cScanner.reset();
|
i2cScanner.reset();
|
||||||
|
|
||||||
@ -1034,4 +1035,4 @@ void loop()
|
|||||||
mainDelay.delay(delayMsec);
|
mainDelay.delay(delayMsec);
|
||||||
}
|
}
|
||||||
// if (didWake) LOG_DEBUG("wake!\n");
|
// if (didWake) LOG_DEBUG("wake!\n");
|
||||||
}
|
}
|
@ -26,6 +26,7 @@
|
|||||||
#include "Sensor/MCP9808Sensor.h"
|
#include "Sensor/MCP9808Sensor.h"
|
||||||
#include "Sensor/RCWL9620Sensor.h"
|
#include "Sensor/RCWL9620Sensor.h"
|
||||||
#include "Sensor/SHT31Sensor.h"
|
#include "Sensor/SHT31Sensor.h"
|
||||||
|
#include "Sensor/SHT4XSensor.h"
|
||||||
#include "Sensor/SHTC3Sensor.h"
|
#include "Sensor/SHTC3Sensor.h"
|
||||||
|
|
||||||
BMP085Sensor bmp085Sensor;
|
BMP085Sensor bmp085Sensor;
|
||||||
@ -36,6 +37,7 @@ MCP9808Sensor mcp9808Sensor;
|
|||||||
SHTC3Sensor shtc3Sensor;
|
SHTC3Sensor shtc3Sensor;
|
||||||
LPS22HBSensor lps22hbSensor;
|
LPS22HBSensor lps22hbSensor;
|
||||||
SHT31Sensor sht31Sensor;
|
SHT31Sensor sht31Sensor;
|
||||||
|
SHT4XSensor sht4xSensor;
|
||||||
RCWL9620Sensor rcwl9620Sensor;
|
RCWL9620Sensor rcwl9620Sensor;
|
||||||
|
|
||||||
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
|
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
|
||||||
@ -91,6 +93,8 @@ int32_t EnvironmentTelemetryModule::runOnce()
|
|||||||
result = lps22hbSensor.runOnce();
|
result = lps22hbSensor.runOnce();
|
||||||
if (sht31Sensor.hasSensor())
|
if (sht31Sensor.hasSensor())
|
||||||
result = sht31Sensor.runOnce();
|
result = sht31Sensor.runOnce();
|
||||||
|
if (sht4xSensor.hasSensor())
|
||||||
|
result = sht4xSensor.runOnce();
|
||||||
if (ina219Sensor.hasSensor())
|
if (ina219Sensor.hasSensor())
|
||||||
result = ina219Sensor.runOnce();
|
result = ina219Sensor.runOnce();
|
||||||
if (ina260Sensor.hasSensor())
|
if (ina260Sensor.hasSensor())
|
||||||
@ -246,6 +250,8 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
|
|||||||
|
|
||||||
if (sht31Sensor.hasSensor())
|
if (sht31Sensor.hasSensor())
|
||||||
valid = sht31Sensor.getMetrics(&m);
|
valid = sht31Sensor.getMetrics(&m);
|
||||||
|
if (sht4xSensor.hasSensor())
|
||||||
|
valid = sht4xSensor.getMetrics(&m);
|
||||||
if (lps22hbSensor.hasSensor())
|
if (lps22hbSensor.hasSensor())
|
||||||
valid = lps22hbSensor.getMetrics(&m);
|
valid = lps22hbSensor.getMetrics(&m);
|
||||||
if (shtc3Sensor.hasSensor())
|
if (shtc3Sensor.hasSensor())
|
||||||
|
63
src/modules/Telemetry/Sensor/SHT4XSensor.cpp
Normal file
63
src/modules/Telemetry/Sensor/SHT4XSensor.cpp
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#include "configuration.h"
|
||||||
|
|
||||||
|
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
||||||
|
|
||||||
|
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
||||||
|
#include "SHT4XSensor.h"
|
||||||
|
#include "TelemetrySensor.h"
|
||||||
|
#include <SensirionI2cSht4x.h>
|
||||||
|
|
||||||
|
// macro definitions
|
||||||
|
// make sure that we use the proper definition of NO_ERROR
|
||||||
|
#ifdef NO_ERROR
|
||||||
|
#undef NO_ERROR
|
||||||
|
#endif
|
||||||
|
#define NO_ERROR 0
|
||||||
|
|
||||||
|
static char errorMessage[64];
|
||||||
|
static int16_t error;
|
||||||
|
|
||||||
|
SHT4XSensor::SHT4XSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT4X, "SHT4X") {}
|
||||||
|
|
||||||
|
int32_t SHT4XSensor::runOnce()
|
||||||
|
{
|
||||||
|
LOG_INFO("Init sensor: %s\n", sensorName);
|
||||||
|
if (!hasSensor()) {
|
||||||
|
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t serialNumber = 0;
|
||||||
|
|
||||||
|
sht4x.begin(*nodeTelemetrySensorsMap[sensorType].second, 0x44);
|
||||||
|
|
||||||
|
error = sht4x.serialNumber(serialNumber);
|
||||||
|
LOG_DEBUG("serialNumber : %x\n", serialNumber);
|
||||||
|
if (error != NO_ERROR) {
|
||||||
|
LOG_DEBUG("Error trying to execute serialNumber(): ");
|
||||||
|
errorToString(error, errorMessage, sizeof errorMessage);
|
||||||
|
LOG_DEBUG(errorMessage);
|
||||||
|
status = 0;
|
||||||
|
} else {
|
||||||
|
status = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return initI2CSensor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHT4XSensor::setup()
|
||||||
|
{
|
||||||
|
// Set up oversampling and filter initialization
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SHT4XSensor::getMetrics(meshtastic_Telemetry *measurement)
|
||||||
|
{
|
||||||
|
float aTemperature = 0.0;
|
||||||
|
float aHumidity = 0.0;
|
||||||
|
sht4x.measureLowestPrecision(aTemperature, aHumidity);
|
||||||
|
measurement->variant.environment_metrics.temperature = aTemperature;
|
||||||
|
measurement->variant.environment_metrics.relative_humidity = aHumidity;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
23
src/modules/Telemetry/Sensor/SHT4XSensor.h
Normal file
23
src/modules/Telemetry/Sensor/SHT4XSensor.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include "configuration.h"
|
||||||
|
|
||||||
|
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
||||||
|
|
||||||
|
#include "../mesh/generated/meshtastic/telemetry.pb.h"
|
||||||
|
#include "TelemetrySensor.h"
|
||||||
|
#include <SensirionI2cSht4x.h>
|
||||||
|
|
||||||
|
class SHT4XSensor : public TelemetrySensor
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
SensirionI2cSht4x sht4x;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void setup() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SHT4XSensor();
|
||||||
|
virtual int32_t runOnce() override;
|
||||||
|
virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user