Skip to content

Commit

Permalink
Merge pull request #180 from kike-canaries/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
hpsaturn authored Nov 19, 2023
2 parents 0be8e83 + 658df0e commit 02c8d14
Show file tree
Hide file tree
Showing 11 changed files with 355 additions and 46 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Panasonic via UART in ESP8266 maybe needs select in detection.
| BME680 | i2c | Auto | STABLE |
| DfRobot SEN0469 NH3 | i2c | Auto | TESTING |
| DFRobot SEN0466 CO | i2c | Auto | TESTING |
| DFRobot SEN0471 NO2 | i2c | Auto | TESTING |
| Geiger CAJOE | GPIO | Select | TESTING |
| DHTxx | TwoWire | Select | DISABLED |

Expand Down Expand Up @@ -364,7 +365,7 @@ Also you can make a donation, be a patreon or buy a device:
- [x] SenseAir S8 via UART support
- [x] Multivariable selection (getNextUnit(),getUnitName(),etc)
- [x] Two I2C channel supported for M5Stack Devices (M5StickC tested)
- [x] Added CO and NH3 sensors
- [x] Added CO, NO2 and NH3 sensors
- [x] Added Geiger sensor support
- [ ] New IKEA VINDSTYRKA device support
- [ ] Sea level setting for Pressure sensors and others
Expand Down
2 changes: 1 addition & 1 deletion doxygen.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "CanAirIO Sensors Library"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.7.1
PROJECT_NUMBER = 0.7.3

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 2 additions & 0 deletions examples/DfRobot_Multigas/dfr_multigas.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
void onSensorDataOk() {
Serial.println("-->[MAIN] NH3: " + String(sensors.getNH3()));
Serial.println("-->[MAIN] CO: " + String(sensors.getCO()));
Serial.println("-->[MAIN] NO2: " + String(sensors.getNO2()));)
}

void onSensorDataError(const char* msg) {
Expand All @@ -46,6 +47,7 @@ void setup() {

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

delay(500);
}
Expand Down
147 changes: 147 additions & 0 deletions examples/DfRobot_Multigas/i2c_change/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/*!
* @file readGasConcentration.ino
* @brief Obtain gas concentration corresponding to the current environment, output as concentration value
* @n Experimental mode: connect sensor communication pin to the main controller and burn
* @n Communication mode select, DIP switch SEL: 0: I2C, 1: UART
* @n Group serial number Address in the group
* @n A0 A1 DIP level 00 01 10 11
* @n 1 0x60 0x61 0x62 0x63
* @n 2 0x64 0x65 0x66 0x67
* @n 3 0x68 0x69 0x6A 0x6B
* @n 4 0x6C 0x6D 0x6E 0x6F
* @n 5 0x70 0x71 0x72 0x73
* @n 6 (Default address group) 0x74 0x75 0x76 0x77 (Default address)
* @n 7 0x78 0x79 0x7A 0x7B
* @n 8 0x7C 0x7D 0x7E 0x7F
* @n i2c address select, default to 0x77, A1 and A0 are grouped into 4 I2C addresses.
* @n | A0 | A1 |
* @n | 0 | 0 | 0x74
* @n | 0 | 1 | 0x75
* @n | 1 | 0 | 0x76
* @n | 1 | 1 | 0x77 default i2c address
* @n Experimental phenomenon: view the gas concentration corresponding to the current environment through serial port printing
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @license The MIT License (MIT)
* @author PengKaixing([email protected])
* @version V1.0
* @date 2021-03-28
* @url https://github.com/DFRobot/DFRobot_MultiGasSensor
*/
#include "DFRobot_MultiGasSensor.h"
#include <Arduino.h>

//Turn on by default, using I2C communication at the time, switch to serial port communication after turning off
//#define I2C_COMMUNICATION

//#ifdef I2C_COMMUNICATION
//#define I2C_ADDRESS 0x77
DFRobot_GAS_I2C nh3(&Wire,0x7A);
DFRobot_GAS_I2C co(&Wire,0x78);
DFRobot_GAS_I2C no2(&Wire,0x7B);

void setup() {
//Serial port init for viewing printing output
Serial.begin(115200);

//Change i2c address group
while(gas.changeI2cAddrGroup(7)==0)
{
Serial.println("IIC addr change fail!");
delay(1000);
}
Serial.println("IIC addr change success!");
}

//Sensor init, used to init serial port or I2C, depending on the communication mode currently used
while(!nh3.begin())
{
Serial.println("No Devices NH3 !");
delay(1000);
}
//Mode of obtaining data: the main controller needs to request the sensor for data
nh3.changeAcquireMode(nh3.PASSIVITY);
delay(1000);

nh3.setTempCompensation(nh3.ON);

Serial.println("The device nh3 0x7A is connected successfully!");

while(!co.begin())
{
Serial.println("No Devices CO !");
delay(1000);
}

co.changeAcquireMode(co.PASSIVITY);
delay(1000);

co.setTempCompensation(co.ON);

Serial.println("The device CO 0x78 is connected successfully!");

while(!no2.begin())
{
Serial.println("No Devices NO2 !");
delay(1000);
}

no2.changeAcquireMode(no2.PASSIVITY);
delay(1000);

no2.setTempCompensation(no2.ON);

Serial.println("The device CO 0x7B is connected successfully!");
}

void loop() {
String gastypeNH3 = nh3.queryGasType();
/**
*Fill in the parameter readGasConcentration() with the type of gas to be obtained and print
*The current gas concentration
*Print with 1s delay each time
*/
Serial.print("Ambient ");
Serial.print(gastypeNH3);
Serial.print(" concentration is: ");
Serial.print(nh3.readGasConcentrationPPM());
if (gastypeNH3 == "O2")
Serial.println(" %vol");
else
Serial.println(" PPM");
Serial.println();
delay(1000);

String gastypeCO = co.queryGasType();
/**
*Fill in the parameter readGasConcentration() with the type of gas to be obtained and print
*The current gas concentration
*Print with 1s delay each time
*/
Serial.print("Ambient ");
Serial.print(gastypeCO);
Serial.print(" concentration is: ");
Serial.print(co.readGasConcentrationPPM());
if (gastypeCO == "O2")
Serial.println(" %vol");
else
Serial.println(" PPM");
Serial.println();
delay(1000);

String gastypeNO2 = no2.queryGasType();
/**
*Fill in the parameter readGasConcentration() with the type of gas to be obtained and print
*The current gas concentration
*Print with 1s delay each time
*/
Serial.print("Ambient ");
Serial.print(gastypeNO2);
Serial.print(" concentration is: ");
Serial.print(no2.readGasConcentrationPPM());
if (gastypeNO2 == "O2")
Serial.println(" %vol");
else
Serial.println(" PPM");
Serial.println();
delay(1000);
}
18 changes: 18 additions & 0 deletions examples/DfRobot_Multigas/i2c_change/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
monitor_speed = 115200
monitor_filters = time
framework = arduino
lib_deps =
https://github.com/DFRobot/DFRobot_MultiGasSensor.git
24 changes: 18 additions & 6 deletions examples/advanced_multivariable/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file main.cpp
* @author Antonio Vanegas @hpsaturn
* @date June 2018 - 2022
* @date June 2018 - 2023
* @brief CanAirIO Sensorslib tests
* @license GPL3
*
Expand All @@ -18,6 +18,8 @@
#include <Arduino.h>
#include <Sensors.hpp>

#define MAIN_HW_EN_PIN 27 // Only for setup with booster board with enable pin

void printSensorsDetected() {
uint16_t sensors_count = sensors.getSensorsRegisteredCount();
uint16_t units_count = sensors.getUnitsRegisteredCount();
Expand Down Expand Up @@ -56,21 +58,31 @@ void onSensorDataError(const char * msg){
* M A I N
******************************************************************************/

void powerEnableSensors() {
// init all sensors (step-up to 5V with enable pin)
Serial.println("-->[POWR] == enable sensors ==");
pinMode(MAIN_HW_EN_PIN, OUTPUT);
digitalWrite(MAIN_HW_EN_PIN, HIGH); // step-up on
}

void setup() {
Serial.begin(115200);
delay(200);
delay(500); // Only for debugging
// powerEnableSensors(); // Only for special setup hardware with enable
delay(100);
Serial.println("\n== Sensor test setup ==\n");
Serial.println("-->[SETUP] Detecting sensors..");

sensors.setSampleTime(10); // config sensors sample time interval
sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback
sensors.setDebugMode(true); // [optional] debug mode
sensors.detectI2COnly(true); // force to only i2c sensors
sensors.setDebugMode(false); // [optional] debug mode
sensors.detectI2COnly(false); // not force to only i2c sensors
sensors.setTemperatureUnit(TEMPUNIT::KELVIN); // comment for Celsius or set Fahrenheit
sensors.init(); // Auto detection to UART and i2c sensors
// sensors.init(SENSORS::Auto, 13, 12); // Auto detection (Custom UART sensor pins example)
sensors.init(); // Auto detection (UART and i2c sensors)
delay(1000);
}

void loop() {
sensors.loop(); // read sensor data and showed it
}
}
9 changes: 5 additions & 4 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CanAirIO Air Quality Sensors Library",
"version": "0.7.2",
"version": "0.7.3",
"homepage":"https://canair.io",
"keywords":
[
Expand Down Expand Up @@ -82,13 +82,14 @@
{"name":"Adafruit BME680 Library","owner":"adafruit","version":"2.0.2"},
{"name":"Adafruit SHT31 Library", "owner":"adafruit","version":"2.2.2"},
{"name":"Adafruit SCD30", "owner":"adafruit","version":"1.0.9"},
{"name":"Adafruit BusIO", "owner":"adafruit","version":"1.14.4"},
{"name":"AM232X", "owner":"robtillaart", "version":"0.4.5"},
{"name":"sps30", "owner":"paulvha","version":"1.4.16"},
{"name":"Adafruit BusIO", "owner":"adafruit","version":"1.14.5"},
{"name":"AM232X", "owner":"robtillaart", "version":"0.5.0"},
{"name":"sps30", "owner":"paulvha","version":"1.4.17"},
{"name":"MH-Z19", "owner":"wifwaf", "version":"1.5.4"},
{"name":"S8_UART", "owner":"jcomas", "version":"1.0.1"},
{"name":"Sensirion Core","owner":"sensirion","version":"0.6.0"},
{"name":"Sensirion I2C SCD4x","owner":"sensirion","version":"0.4.0"},
{"name":"Sensirion I2C SEN5X","owner":"sensirion","version":"0.3.0"},
{"name":"DFRobot_MultiGasSensor","owner":"phzi","version":"2.0.0"},

{"name":"AHTxx", "version":"https://github.com/enjoyneering/AHTxx.git#eb21571"},
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=CanAirIO Air Quality Sensors Library
version=0.7.2
version=0.7.3
author=@hpsaturn, CanAirIO project <[email protected]>
maintainer=Antonio Vanegas <[email protected]>
url=https://github.com/kike-canaries/canairio_sensorlib
Expand Down
Loading

0 comments on commit 02c8d14

Please sign in to comment.