scd4x #1

Merged
mathieu merged 5 commits from scd4x into master 2023-11-28 23:12:29 +01:00
4 changed files with 17 additions and 2 deletions
Showing only changes of commit 346d7927d8 - Show all commits

View File

@ -21,6 +21,9 @@
#define TELEINFO_IINST_FEED_FORMAT "/feeds/%s/%s/teleinfo/iinst" #define TELEINFO_IINST_FEED_FORMAT "/feeds/%s/%s/teleinfo/iinst"
#define TELEINFO_PAPP_FEED_FORMAT "/feeds/%s/%s/teleinfo/papp" #define TELEINFO_PAPP_FEED_FORMAT "/feeds/%s/%s/teleinfo/papp"
#define TELEINFO_BASE_FEED_FORMAT "/feeds/%s/%s/teleinfo/base" #define TELEINFO_BASE_FEED_FORMAT "/feeds/%s/%s/teleinfo/base"
#define SCD4X_TEMPERATURE_FEED_FORMAT "/feeds/%s/%s/scd4x/temperature"
#define SCD4X_HUMIDITY_FEED_FORMAT "/feeds/%s/%s/scd4x/humidity"
#define SCD4X_CO2_FEED_FORMAT "/feeds/%s/%s/scd4x/co2"
#ifndef CONFIG_DISABLE_MQTT #ifndef CONFIG_DISABLE_MQTT
#include "Adafruit_MQTT.h" #include "Adafruit_MQTT.h"

View File

@ -48,7 +48,7 @@ int SCD4XGetMeasure(float &temperature, float &humidity, uint16_t &co2)
char errorMsg[256]; char errorMsg[256];
SKETCH_DEBUG_PRINT("Error with reading measurement. Error : "); SKETCH_DEBUG_PRINT("Error with reading measurement. Error : ");
errorToString(error, errorMsg, sizeof(errorMsg)); errorToString(error, errorMsg, sizeof(errorMsg));
SKETCH_DEBUG_PRINTLN(" Co2: %d", co2); SKETCH_DEBUG_PRINTF(" Co2: %d\n", co2);
return -1; return -1;
} }

View File

@ -53,6 +53,7 @@
#include "Adafruit_MQTT_Client.h" #include "Adafruit_MQTT_Client.h"
#include "EEPROM.h" #include "EEPROM.h"
#include "Teleinfo.h" #include "Teleinfo.h"
#include "SCD4X.h"
extern "C" { extern "C" {
#include <user_interface.h> #include <user_interface.h>
@ -68,6 +69,8 @@ float dhtTemp, dhtHumidity;
float bme680T, bme680P, bme680H, bme680G, bme680A; float bme680T, bme680P, bme680H, bme680G, bme680A;
float bme680BSECT, bme680BSECP, bme680BSECH, bme680BSECIaq, bme680BSECIaqAcc; float bme680BSECT, bme680BSECP, bme680BSECH, bme680BSECIaq, bme680BSECIaqAcc;
float teleIinst, telePapp, teleBase; float teleIinst, telePapp, teleBase;
float SCD4xT, SCD4xH;
uint16_t SCD4xCo2;
int dryness; int dryness;
uint8_t mode; uint8_t mode;
int reconfig = 0; int reconfig = 0;
@ -296,6 +299,9 @@ void setup()
if(!TeleinfoSetup()){ if(!TeleinfoSetup()){
SKETCH_DEBUG_PRINTLN("Teleinfo init success"); SKETCH_DEBUG_PRINTLN("Teleinfo init success");
} }
if(!SCD4XSetup()){
SKETCH_DEBUG_PRINTLN("SCD4X init success");
}
WebSetupServer(mode); WebSetupServer(mode);
} }
samplingPeriod = conf.samplingPeriod; samplingPeriod = conf.samplingPeriod;
@ -334,6 +340,12 @@ void loop() {
batchInfo.push_back({dhtTemp, TEMPERATURE_DHT_FEED_FORMAT, 0, 0}); batchInfo.push_back({dhtTemp, TEMPERATURE_DHT_FEED_FORMAT, 0, 0});
batchInfo.push_back({dhtHumidity, HUMIDITY_DHT_FEED_FORMAT, 0, 0}); batchInfo.push_back({dhtHumidity, HUMIDITY_DHT_FEED_FORMAT, 0, 0});
} }
if (!SCD4XGetMeasure(SCD4xT, SCD4xH, SCD4xCo2)) {
SKETCH_DEBUG_PRINTF("Current %f°C %f Humidity, Current C02 %d\n", SCD4xT, SCD4xH, SCD4xCo2);
batchInfo.push_back({SCD4xT, SCD4X_TEMPERATURE_FEED_FORMAT, 0, 0});
batchInfo.push_back({SCD4xH, SCD4X_HUMIDITY_FEED_FORMAT, 0, 0});
batchInfo.push_back({(float)SCD4xCo2, SCD4X_CO2_FEED_FORMAT, 0, 0});
}
if (!DryGetMeasure(dryness)) { if (!DryGetMeasure(dryness)) {
SKETCH_DEBUG_PRINTF("Current dryness %d %%\n", (dryness * 100) / 1024); SKETCH_DEBUG_PRINTF("Current dryness %d %%\n", (dryness * 100) / 1024);
batchInfo.push_back({(float)dryness, DRY_FEED_FORMAT, 0, 0}); batchInfo.push_back({(float)dryness, DRY_FEED_FORMAT, 0, 0});

View File

@ -35,7 +35,7 @@
//#define CONFIG_ENABLE_DRY_SENSOR //#define CONFIG_ENABLE_DRY_SENSOR
//If the dry sensor is powered by a GPIO, this GPIO could be defined here //If the dry sensor is powered by a GPIO, this GPIO could be defined here
//#define CONFIG_DRY_POWER_PIN 13 //#define CONFIG_DRY_POWER_PIN 13
#define CONFIG_ENABLE_SCD4X
// Enable light sleep to save some power (http://bbs.espressif.com/viewtopic.php?f=6&t=133&p=485&hilit=sleep+modem#p485) // Enable light sleep to save some power (http://bbs.espressif.com/viewtopic.php?f=6&t=133&p=485&hilit=sleep+modem#p485)
#define CONFIG_ENABLE_POWER_SAVE #define CONFIG_ENABLE_POWER_SAVE