kopia lustrzana https://github.com/meshtastic/firmware
rodzic
0c89aff0f6
commit
5d9800b7c2
|
@ -133,4 +133,3 @@ lib_deps =
|
|||
https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17
|
||||
adafruit/Adafruit LSM6DS@^4.7.2
|
||||
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 LPS22HB_ADDR 0x5C
|
||||
#define LPS22HB_ADDR_ALT 0x5D
|
||||
#define SHT31_4x_ADDR 0x44
|
||||
#define SHT31_ADDR 0x44
|
||||
#define PMSA0031_ADDR 0x12
|
||||
#define RCWL9620_ADDR 0x57
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ class ScanI2C
|
|||
INA3221,
|
||||
MCP9808,
|
||||
SHT31,
|
||||
SHT4X,
|
||||
SHTC3,
|
||||
LPS22HB,
|
||||
QMC6310,
|
||||
|
|
|
@ -292,18 +292,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port)
|
|||
|
||||
break;
|
||||
|
||||
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(SHT31_ADDR, SHT31, "SHT31 sensor found\n")
|
||||
SCAN_SIMPLE_CASE(SHTC3_ADDR, SHTC3, "SHTC3 sensor found\n")
|
||||
SCAN_SIMPLE_CASE(RCWL9620_ADDR, RCWL9620, "RCWL9620 sensor found\n")
|
||||
|
||||
|
@ -368,4 +357,4 @@ TwoWire *ScanI2CTwoWire::fetchI2CBus(ScanI2C::DeviceAddress address) const
|
|||
size_t ScanI2CTwoWire::countDevices() const
|
||||
{
|
||||
return foundDevices.size();
|
||||
}
|
||||
}
|
|
@ -541,7 +541,6 @@ void setup()
|
|||
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::RCWL9620, meshtastic_TelemetrySensorType_RCWL9620)
|
||||
SCANNER_TO_SENSORS_MAP(ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X)
|
||||
|
||||
i2cScanner.reset();
|
||||
|
||||
|
@ -1033,4 +1032,4 @@ void loop()
|
|||
mainDelay.delay(delayMsec);
|
||||
}
|
||||
// if (didWake) LOG_DEBUG("wake!\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "Sensor/MCP9808Sensor.h"
|
||||
#include "Sensor/RCWL9620Sensor.h"
|
||||
#include "Sensor/SHT31Sensor.h"
|
||||
#include "Sensor/SHT4XSensor.h"
|
||||
#include "Sensor/SHTC3Sensor.h"
|
||||
|
||||
BMP085Sensor bmp085Sensor;
|
||||
|
@ -37,7 +36,6 @@ MCP9808Sensor mcp9808Sensor;
|
|||
SHTC3Sensor shtc3Sensor;
|
||||
LPS22HBSensor lps22hbSensor;
|
||||
SHT31Sensor sht31Sensor;
|
||||
SHT4XSensor sht4xSensor;
|
||||
RCWL9620Sensor rcwl9620Sensor;
|
||||
|
||||
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
|
||||
|
@ -93,8 +91,6 @@ int32_t EnvironmentTelemetryModule::runOnce()
|
|||
result = lps22hbSensor.runOnce();
|
||||
if (sht31Sensor.hasSensor())
|
||||
result = sht31Sensor.runOnce();
|
||||
if (sht4xSensor.hasSensor())
|
||||
result = sht4xSensor.runOnce();
|
||||
if (ina219Sensor.hasSensor())
|
||||
result = ina219Sensor.runOnce();
|
||||
if (ina260Sensor.hasSensor())
|
||||
|
@ -250,8 +246,6 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
|
|||
|
||||
if (sht31Sensor.hasSensor())
|
||||
valid = sht31Sensor.getMetrics(&m);
|
||||
if (sht4xSensor.hasSensor())
|
||||
valid = sht4xSensor.getMetrics(&m);
|
||||
if (lps22hbSensor.hasSensor())
|
||||
valid = lps22hbSensor.getMetrics(&m);
|
||||
if (shtc3Sensor.hasSensor())
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
#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
|
|
@ -1,23 +0,0 @@
|
|||
#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
|
Ładowanie…
Reference in New Issue