Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nh3 support #169

Merged
merged 2 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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