Skip to content

Commit

Permalink
Merge pull request #169 from roberbike/nh3_support
Browse files Browse the repository at this point in the history
Nh3 support
  • Loading branch information
hpsaturn authored Jun 11, 2023
2 parents afeac6a + b02cdbb commit 912ead5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ NOTE: Panasonic via UART in ESP8266 maybe needs select in detection
| BMP280 | i2c | Auto | TESTING |
| BME680 | i2c | Auto | STABLE |
| DHTxx | TwoWire | Auto | DISABLED |
| DfRobot SEN0469 NH3 | --- | Yes | Auto | TESTING |
| DFRobot SEN0466 CO | --- | Yes | Auto | TESTING |

NOTE: DHT22 is supported but is not recommended. Please see the documentation.

Expand Down
55 changes: 55 additions & 0 deletions examples/DfRobot_Multigas/dfr_multigas.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @file main.cpp
* @date June 2018 - 2021
* @brief Particle meter sensor tests
* @license GPL3
*
* Full documentation:
* https://github.com/kike-canaries/canairio_sensorlib#canairio-air-quality-sensors-library
*
* Full implementation for WiFi and Bluetooth Air Quality fixed and mobile station:
* https://github.com/kike-canaries/canairio_firmware#canairio-firmware
*
* CanAirIO project:
* https://canair.io
*/

#include <Arduino.h>

#include <Sensors.hpp>

void onSensorDataOk() {
Serial.println("-->[MAIN] NH3: " + String(sensors.getNH3()));
Serial.println("-->[MAIN] CO: " + String(sensors.getCO()));
}

void onSensorDataError(const char* msg) {
Serial.println(msg);
}

/******************************************************************************
* M A I N
******************************************************************************/

void setup() {
Serial.begin(115200);
delay(200);
Serial.println("\n== Sensor test setup ==\n");

Serial.println("-->[SETUP] Detecting sensors..");

sensors.setSampleTime(5); // config sensors sample time interval
sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback
sensors.setOnErrorCallBack(&onSensorDataError); // [optional] error callback
sensors.setDebugMode(false); // [optional] debug mode
sensors.detectI2COnly(true); // force to only i2c sensors

sensors.init(SENSORS::SDFRCO); // detect CO sensor
sensors.init(SENSORS::SDFRNH3); // detect NH3 sensor

delay(500);
}

void loop() {
sensors.loop(); // read sensor data and showed it
}
4 changes: 2 additions & 2 deletions src/Sensors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ typedef enum UNIT : size_t { SENSOR_UNITS } UNIT;
X(SAHTXX, "AHTXX", 3) \
X(SAM232X, "AM232X", 3) \
X(SDHTX, "DHTX", 3) \
X(SDFRCO, "DFRCO", 2) \
X(SDFRNH3, "DFRNH3", 2) \
X(SDFRCO, "DFRCO", 3) \
X(SDFRNH3, "DFRNH3", 3) \
X(SCOUNT, "SCOUNT", 3)

#define X(utype, uname, umaintype) utype,
Expand Down

0 comments on commit 912ead5

Please sign in to comment.