Skip to content

Commit

Permalink
fixed Adafruit SCD30 migration issue (cache project issues)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpsaturn committed Jun 1, 2022
1 parent 1672aac commit 90ae1f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/Sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void Sensors::setSampleTime(int seconds) {
void Sensors::setCO2RecalibrationFactor(int ppmValue) {
if (isSensorRegistered(SENSORS::SSCD30)) {
Serial.println("-->[SLIB] SCD30 calibration to\t: " + String(ppmValue));
scd30.setForcedRecalibrationFactor(ppmValue);
scd30.forceRecalibrationWithReference(ppmValue);
}
if (isSensorRegistered(SENSORS::SCM1106)) {
Serial.println("-->[SLIB] CM1106 calibration to\t: " + String(ppmValue));
Expand Down Expand Up @@ -933,12 +933,12 @@ void Sensors::sht31Read() {
}

void Sensors::CO2scd30Read() {
if (!scd30.isConnected()) return;
uint16_t tCO2 = scd30.getCO2(); // we need temp var, without it override CO2
if (!scd30.dataReady() || !scd30.read()) return;
uint16_t tCO2 = scd30.CO2; // we need temp var, without it override CO2
if (tCO2 > 0) {
CO2Val = tCO2;
CO2humi = scd30.getHumidity();
CO2temp = scd30.getTemperature();
CO2humi = scd30.relative_humidity;
CO2temp = scd30.temperature;
dataReady = true;
DEBUG("-->[SLIB] SCD30 read\t\t: done!");
unitRegister(UNIT::CO2);
Expand Down Expand Up @@ -1424,16 +1424,16 @@ void Sensors::aht10Init() {
void Sensors::CO2scd30Init() {
sensorAnnounce(SENSORS::SSCD30);
#ifdef ESP32
if (!scd30.begin() && !scd30.begin(Wire1,false,true)) return;
if (!scd30.begin() && !scd30.begin(SCD30_I2CADDR_DEFAULT, &Wire1, SCD30_CHIP_ID)) return;
#else
if (!scd30.begin()) return;
#endif
delay(10);

DEBUG("-->[SLIB] SCD30 Temp offset\t:",String(scd30.getTemperatureOffset()).c_str());
DEBUG("-->[SLIB] SCD30 Altitude offset\t:", String(scd30.getAltitudeCompensation()).c_str());
DEBUG("-->[SLIB] SCD30 Altitude offset\t:", String(scd30.getAltitudeOffset()).c_str());

if(scd30.getAltitudeCompensation() != uint16_t(altoffset)){
if(scd30.getAltitudeOffset() != uint16_t(altoffset)){
DEBUG("-->[SLIB] SCD30 altitude offset to\t:", String(altoffset).c_str());
setSCD30AltitudeOffset(altoffset);
delay(10);
Expand All @@ -1458,7 +1458,7 @@ void Sensors::setSCD30TempOffset(float offset) {
void Sensors::setSCD30AltitudeOffset(float offset) {
if (isSensorRegistered(SENSORS::SSCD30)) {
Serial.println("-->[SLIB] SCD30 new altitude offset\t: " + String(offset));
scd30.setAltitudeCompensation(uint16_t(offset));
scd30.setAltitudeOffset(uint16_t(offset));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Sensors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include <Adafruit_BME680.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_SHT31.h>
#include <Adafruit_SCD30.h>
#include <Adafruit_Sensor.h>
#include <MHZ19.h>
#include <SensirionI2CScd4x.h>
#include <SparkFun_Particle_Sensor_SN-GCJA5_Arduino_Library.h>
#include <SparkFun_SCD30_Arduino_Library.h>
#include <cm1106_uart.h>
#include <dht_nonblocking.h>
#include <s8_uart.h>
Expand Down Expand Up @@ -186,7 +186,7 @@ class Sensors {
// Mhz19 sensor
MHZ19 mhz19;
// SCD30 sensor
SCD30 scd30;
Adafruit_SCD30 scd30;
// CM1106 UART
CM1106_UART *cm1106;

Expand Down

0 comments on commit 90ae1f4

Please sign in to comment.