mirror of
https://github.com/thelsing/knx.git
synced 2025-08-13 13:46:20 +02:00
Update knx-bme680.ino
This commit is contained in:
parent
c452512650
commit
4bba027993
@ -42,10 +42,10 @@ bool trigger = false;
|
|||||||
// Entry point for the example
|
// Entry point for the example
|
||||||
void setup(void)
|
void setup(void)
|
||||||
{
|
{
|
||||||
SerialDBG.begin(115200);
|
Serial.begin(115200);
|
||||||
ArduinoPlatform::SerialDebug = Serial;
|
ArduinoPlatform::SerialDebug = Serial;
|
||||||
delay(5000);
|
delay(5000);
|
||||||
SerialDBG.println("start");
|
Serial.println("start");
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP8266
|
#ifdef ARDUINO_ARCH_ESP8266
|
||||||
WiFiManager wifiManager;
|
WiFiManager wifiManager;
|
||||||
@ -92,8 +92,8 @@ void setup(void)
|
|||||||
if (knx.configured())
|
if (knx.configured())
|
||||||
{
|
{
|
||||||
cyclSend = knx.paramInt(0);
|
cyclSend = knx.paramInt(0);
|
||||||
SerialDBG.print("Zykl. send:");
|
Serial.print("Zykl. send:");
|
||||||
SerialDBG.println(cyclSend);
|
Serial.println(cyclSend);
|
||||||
goRawTemperature.dataPointType(Dpt(9, 1));
|
goRawTemperature.dataPointType(Dpt(9, 1));
|
||||||
goPressure.dataPointType(Dpt(9, 1));
|
goPressure.dataPointType(Dpt(9, 1));
|
||||||
goRawHumidity.dataPointType(Dpt(9, 1));
|
goRawHumidity.dataPointType(Dpt(9, 1));
|
||||||
@ -112,7 +112,7 @@ void setup(void)
|
|||||||
iaqSensor.updateSubscription(sensorList, sizeof(sensorList)/sizeof(bsec_virtual_sensor_t), BSEC_SAMPLE_RATE_LP);
|
iaqSensor.updateSubscription(sensorList, sizeof(sensorList)/sizeof(bsec_virtual_sensor_t), BSEC_SAMPLE_RATE_LP);
|
||||||
checkIaqSensorStatus();
|
checkIaqSensorStatus();
|
||||||
String output = "Timestamp [ms], raw temperature [°C], pressure [hPa], raw relative humidity [%], gas [Ohm], IAQ, IAQ accuracy, temperature [°C], relative humidity [%], CO2";
|
String output = "Timestamp [ms], raw temperature [°C], pressure [hPa], raw relative humidity [%], gas [Ohm], IAQ, IAQ accuracy, temperature [°C], relative humidity [%], CO2";
|
||||||
SerialDBG.println(output);
|
Serial.println(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function that is looped forever
|
// Function that is looped forever
|
||||||
@ -150,7 +150,7 @@ void loop(void)
|
|||||||
output += ", " + String(iaqSensor.runInStatus);
|
output += ", " + String(iaqSensor.runInStatus);
|
||||||
output += ", " + String(iaqSensor.stabStatus);
|
output += ", " + String(iaqSensor.stabStatus);
|
||||||
|
|
||||||
SerialDBG.println(output);
|
Serial.println(output);
|
||||||
updateState();
|
updateState();
|
||||||
|
|
||||||
if (sendCounter++ == cyclSend || trigger)
|
if (sendCounter++ == cyclSend || trigger)
|
||||||
@ -180,26 +180,26 @@ void checkIaqSensorStatus(void)
|
|||||||
if (iaqSensor.status != BSEC_OK) {
|
if (iaqSensor.status != BSEC_OK) {
|
||||||
if (iaqSensor.status < BSEC_OK) {
|
if (iaqSensor.status < BSEC_OK) {
|
||||||
String output = "BSEC error code : " + String(iaqSensor.status);
|
String output = "BSEC error code : " + String(iaqSensor.status);
|
||||||
SerialDBG.println(output);
|
Serial.println(output);
|
||||||
for (;;)
|
for (;;)
|
||||||
errLeds(); /* Halt in case of failure */
|
errLeds(); /* Halt in case of failure */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String output = "BSEC warning code : " + String(iaqSensor.status);
|
String output = "BSEC warning code : " + String(iaqSensor.status);
|
||||||
SerialDBG.println(output);
|
Serial.println(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iaqSensor.bme680Status != BME680_OK) {
|
if (iaqSensor.bme680Status != BME680_OK) {
|
||||||
if (iaqSensor.bme680Status < BME680_OK) {
|
if (iaqSensor.bme680Status < BME680_OK) {
|
||||||
String output = "BME680 error code : " + String(iaqSensor.bme680Status);
|
String output = "BME680 error code : " + String(iaqSensor.bme680Status);
|
||||||
SerialDBG.println(output);
|
Serial.println(output);
|
||||||
for (;;)
|
for (;;)
|
||||||
errLeds(); /* Halt in case of failure */
|
errLeds(); /* Halt in case of failure */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String output = "BME680 warning code : " + String(iaqSensor.bme680Status);
|
String output = "BME680 warning code : " + String(iaqSensor.bme680Status);
|
||||||
SerialDBG.println(output);
|
Serial.println(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,10 +216,10 @@ void errLeds(void)
|
|||||||
uint8_t* loadBme680State(uint8_t* buffer)
|
uint8_t* loadBme680State(uint8_t* buffer)
|
||||||
{
|
{
|
||||||
// Existing state in EEPROM
|
// Existing state in EEPROM
|
||||||
SerialDBG.println("Reading state from EEPROM");
|
Serial.println("Reading state from EEPROM");
|
||||||
|
|
||||||
for (uint8_t i = 0; i < BSEC_MAX_STATE_BLOB_SIZE; i++) {
|
for (uint8_t i = 0; i < BSEC_MAX_STATE_BLOB_SIZE; i++) {
|
||||||
SerialDBG.println(buffer[i], HEX);
|
Serial.println(buffer[i], HEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
iaqSensor.setState(buffer);
|
iaqSensor.setState(buffer);
|
||||||
@ -232,10 +232,10 @@ uint8_t* saveBme680State(uint8_t* buffer)
|
|||||||
iaqSensor.getState(buffer);
|
iaqSensor.getState(buffer);
|
||||||
checkIaqSensorStatus();
|
checkIaqSensorStatus();
|
||||||
|
|
||||||
SerialDBG.println("Writing state to EEPROM");
|
Serial.println("Writing state to EEPROM");
|
||||||
|
|
||||||
for (uint8_t i = 0; i < BSEC_MAX_STATE_BLOB_SIZE; i++) {
|
for (uint8_t i = 0; i < BSEC_MAX_STATE_BLOB_SIZE; i++) {
|
||||||
SerialDBG.println(buffer[i], HEX);
|
Serial.println(buffer[i], HEX);
|
||||||
}
|
}
|
||||||
return buffer + BSEC_MAX_STATE_BLOB_SIZE;
|
return buffer + BSEC_MAX_STATE_BLOB_SIZE;
|
||||||
}
|
}
|
||||||
@ -266,8 +266,8 @@ void updateState(void)
|
|||||||
// callback from trigger-GO
|
// callback from trigger-GO
|
||||||
void triggerCallback(GroupObject& go)
|
void triggerCallback(GroupObject& go)
|
||||||
{
|
{
|
||||||
SerialDBG.println("trigger");
|
Serial.println("trigger");
|
||||||
SerialDBG.println((bool)go.value());
|
Serial.println((bool)go.value());
|
||||||
if (!go.value())
|
if (!go.value())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ void triggerCallback(GroupObject& go)
|
|||||||
/* We call bsec_update_subscription() in order to instruct BSEC to perform an extra measurement at the next
|
/* We call bsec_update_subscription() in order to instruct BSEC to perform an extra measurement at the next
|
||||||
possible time slot
|
possible time slot
|
||||||
*/
|
*/
|
||||||
SerialDBG.println("Triggering ULP plus.");
|
Serial.println("Triggering ULP plus.");
|
||||||
bsec_virtual_sensor_t sensorList[] = {
|
bsec_virtual_sensor_t sensorList[] = {
|
||||||
BSEC_OUTPUT_IAQ, BSEC_OUTPUT_CO2_EQUIVALENT
|
BSEC_OUTPUT_IAQ, BSEC_OUTPUT_CO2_EQUIVALENT
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user