Skip to content

Commit

Permalink
Merge pull request #168 from roberbike/nh3_support
Browse files Browse the repository at this point in the history
Nh3 support
  • Loading branch information
hpsaturn authored Jun 10, 2023
2 parents b0c03f4 + f100558 commit 5146b6a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ upload_speed = 1500000
monitor_speed = 115200
monitor_filters = time
build_flags =
-D CORE_DEBUG_LEVEL=3
-D CORE_DEBUG_LEVEL=0
-D ARDUINO_ESP32_DEV=1
; -D DHT11_ENABLED=1 // Deprecated, please change this old sensor
; -D DHT_SENSOR_TYPE=2
Expand Down
34 changes: 16 additions & 18 deletions src/Sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ bool Sensors::readAllSensors() {
dataReady = pmSensorRead();
DEBUG("-->[SLIB] UART data ready \t:", dataReady ? "true" : "false");
}
enableWire1();
enableWire1();
CO2scd30Read();
GCJA5Read();
sps30Read();
CO2scd4xRead();
am2320Read();
am2320Read();
sht31Read();
bme280Read();
bmp280Read();
bme680Read();
aht10Read();
// DFRobotCORead();
bme680Read();
aht10Read();
DFRobotCORead();
DFRobotNH3Read();
#ifdef DHT11_ENABLED
dhtRead();
Expand Down Expand Up @@ -116,18 +116,18 @@ void Sensors::init(u_int pms_type, int pms_rx, int pms_tx) {
DEBUG("-->[SLIB] UART sensors detected\t:", "0");
}

startI2C();
startI2C();
CO2scd30Init();
sps30I2CInit();
GCJA5Init();
CO2scd4xInit();
bmp280Init();
bme280Init();
bme680Init();
am2320Init();
sht31Init();
aht10Init();
// DFRobotCOInit();
am2320Init();
sht31Init();
aht10Init();
DFRobotCOInit();
DFRobotNH3Init();

#ifdef DHT11_ENABLED
Expand Down Expand Up @@ -990,16 +990,16 @@ void Sensors::GCJA5Read() {

void Sensors::DFRobotNH3Read() {
if (!dfrNH3.begin()) return;
String gastype = dfrNH3.queryGasType();
nh3 = dfrNH3.readGasConcentrationPPM();
unitRegister(UNIT::NH3);

}

void Sensors::DFRobotCORead() {
if (!dfrCO.begin()) return;
String gastype = dfrCO.queryGasType();
co = dfrCO.readGasConcentrationPPM();
unitRegister(UNIT::CO);

}

#ifdef DHT11_ENABLED
Expand Down Expand Up @@ -1583,20 +1583,18 @@ void Sensors::DFRobotCOInit() {
dfrCO = DFRobot_GAS_I2C(&Wire, 0x74);
if (!dfrCO.begin()) return;
//Mode of obtaining data: the main controller needs to request the sensor for data
delay(1000); // TODO: we need validate if we need that
//Turn on temperature compensation: gas.ON : turn on
dfrCO.changeAcquireMode(dfrCO.PASSIVITY);
//Turn on temperature compensation: gas.ON : turn on
dfrNH3.setTempCompensation(dfrCO.ON);
sensorRegister(SENSORS::SDFRCO);
}

void Sensors::DFRobotNH3Init() {
sensorAnnounce(SENSORS::SDFRNH3);
dfrNH3 = DFRobot_GAS_I2C(&Wire, 0x77);
dfrNH3 = DFRobot_GAS_I2C(&Wire, 0x76); // 0x77 y 0x75 used by bme680
if (!dfrNH3.begin()) return;
//Mode of obtaining data: the main controller needs to request the sensor for data
// dfrNH3.changeAcquireMode(dfrNH3.PASSIVITY);
delay(1000); // TODO: we need validate if we need that

dfrNH3.changeAcquireMode(dfrNH3.PASSIVITY);
//Turn on temperature compensation: gas.ON : turn on
dfrNH3.setTempCompensation(dfrNH3.ON);
sensorRegister(SENSORS::SDFRNH3);
Expand Down

0 comments on commit 5146b6a

Please sign in to comment.