Compare commits

..

No commits in common. "c8d0d308140052e9a89cc23e15f6969d28db337a" and "875a7c010173dea13a9b19fcd5342d1055560b5a" have entirely different histories.

4 changed files with 1 additions and 324 deletions

View File

@ -1,180 +0,0 @@
//Connect SCL to D1, SDA to D2, GND and 3v3
#include "sensor_multichannelgasgmxxx.h"
Sensor_MULTICHANNELGASGMXXX::Sensor_MULTICHANNELGASGMXXX()
{
gas = new GAS_GMXXX<TwoWire>();
}
void Sensor_MULTICHANNELGASGMXXX::init() //Things to be done during setup()
{
Serial.println("initializing MULTICHANNELGASGMXXX");
//The default addrss is 0x08;
//gas.begin(MyWire, 0x08); // use the software I2C
//gas.setAddress(0x64); change thee I2C address
gas->begin(Wire, 0x08);
init_ok=true;
}
//Also called during setup()
void Sensor_MULTICHANNELGASGMXXX::setSettings_no2(float minchange, unsigned long senddelaymax, unsigned long readdelay)
{
data_no2.minchange=minchange;
data_no2.senddelaymax=senddelaymax;
data_no2.readdelay=readdelay;
}
void Sensor_MULTICHANNELGASGMXXX::setSettings_c2h5oh(float minchange, unsigned long senddelaymax, unsigned long readdelay)
{
data_c2h5oh.minchange=minchange;
data_c2h5oh.senddelaymax=senddelaymax;
data_c2h5oh.readdelay=readdelay;
}
void Sensor_MULTICHANNELGASGMXXX::setSettings_voc(float minchange, unsigned long senddelaymax, unsigned long readdelay)
{
data_voc.minchange=minchange;
data_voc.senddelaymax=senddelaymax;
data_voc.readdelay=readdelay;
}
void Sensor_MULTICHANNELGASGMXXX::setSettings_co(float minchange, unsigned long senddelaymax, unsigned long readdelay)
{
data_co.minchange=minchange;
data_co.senddelaymax=senddelaymax;
data_co.readdelay=readdelay;
}
//Called during setup
void Sensor_MULTICHANNELGASGMXXX::advertise(HomieNode& p_sensorNode)
{
sensorNode = &p_sensorNode;
sensorNode->advertise("no2");
sensorNode->advertise("c2h5oh");
sensorNode->advertise("voc");
sensorNode->advertise("co");
}
void Sensor_MULTICHANNELGASGMXXX::sensorloop_no2()
{
if (init_ok) {
sensordata &d=data_no2;
bool _changed=false;
if (millis() >= (d.lastreadtime+d.readdelay)) {
d.value = gas->calcVol(gas->measure_NO2()); // Volt
if (fabs(d.lastsentvalue-d.value)>=d.minchange){
_changed=true;
}
d.lastreadtime=millis();
}
if (_changed || millis() >= (d.lastsent+d.senddelaymax)) {
Serial.print("Sending MULTICHANNELGASGMXXX no2. reason=");
if (_changed) Serial.println("change"); else Serial.println("time");
Homie.getLogger() << "no2 " << ": " << d.value << endl;
sensorNode->setProperty("no2").send(String(d.value));
d.lastsentvalue=d.value;
d.lastsent=millis();
}
}
}
void Sensor_MULTICHANNELGASGMXXX::sensorloop_c2h5oh()
{
if (init_ok) {
sensordata &d=data_c2h5oh;
bool _changed=false;
if (millis() >= (d.lastreadtime+d.readdelay)) {
d.value = gas->calcVol(gas->measure_C2H5OH()); // Volt
if (fabs(d.lastsentvalue-d.value)>=d.minchange){
_changed=true;
}
d.lastreadtime=millis();
}
if (_changed || millis() >= (d.lastsent+d.senddelaymax)) {
Serial.print("Sending MULTICHANNELGASGMXXX c2h5oh. reason=");
if (_changed) Serial.println("change"); else Serial.println("time");
Homie.getLogger() << "c2h5oh " << ": " << d.value << endl;
sensorNode->setProperty("c2h5oh").send(String(d.value));
d.lastsentvalue=d.value;
d.lastsent=millis();
}
}
}
void Sensor_MULTICHANNELGASGMXXX::sensorloop_voc()
{
if (init_ok) {
sensordata &d=data_voc;
bool _changed=false;
if (millis() >= (d.lastreadtime+d.readdelay)) {
d.value = gas->calcVol(gas->measure_VOC()); // Volt
if (fabs(d.lastsentvalue-d.value)>=d.minchange){
_changed=true;
}
d.lastreadtime=millis();
}
if (_changed || millis() >= (d.lastsent+d.senddelaymax)) {
Serial.print("Sending MULTICHANNELGASGMXXX voc. reason=");
if (_changed) Serial.println("change"); else Serial.println("time");
Homie.getLogger() << "voc " << ": " << d.value << endl;
sensorNode->setProperty("voc").send(String(d.value));
d.lastsentvalue=d.value;
d.lastsent=millis();
}
}
}
void Sensor_MULTICHANNELGASGMXXX::sensorloop_co()
{
if (init_ok) {
sensordata &d=data_co;
bool _changed=false;
if (millis() >= (d.lastreadtime+d.readdelay)) {
d.value = gas->calcVol(gas->measure_CO()); // Volt
if (fabs(d.lastsentvalue-d.value)>=d.minchange){
_changed=true;
}
d.lastreadtime=millis();
}
if (_changed || millis() >= (d.lastsent+d.senddelaymax)) {
Serial.print("Sending MULTICHANNELGASGMXXX co. reason=");
if (_changed) Serial.println("change"); else Serial.println("time");
Homie.getLogger() << "co " << ": " << d.value << endl;
sensorNode->setProperty("co").send(String(d.value));
d.lastsentvalue=d.value;
d.lastsent=millis();
}
}
}
/*
val = gas.measure_NO2(); Serial.print("NO2: "); Serial.print(val); Serial.print(" eq ");
Serial.print(gas.calcVol(val)); Serial.println("V");
val = gas.measure_C2H5OH(); Serial.print("C2H5OH: "); Serial.print(val); Serial.print(" eq ");
Serial.print(gas.calcVol(val)); Serial.println("V");
val = gas.measure_VOC(); Serial.print("VOC: "); Serial.print(val); Serial.print(" eq ");
Serial.print(gas.calcVol(val)); Serial.println("V");
val = gas.measure_CO(); Serial.print("CO: "); Serial.print(val); Serial.print(" eq ");
Serial.print(gas.calcVol(val)); Serial.println("V");
*/

View File

@ -1,43 +0,0 @@
#ifndef SENSOR_MULTICHANNELGASGMXXX_H
#define SENSOR_MULTICHANNELGASGMXXX_H
#include "sensordata.h"
#include <Homie.h>
#include <Multichannel_Gas_GMXXX.h>
#include <Wire.h>
class Sensor_MULTICHANNELGASGMXXX
{
private:
GAS_GMXXX<TwoWire> *gas;
HomieNode *sensorNode; //reference to HomieNode
struct sensordata data_no2; //struct values are changed in setup()
struct sensordata data_c2h5oh;
struct sensordata data_voc;
struct sensordata data_co;
bool init_ok;
public:
Sensor_MULTICHANNELGASGMXXX();
void init();
void setSettings_no2(float minchange, unsigned long senddelaymax, unsigned long readdelay);
void setSettings_c2h5oh(float minchange, unsigned long senddelaymax, unsigned long readdelay);
void setSettings_voc(float minchange, unsigned long senddelaymax, unsigned long readdelay);
void setSettings_co(float minchange, unsigned long senddelaymax, unsigned long readdelay);
void advertise(HomieNode& p_sensorNode);
void sensorloop_no2();
void sensorloop_c2h5oh();
void sensorloop_voc();
void sensorloop_co();
};
#endif

View File

@ -18,9 +18,8 @@
#data_dir=data_sensoresp3 #data_dir=data_sensoresp3
#data_dir=data_sensoresp4 #data_dir=data_sensoresp4
#data_dir=data_sensoresp5 #data_dir=data_sensoresp5
data_dir=data_sensoresp6
#data_dir=data_sensoresp3dprinter #data_dir=data_sensoresp3dprinter
#data_dir=data_sensoresptest data_dir=data_sensoresptest
#Outdoor #Outdoor
@ -274,37 +273,6 @@ lib_deps =
pololu/VL53L1X @ ^1.3.0 pololu/VL53L1X @ ^1.3.0
#Flur Gas, motion
[env:sensoresp6]
platform = espressif8266 @ 2.5.0
board = d1_mini
framework = arduino
monitor_port = /dev/ttyUSB0
monitor_speed = 115200
build_flags =
-D SENSOR_MULTICHANNELGASGMXXX
-D SENSOR_MULTICHANNELGASGMXXX_no2_minchange=0.1
-D SENSOR_MULTICHANNELGASGMXXX_c2h5oh_minchange=0.1
-D SENSOR_MULTICHANNELGASGMXXX_voc_minchange=0.1
-D SENSOR_MULTICHANNELGASGMXXX_co_minchange=0.1
-D SENSOR_MULTICHANNELGASGMXXX_no2_senddelaymax=600000
-D SENSOR_MULTICHANNELGASGMXXX_c2h5oh_senddelaymax=600000
-D SENSOR_MULTICHANNELGASGMXXX_voc_senddelaymax=600000
-D SENSOR_MULTICHANNELGASGMXXX_co_senddelaymax=600000
-D SENSOR_HTU21D
-D dataHTU21D_temperature_minchange=0.2
-D dataHTU21D_temperature_senddelaymax=1000*60*60
-D dataHTU21D_humidity_minchange=1.0
-D dataHTU21D_humidity_senddelaymax=1000*60*60
lib_deps =
https://github.com/Seeed-Studio/Seeed_Arduino_MultiGas
adafruit/Adafruit HTU21DF Library @ ^1.0.5
ArduinoJson@6.16.1 #dependency of homie. using older version because of "ambiguous overload for operator|" error
Homie@3.0.0
#3D Printer #3D Printer
[env:sensoresp3dprinter] [env:sensoresp3dprinter]

View File

@ -345,55 +345,6 @@ HomieNode sensorNode("sensors", "Sensors","sensors"); //id, name, type
#endif #endif
#ifdef SENSOR_MULTICHANNELGASGMXXX
#include "sensor_multichannelgasgmxxx.cpp"
Sensor_MULTICHANNELGASGMXXX sensor_multichannelgasgmxxx;
#ifndef SENSOR_MULTICHANNELGASGMXXX_no2_minchange
#define SENSOR_MULTICHANNELGASGMXXX_no2_minchange 0.1
#endif
#ifndef SENSOR_MULTICHANNELGASGMXXX_no2_senddelaymax
#define SENSOR_MULTICHANNELGASGMXXX_no2_senddelaymax 600000
#endif
#ifndef SENSOR_MULTICHANNELGASGMXXX_no2_readdelay
#define SENSOR_MULTICHANNELGASGMXXX_no2_readdelay 10000
#endif
#ifndef SENSOR_MULTICHANNELGASGMXXX_c2h5oh_minchange
#define SENSOR_MULTICHANNELGASGMXXX_c2h5oh_minchange 0.1
#endif
#ifndef SENSOR_MULTICHANNELGASGMXXX_c2h5oh_senddelaymax
#define SENSOR_MULTICHANNELGASGMXXX_c2h5oh_senddelaymax 600000
#endif
#ifndef SENSOR_MULTICHANNELGASGMXXX_c2h5oh_readdelay
#define SENSOR_MULTICHANNELGASGMXXX_c2h5oh_readdelay 10000
#endif
#ifndef SENSOR_MULTICHANNELGASGMXXX_voc_minchange
#define SENSOR_MULTICHANNELGASGMXXX_voc_minchange 0.1
#endif
#ifndef SENSOR_MULTICHANNELGASGMXXX_voc_senddelaymax
#define SENSOR_MULTICHANNELGASGMXXX_voc_senddelaymax 600000
#endif
#ifndef SENSOR_MULTICHANNELGASGMXXX_voc_readdelay
#define SENSOR_MULTICHANNELGASGMXXX_voc_readdelay 10000
#endif
#ifndef SENSOR_MULTICHANNELGASGMXXX_co_minchange
#define SENSOR_MULTICHANNELGASGMXXX_co_minchange 0.1
#endif
#ifndef SENSOR_MULTICHANNELGASGMXXX_co_senddelaymax
#define SENSOR_MULTICHANNELGASGMXXX_co_senddelaymax 600000
#endif
#ifndef SENSOR_MULTICHANNELGASGMXXX_co_readdelay
#define SENSOR_MULTICHANNELGASGMXXX_co_readdelay 10000
#endif
#endif
char tempstring[16]; //for dtostrf char tempstring[16]; //for dtostrf
@ -494,14 +445,6 @@ void setup() {
sensor_raingauge.setSettings(SENSOR_Raingauge_minchange,SENSOR_Raingauge_senddelaymax,SENSOR_Raingauge_readdelay); sensor_raingauge.setSettings(SENSOR_Raingauge_minchange,SENSOR_Raingauge_senddelaymax,SENSOR_Raingauge_readdelay);
#endif #endif
#ifdef SENSOR_MULTICHANNELGASGMXXX
sensor_multichannelgasgmxxx.init();
sensor_multichannelgasgmxxx.setSettings_no2(SENSOR_MULTICHANNELGASGMXXX_no2_minchange,SENSOR_MULTICHANNELGASGMXXX_no2_senddelaymax,SENSOR_MULTICHANNELGASGMXXX_no2_readdelay);
sensor_multichannelgasgmxxx.setSettings_c2h5oh(SENSOR_MULTICHANNELGASGMXXX_c2h5oh_minchange,SENSOR_MULTICHANNELGASGMXXX_c2h5oh_senddelaymax,SENSOR_MULTICHANNELGASGMXXX_c2h5oh_readdelay);
sensor_multichannelgasgmxxx.setSettings_voc(SENSOR_MULTICHANNELGASGMXXX_voc_minchange,SENSOR_MULTICHANNELGASGMXXX_voc_senddelaymax,SENSOR_MULTICHANNELGASGMXXX_voc_readdelay);
sensor_multichannelgasgmxxx.setSettings_co(SENSOR_MULTICHANNELGASGMXXX_co_minchange,SENSOR_MULTICHANNELGASGMXXX_co_senddelaymax,SENSOR_MULTICHANNELGASGMXXX_co_readdelay);
#endif
// ##### Advertise topics below here ##### // ##### Advertise topics below here #####
@ -577,10 +520,6 @@ void setup() {
sensor_raingauge.advertise(sensorNode); sensor_raingauge.advertise(sensorNode);
#endif #endif
#ifdef SENSOR_MULTICHANNELGASGMXXX
sensor_multichannelgasgmxxx.advertise(sensorNode);
#endif
Serial.println("connecting.."); Serial.println("connecting..");
Homie.setup(); Homie.setup();
@ -657,13 +596,6 @@ void loopHandler() {
sensor_raingauge.sensorloop(); sensor_raingauge.sensorloop();
#endif #endif
#ifdef SENSOR_MULTICHANNELGASGMXXX
sensor_multichannelgasgmxxx.sensorloop_no2();
sensor_multichannelgasgmxxx.sensorloop_c2h5oh();
sensor_multichannelgasgmxxx.sensorloop_voc();
sensor_multichannelgasgmxxx.sensorloop_co();
#endif
} }