Compare commits
5 Commits
14b599c4da
...
295ee2d87d
| Author | SHA1 | Date | |
|---|---|---|---|
| 295ee2d87d | |||
| 2873d56b58 | |||
| 3d740c9387 | |||
| dd511c8e18 | |||
| 11b146c2d1 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1 +1,6 @@
|
|||||||
.pio/
|
.pio/
|
||||||
|
.vscode/
|
||||||
|
*/.DS_store
|
||||||
|
.DS_Store
|
||||||
|
.vscode/c_cpp_properties.json
|
||||||
|
.vscode/launch.json
|
||||||
|
|||||||
40
.vscode/c_cpp_properties.json
vendored
40
.vscode/c_cpp_properties.json
vendored
@@ -10,10 +10,15 @@
|
|||||||
"includePath": [
|
"includePath": [
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/include",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/include",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SGP30 Sensor",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/lib/JC_Button/src",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SCD30",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/ArduinoOTA/src",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit BusIO",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/ESPmDNS/src",
|
||||||
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Update/src",
|
||||||
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/lib/IP5306",
|
||||||
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/SparkFun SGP30 Arduino Library/src",
|
||||||
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/SparkFun SCD30 Arduino Library/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src",
|
||||||
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/JC_Button/src",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/TJpg_Decoder/src",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/TJpg_Decoder/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SD/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SD/src",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/RunningMedian",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/RunningMedian",
|
||||||
@@ -87,8 +92,10 @@
|
|||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fb_gfx",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fb_gfx",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/cores/esp32",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/cores/esp32",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/variants/esp32",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/variants/esp32",
|
||||||
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit BusIO",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit GFX Library",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit GFX Library",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/ArduinoOTA/src",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SCD30",
|
||||||
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SGP30 Sensor",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/AsyncUDP/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/AsyncUDP/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/AzureIoT/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/AzureIoT/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/BLE/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/BLE/src",
|
||||||
@@ -96,7 +103,6 @@
|
|||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/DNSServer/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/DNSServer/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/EEPROM/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/EEPROM/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/ESP32/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/ESP32/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/ESPmDNS/src",
|
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/FFat/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/FFat/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdate/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdate/src",
|
||||||
@@ -106,11 +112,9 @@
|
|||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SD_MMC/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SD_MMC/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SimpleBLE/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SimpleBLE/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Ticker/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Ticker/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Update/src",
|
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WiFiProv/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WiFiProv/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/tool-unity",
|
|
||||||
""
|
""
|
||||||
],
|
],
|
||||||
"browse": {
|
"browse": {
|
||||||
@@ -118,10 +122,15 @@
|
|||||||
"path": [
|
"path": [
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/include",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/include",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SGP30 Sensor",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/lib/JC_Button/src",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SCD30",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/ArduinoOTA/src",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit BusIO",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/ESPmDNS/src",
|
||||||
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Update/src",
|
||||||
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/lib/IP5306",
|
||||||
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/SparkFun SGP30 Arduino Library/src",
|
||||||
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/SparkFun SCD30 Arduino Library/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src",
|
||||||
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/JC_Button/src",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/TJpg_Decoder/src",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/TJpg_Decoder/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SD/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SD/src",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/RunningMedian",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/RunningMedian",
|
||||||
@@ -195,8 +204,10 @@
|
|||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fb_gfx",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fb_gfx",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/cores/esp32",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/cores/esp32",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/variants/esp32",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/variants/esp32",
|
||||||
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit BusIO",
|
||||||
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit GFX Library",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit GFX Library",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/ArduinoOTA/src",
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SCD30",
|
||||||
|
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SGP30 Sensor",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/AsyncUDP/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/AsyncUDP/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/AzureIoT/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/AzureIoT/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/BLE/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/BLE/src",
|
||||||
@@ -204,7 +215,6 @@
|
|||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/DNSServer/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/DNSServer/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/EEPROM/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/EEPROM/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/ESP32/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/ESP32/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/ESPmDNS/src",
|
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/FFat/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/FFat/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdate/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdate/src",
|
||||||
@@ -214,16 +224,14 @@
|
|||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SD_MMC/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SD_MMC/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SimpleBLE/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SimpleBLE/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Ticker/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Ticker/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Update/src",
|
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WiFiProv/src",
|
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WiFiProv/src",
|
||||||
"/Users/willemoldemans/.platformio/packages/tool-unity",
|
|
||||||
""
|
""
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"defines": [
|
"defines": [
|
||||||
"PLATFORMIO=50101",
|
"PLATFORMIO=60001",
|
||||||
"ARDUINO_ESP32_DEV",
|
"ARDUINO_ESP32_DEV",
|
||||||
"ESP32",
|
"ESP32",
|
||||||
"ESP_PLATFORM",
|
"ESP_PLATFORM",
|
||||||
@@ -238,7 +246,7 @@
|
|||||||
],
|
],
|
||||||
"cStandard": "c99",
|
"cStandard": "c99",
|
||||||
"cppStandard": "c++11",
|
"cppStandard": "c++11",
|
||||||
"compilerPath": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gcc",
|
"compilerPath": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32@2.50200.97/bin/xtensa-esp32-elf-gcc",
|
||||||
"compilerArgs": [
|
"compilerArgs": [
|
||||||
"-mlongcalls",
|
"-mlongcalls",
|
||||||
""
|
""
|
||||||
|
|||||||
17
.vscode/extensions.json
vendored
17
.vscode/extensions.json
vendored
@@ -1,7 +1,10 @@
|
|||||||
{
|
{
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
// for the documentation about the extensions.json format
|
// for the documentation about the extensions.json format
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"platformio.platformio-ide"
|
"platformio.platformio-ide"
|
||||||
]
|
],
|
||||||
}
|
"unwantedRecommendations": [
|
||||||
|
"ms-vscode.cpptools-extension-pack"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
14
.vscode/launch.json
vendored
14
.vscode/launch.json
vendored
@@ -14,7 +14,7 @@
|
|||||||
"name": "PIO Debug",
|
"name": "PIO Debug",
|
||||||
"executable": "/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/build/esp32/firmware.elf",
|
"executable": "/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/build/esp32/firmware.elf",
|
||||||
"projectEnvName": "esp32",
|
"projectEnvName": "esp32",
|
||||||
"toolchainBinDir": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32/bin",
|
"toolchainBinDir": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32@2.50200.97/bin",
|
||||||
"internalConsoleOptions": "openOnSessionStart",
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
"preLaunchTask": {
|
"preLaunchTask": {
|
||||||
"type": "PlatformIO",
|
"type": "PlatformIO",
|
||||||
@@ -27,8 +27,18 @@
|
|||||||
"name": "PIO Debug (skip Pre-Debug)",
|
"name": "PIO Debug (skip Pre-Debug)",
|
||||||
"executable": "/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/build/esp32/firmware.elf",
|
"executable": "/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/build/esp32/firmware.elf",
|
||||||
"projectEnvName": "esp32",
|
"projectEnvName": "esp32",
|
||||||
"toolchainBinDir": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32/bin",
|
"toolchainBinDir": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32@2.50200.97/bin",
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "platformio-debug",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "PIO Debug (without uploading)",
|
||||||
|
"executable": "/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/build/esp32/firmware.elf",
|
||||||
|
"projectEnvName": "esp32",
|
||||||
|
"toolchainBinDir": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32@2.50200.97/bin",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
|
"loadMode": "manual"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "CO2_sensor.h"
|
#include "CO2_sensor.h"
|
||||||
|
|
||||||
Adafruit_SCD30 scd30;
|
//Adafruit_SCD30 scd30;
|
||||||
|
SCD30 scd30;
|
||||||
|
|
||||||
#define CO2_INTERVAL 120000 //ms
|
#define CO2_INTERVAL 120000 //ms
|
||||||
#define SCD30TEMPMAX 50
|
#define SCD30TEMPMAX 50
|
||||||
@@ -8,7 +9,7 @@ Adafruit_SCD30 scd30;
|
|||||||
#define SCD30CO2MAX 20000
|
#define SCD30CO2MAX 20000
|
||||||
#define SCD30MIN 0
|
#define SCD30MIN 0
|
||||||
|
|
||||||
uint8_t CO2_samples = 3600 / g_pms_report_period;
|
uint8_t CO2_samples = 3600 / 30;
|
||||||
|
|
||||||
AQSSensor SCD30_temperature("Temperature", SCD30_temp, "degC", device_name, CO2_samples, SCD30MIN, SCD30TEMPMAX);
|
AQSSensor SCD30_temperature("Temperature", SCD30_temp, "degC", device_name, CO2_samples, SCD30MIN, SCD30TEMPMAX);
|
||||||
AQSSensor SCD30_Humidity("Humidity", SCD30_hum, "%RH", device_name, CO2_samples, SCD30MIN, SDC30HUMMAX);
|
AQSSensor SCD30_Humidity("Humidity", SCD30_hum, "%RH", device_name, CO2_samples, SCD30MIN, SDC30HUMMAX);
|
||||||
@@ -19,6 +20,7 @@ uint32_t CO2_lastUpdate = 0;
|
|||||||
void initCO2sensor(void)
|
void initCO2sensor(void)
|
||||||
{
|
{
|
||||||
Serial.println("SCD30: init");
|
Serial.println("SCD30: init");
|
||||||
|
Wire.begin();
|
||||||
if (!scd30.begin())
|
if (!scd30.begin())
|
||||||
{
|
{
|
||||||
Serial.println("SCD30: Failed to find sensor");
|
Serial.println("SCD30: Failed to find sensor");
|
||||||
@@ -33,8 +35,8 @@ void initCO2sensor(void)
|
|||||||
addSensorToList(&SCD30_CO2);
|
addSensorToList(&SCD30_CO2);
|
||||||
|
|
||||||
//check callibration Mode
|
//check callibration Mode
|
||||||
scd30.selfCalibrationEnabled(false);
|
//scd30.selfCalibrationEnabled(false);
|
||||||
scd30.read();
|
//scd30.read();
|
||||||
Serial.println("SCD30: init OK");
|
Serial.println("SCD30: init OK");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,22 +44,21 @@ void initCO2sensor(void)
|
|||||||
void handleCO2sensor(void)
|
void handleCO2sensor(void)
|
||||||
{
|
{
|
||||||
uint32_t currentmillis = millis();
|
uint32_t currentmillis = millis();
|
||||||
if ((currentmillis - CO2_lastUpdate > (g_pms_report_period * 1000)) || (!CO2_lastUpdate) && (scd30.dataReady()))
|
if ((currentmillis - CO2_lastUpdate > (g_pms_report_period * 1000)) || (!CO2_lastUpdate))
|
||||||
{
|
{
|
||||||
if (!scd30.read())
|
|
||||||
|
if (!scd30.dataAvailable())
|
||||||
{
|
{
|
||||||
Serial.println("SCD30: read error!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCD30_temperature.set(uint32_t(scd30.temperature));
|
SCD30_temperature.set(uint32_t(scd30.getTemperature()));
|
||||||
SCD30_Humidity.set(uint32_t(scd30.relative_humidity));
|
SCD30_Humidity.set(uint32_t(scd30.getHumidity()));
|
||||||
SCD30_CO2.set(uint32_t(scd30.CO2));
|
SCD30_CO2.set(uint32_t(scd30.getCO2()));
|
||||||
|
|
||||||
SCD30_temperature.publish();
|
SCD30_temperature.publish();
|
||||||
SCD30_Humidity.publish();
|
SCD30_Humidity.publish();
|
||||||
SCD30_CO2.publish();
|
SCD30_CO2.publish();
|
||||||
|
|
||||||
CO2_lastUpdate = currentmillis;
|
CO2_lastUpdate = currentmillis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <wire.h>
|
||||||
|
//#include <Adafruit_SCD30.h>
|
||||||
|
//#include <Adafruit_Sensor.h>
|
||||||
|
#include "SparkFun_SCD30_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_SCD30
|
||||||
|
|
||||||
#include <Adafruit_SCD30.h>
|
|
||||||
#include <Adafruit_Sensor.h>
|
|
||||||
|
|
||||||
#include "sensor.h"
|
#include "sensor.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +1,47 @@
|
|||||||
#include "VOC_sensor.h"
|
#include "VOC_sensor.h"
|
||||||
|
#define DEBUG_SERIAL
|
||||||
|
|
||||||
Adafruit_SGP30 sgp;
|
|
||||||
|
//Adafruit_SGP30 sgp;
|
||||||
|
SGP30 sgp;
|
||||||
|
|
||||||
|
//TwoWire wire1(1);
|
||||||
uint8_t VOC_samples = 3600 / g_pms_report_period;
|
uint8_t VOC_samples = 3600 / g_pms_report_period;
|
||||||
#define VOC_MIN 0
|
#define VOC_MIN 0
|
||||||
#define VOC_MAX 10000
|
#define VOC_MAX 10000
|
||||||
|
#define VOC_RAW_MAX 30000
|
||||||
#define VOC_INTERVAL 120000 //ms
|
#define VOC_INTERVAL 120000 //ms
|
||||||
|
|
||||||
uint32_t lastVOCtime = 0;
|
uint32_t lastVOCtime = 0;
|
||||||
//sensors
|
//sensors
|
||||||
AQSSensor SGP30_tvoc("TVOC", SGP30_TVOC, "ppb", device_name, VOC_samples, VOC_MIN, VOC_MAX);
|
AQSSensor SGP30_tvoc("TVOC", SGP30_TVOC, "ppb", device_name, VOC_samples, VOC_MIN, VOC_MAX);
|
||||||
AQSSensor SGP30_eco2("eCO2", SGP30_eCO2, "ppm", device_name, VOC_samples, VOC_MIN, VOC_MAX);
|
AQSSensor SGP30_eco2("eCO2", SGP30_eCO2, "ppm", device_name, VOC_samples, VOC_MIN, VOC_MAX);
|
||||||
AQSSensor SGP30_rawh2("Raw_H2", SGP30_rawH2, "#", device_name, VOC_samples, VOC_MIN, VOC_MAX);
|
AQSSensor SGP30_rawh2("Raw_H2", SGP30_rawH2, "#", device_name, VOC_samples, VOC_MIN, VOC_RAW_MAX);
|
||||||
AQSSensor SGP30_rawethanol("Raw_Ethanol", SGP30_rawEthanol, "#", device_name, VOC_samples, VOC_MIN, VOC_MAX);
|
AQSSensor SGP30_rawethanol("Raw_Ethanol", SGP30_rawEthanol, "#", device_name, VOC_samples, VOC_MIN, VOC_RAW_MAX);
|
||||||
|
|
||||||
void initVOCsensor(void)
|
void initVOCsensor(void)
|
||||||
{
|
{
|
||||||
Serial.println("VOCSensor: Init SGP30: ");
|
Serial.println("VOCSensor: Init SGP30: ");
|
||||||
|
//wire1.setPins(I2C_2_SDA, I2C_2_SCL);
|
||||||
|
//if (!sgp.begin(&wire1))
|
||||||
|
Wire.begin();
|
||||||
if (!sgp.begin())
|
if (!sgp.begin())
|
||||||
{
|
{
|
||||||
Serial.println("VOCSensor: Init Failed (SGP30 not found)");
|
Serial.println("VOCSensor: Init Failed (SGP30 not found)");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.printf("VOCSensor: serial =0x%X%X%X\n", sgp.serialnumber[0], sgp.serialnumber[1], sgp.serialnumber[2]);
|
sgp.getSerialID();
|
||||||
|
//Get version number
|
||||||
|
sgp.getFeatureSetVersion();
|
||||||
|
Serial.print("VOCSensor: serial =0x");
|
||||||
|
Serial.println((unsigned long)sgp.serialID, HEX);
|
||||||
addSensorToList(&SGP30_tvoc);
|
addSensorToList(&SGP30_tvoc);
|
||||||
addSensorToList(&SGP30_eco2);
|
addSensorToList(&SGP30_eco2);
|
||||||
addSensorToList(&SGP30_rawh2);
|
|
||||||
addSensorToList(&SGP30_rawethanol);
|
|
||||||
|
|
||||||
sgp.IAQmeasure();
|
sgp.initAirQuality();
|
||||||
sgp.IAQmeasureRaw();
|
sgp.measureAirQuality();
|
||||||
|
|
||||||
Serial.println("VOCSensor: Init OK");
|
Serial.println("VOCSensor: Init OK");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,28 +51,13 @@ void handleVOCsensor(void)
|
|||||||
uint32_t timenow = millis();
|
uint32_t timenow = millis();
|
||||||
if ((timenow - lastVOCtime > VOC_INTERVAL) || !lastVOCtime)
|
if ((timenow - lastVOCtime > VOC_INTERVAL) || !lastVOCtime)
|
||||||
{
|
{
|
||||||
if (!sgp.IAQmeasure())
|
sgp.measureAirQuality();
|
||||||
{
|
|
||||||
Serial.println("VOCSensor: Measurement failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SGP30_tvoc.set(sgp.TVOC);
|
SGP30_tvoc.set(sgp.TVOC);
|
||||||
SGP30_eco2.set(sgp.eCO2);
|
SGP30_eco2.set(sgp.CO2);
|
||||||
|
|
||||||
SGP30_tvoc.publish();
|
SGP30_tvoc.publish();
|
||||||
SGP30_eco2.publish();
|
SGP30_eco2.publish();
|
||||||
|
|
||||||
if (!sgp.IAQmeasureRaw())
|
|
||||||
{
|
|
||||||
Serial.println("VOCSensor: Raw Measurement failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SGP30_rawethanol.set(sgp.rawEthanol);
|
|
||||||
SGP30_rawh2.set(sgp.rawH2);
|
|
||||||
|
|
||||||
SGP30_rawethanol.publish();
|
|
||||||
SGP30_rawh2.publish();
|
|
||||||
|
|
||||||
lastVOCtime = timenow;
|
lastVOCtime = timenow;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,11 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "sensor.h"
|
#include "sensor.h"
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
#include "Adafruit_SGP30.h"
|
//#include "Adafruit_SGP30.h"
|
||||||
|
#include "SparkFun_SGP30_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_SGP30
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
|
|
||||||
void initVOCsensor(void);
|
void initVOCsensor(void);
|
||||||
|
|||||||
10
battery.cpp
Normal file
10
battery.cpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include "battery.h"
|
||||||
|
|
||||||
|
void initBattery(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void handleBattery(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
7
battery.h
Normal file
7
battery.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "IP5306.h"
|
||||||
|
|
||||||
|
void initBattery(void);
|
||||||
|
void handleBattery(void);
|
||||||
2
button.h
2
button.h
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
#include "JC_Button.h"
|
||||||
|
|
||||||
void initButtons( void );
|
void initButtons( void );
|
||||||
void handleButtons( void );
|
void handleButtons( void );
|
||||||
32
buttons.cpp
32
buttons.cpp
@@ -6,16 +6,45 @@ uint8_t g_previous_mode_button_state = 1;
|
|||||||
uint32_t g_last_debounce_time = 0;
|
uint32_t g_last_debounce_time = 0;
|
||||||
uint32_t g_debounce_delay = 50;
|
uint32_t g_debounce_delay = 50;
|
||||||
|
|
||||||
|
Button buttonCenter(BUTTON_CENTER);
|
||||||
|
Button buttonLeft(BUTTON_LEFT);
|
||||||
|
Button buttonRight(BUTTON_RIGHT);
|
||||||
|
|
||||||
void initButtons(void)
|
void initButtons(void)
|
||||||
{
|
{
|
||||||
Serial.print("initButtons:");
|
Serial.print("initButtons:");
|
||||||
|
buttonCenter.begin();
|
||||||
|
buttonLeft.begin();
|
||||||
|
buttonRight.begin();
|
||||||
|
|
||||||
pinMode(MODE_BUTTON_PIN, INPUT_PULLUP); // Pin for switching screens button
|
pinMode(MODE_BUTTON_PIN, INPUT_PULLUP); // Pin for switching screens button
|
||||||
Serial.println(" OK");
|
Serial.println(" OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleButtons(void)
|
void handleButtons(void)
|
||||||
{
|
{
|
||||||
g_previous_mode_button_state = g_current_mode_button_state;
|
//handle buttons
|
||||||
|
buttonCenter.read();
|
||||||
|
buttonLeft.read();
|
||||||
|
buttonRight.read();
|
||||||
|
|
||||||
|
if (buttonCenter.wasPressed())
|
||||||
|
{
|
||||||
|
backlightRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonLeft.wasPressed())
|
||||||
|
{
|
||||||
|
previousSensor();
|
||||||
|
backlightRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonRight.wasPressed())
|
||||||
|
{
|
||||||
|
nextSensor();
|
||||||
|
backlightRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
g_current_mode_button_state = digitalRead(MODE_BUTTON_PIN);
|
g_current_mode_button_state = digitalRead(MODE_BUTTON_PIN);
|
||||||
|
|
||||||
// Check if button is now pressed and it was previously unpressed
|
// Check if button is now pressed and it was previously unpressed
|
||||||
@@ -27,6 +56,7 @@ void handleButtons(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Serial.println("Button pressed");
|
Serial.println("Button pressed");
|
||||||
|
backlightRefresh();
|
||||||
// Increment display state
|
// Increment display state
|
||||||
g_last_debounce_time = millis();
|
g_last_debounce_time = millis();
|
||||||
}
|
}
|
||||||
|
|||||||
44
config.h
44
config.h
@@ -4,9 +4,9 @@
|
|||||||
/* WiFi config */
|
/* WiFi config */
|
||||||
#define WIFI_SSID "poes" // Your WiFi SSID
|
#define WIFI_SSID "poes" // Your WiFi SSID
|
||||||
#define WIFI_PASSWORD "Rijnstraat214" // Your WiFi password
|
#define WIFI_PASSWORD "Rijnstraat214" // Your WiFi password
|
||||||
|
#define HOST_NAME "AQS-monitor"
|
||||||
/* MQTT */
|
/* MQTT */
|
||||||
#define mqtt_broker "192.168.2.5" // IP address of your MQTT broker
|
#define mqtt_broker "192.168.2.3" // IP address of your MQTT broker
|
||||||
#define REPORT_MQTT_SEPARATE true // Report each value to its own topic
|
#define REPORT_MQTT_SEPARATE true // Report each value to its own topic
|
||||||
#define REPORT_MQTT_JSON true // Report all values in a JSON message
|
#define REPORT_MQTT_JSON true // Report all values in a JSON message
|
||||||
#define status_topic "events" // MQTT topic to report startup
|
#define status_topic "events" // MQTT topic to report startup
|
||||||
@@ -16,9 +16,6 @@
|
|||||||
#define g_pms_warmup_period 30 // Seconds to warm up PMS before reading
|
#define g_pms_warmup_period 30 // Seconds to warm up PMS before reading
|
||||||
#define g_pms_report_period 120 // Seconds between reports
|
#define g_pms_report_period 120 // Seconds between reports
|
||||||
|
|
||||||
/* Use WiFi. If this is off, MQTT won't run */
|
|
||||||
#define ENABLE_WIFI true
|
|
||||||
|
|
||||||
/* Serial */
|
/* Serial */
|
||||||
#define SERIAL_BAUD_RATE 115200 // Speed for USB serial console
|
#define SERIAL_BAUD_RATE 115200 // Speed for USB serial console
|
||||||
|
|
||||||
@@ -27,28 +24,25 @@
|
|||||||
|
|
||||||
/* ----------------- Hardware-specific Config ---------------------- */
|
/* ----------------- Hardware-specific Config ---------------------- */
|
||||||
/* Mode button connection (momentary between this pin and GND) */
|
/* Mode button connection (momentary between this pin and GND) */
|
||||||
#define MODE_BUTTON_PIN 0
|
#define MODE_BUTTON_PIN 0
|
||||||
|
#define BUTTON_CENTER 37
|
||||||
|
#define BUTTON_RIGHT 39
|
||||||
|
#define BUTTON_LEFT 38
|
||||||
|
#define I2C_SDA_PIN 21
|
||||||
|
#define I2C_SCL_PIN 22
|
||||||
|
#define I2C_2_SCL 13
|
||||||
|
#define I2C_2_SDA 14
|
||||||
|
#define PMS_RX_PIN 19 // Tx to the PMS SHOULD BE 16
|
||||||
|
#define PMS_TX_PIN 26 // Rx from the PMS SHOULD BE 17
|
||||||
|
#define TFT_BL 4 // LED back-light control pin
|
||||||
|
|
||||||
/* RGB LEDs */
|
|
||||||
#define WS2812B_PIN 13
|
|
||||||
#define NUM_RGB_LEDS 0
|
|
||||||
|
|
||||||
/* LCD */
|
//backlight defines
|
||||||
// #define TFT_DC_PIN 2
|
#define TFT_BACKLIGHT_ON HIGH // Level to turn ON back-light (HIGH or LOW)
|
||||||
// #define TFT_RST_PIN 4
|
#define TFT_BL_PWMCHANNEL 1
|
||||||
// #define TFT_CS_PIN 26
|
#define TFT_BL_FREQ 5000
|
||||||
// #define TFT_SCLK_PIN 18
|
#define TFT_BL_BITS 8
|
||||||
// #define TFT_MISO_PIN 19
|
|
||||||
// #define TFT_MOSI_PIN 23
|
|
||||||
|
|
||||||
/* I2C */
|
|
||||||
#define I2C_SDA_PIN 21
|
|
||||||
#define I2C_SCL_PIN 22
|
|
||||||
//#define BME680_I2C_ADDR 0x76
|
|
||||||
|
|
||||||
/* Particulate Matter Sensor */
|
/* Particulate Matter Sensor */
|
||||||
#define PMS_BAUD_RATE 9600
|
#define PMS_BAUD_RATE 9600
|
||||||
#define PMS_SET_PIN 19
|
|
||||||
#define PMS_RESET_PIN 26
|
|
||||||
#define PMS_RX_PIN 4 // Tx to the PMS SHOULD BE 16
|
|
||||||
#define PMS_TX_PIN 14 // Rx from the PMS SHOULD BE 17
|
|
||||||
|
|||||||
46
esp_ota.cpp
Normal file
46
esp_ota.cpp
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#include "esp_ota.h"
|
||||||
|
|
||||||
|
void initEspOta(void)
|
||||||
|
{
|
||||||
|
Serial.println("ESPOTA: init");
|
||||||
|
ArduinoOTA
|
||||||
|
.onStart([]() {
|
||||||
|
String type;
|
||||||
|
if (ArduinoOTA.getCommand() == U_FLASH)
|
||||||
|
type = "sketch";
|
||||||
|
else // U_SPIFFS
|
||||||
|
type = "filesystem";
|
||||||
|
|
||||||
|
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
|
||||||
|
Serial.println("ESPOTA: Start updating " + type);
|
||||||
|
ProgressbarVisible(true);
|
||||||
|
ledcWrite(TFT_BL_PWMCHANNEL, 64);
|
||||||
|
})
|
||||||
|
.onEnd([]() {
|
||||||
|
Serial.println("\nESPOTA: End");
|
||||||
|
})
|
||||||
|
.onProgress([](unsigned int progress, unsigned int total) {
|
||||||
|
Serial.printf("ESPOTA: Progress: %u%%\r", (progress / (total / 100)));
|
||||||
|
setOTAProgress((progress / (total / 100)));
|
||||||
|
})
|
||||||
|
.onError([](ota_error_t error) {
|
||||||
|
Serial.printf("ESPOTA: Error[%u]: ", error);
|
||||||
|
if (error == OTA_AUTH_ERROR) Serial.println("ESPOTA: Auth Failed");
|
||||||
|
else if (error == OTA_BEGIN_ERROR) Serial.println("ESPOTA: Begin Failed");
|
||||||
|
else if (error == OTA_CONNECT_ERROR) Serial.println("ESPOTA: Connect Failed");
|
||||||
|
else if (error == OTA_RECEIVE_ERROR) Serial.println("ESPOTA: Receive Failed");
|
||||||
|
else if (error == OTA_END_ERROR) Serial.println("ESPOTA: End Failed");
|
||||||
|
});
|
||||||
|
|
||||||
|
ArduinoOTA.begin();
|
||||||
|
|
||||||
|
Serial.print("ESPOTA: IP address: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
Serial.println("ESPOTA: init OK");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleEspOta(void)
|
||||||
|
{
|
||||||
|
ArduinoOTA.handle();
|
||||||
|
}
|
||||||
8
esp_ota.h
Normal file
8
esp_ota.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include <ArduinoOTA.h>
|
||||||
|
#include "lcd.h"
|
||||||
|
|
||||||
|
void initEspOta(void);
|
||||||
|
void handleEspOta(void);
|
||||||
506
lcd.cpp
506
lcd.cpp
@@ -1,25 +1,5 @@
|
|||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
|
|
||||||
// This example draws an animated dial with a rotating needle.
|
|
||||||
|
|
||||||
// The dial is a jpeg image, the needle is created using a rotated
|
|
||||||
// Sprite. The example operates by reading blocks of pixels from the
|
|
||||||
// TFT, thus the TFT setup must support reading from the TFT CGRAM.
|
|
||||||
|
|
||||||
// The sketch operates by creating a copy of the screen block where
|
|
||||||
// the needle will be drawn, the needle is then drawn on the screen.
|
|
||||||
// When the needle moves, the original copy of the sreen area is
|
|
||||||
// pushed to the screen to over-write the needle graphic. A copy
|
|
||||||
// of the screen where the new position will be drawn is then made
|
|
||||||
// before drawing the needle in the new postion. This technique
|
|
||||||
// allows the needle to move over other screen graphics.
|
|
||||||
|
|
||||||
// The sketch calculates the size of the buffer memory required and
|
|
||||||
// reserves the memory for the TFT block copy.
|
|
||||||
|
|
||||||
// Created by Bodmer 17/3/20 as an example to the TFT_eSPI library:
|
|
||||||
// https://github.com/Bodmer/TFT_eSPI
|
|
||||||
|
|
||||||
#define NEEDLE_LENGTH 35 // Visible length
|
#define NEEDLE_LENGTH 35 // Visible length
|
||||||
#define NEEDLE_WIDTH 5 // Width of needle - make it an odd number
|
#define NEEDLE_WIDTH 5 // Width of needle - make it an odd number
|
||||||
#define NEEDLE_RADIUS 90 // Radius at tip
|
#define NEEDLE_RADIUS 90 // Radius at tip
|
||||||
@@ -28,33 +8,58 @@
|
|||||||
#define DIAL_CENTRE_X 120
|
#define DIAL_CENTRE_X 120
|
||||||
#define DIAL_CENTRE_Y 120
|
#define DIAL_CENTRE_Y 120
|
||||||
|
|
||||||
// Font attached to this sketch
|
#define MAXGUAGE 240
|
||||||
#include "NotoSansBold36.h"
|
#define MINGUAGE 0
|
||||||
|
#define DISPLAY_ROTATE 15 //sec
|
||||||
|
|
||||||
|
#define BACKLIGHTTIMEOUT 60000
|
||||||
|
#define BACKLIGHTONBRGT 84
|
||||||
|
#define BACKLIGHTSTEP 1
|
||||||
|
|
||||||
#define AA_FONT_LARGE NotoSansBold36
|
#define AA_FONT_LARGE NotoSansBold36
|
||||||
|
|
||||||
#include <TFT_eSPI.h>
|
enum DISPLAY_STATE
|
||||||
|
{
|
||||||
|
DISPLAY_PM1P0,
|
||||||
|
DISPLAY_PM2P5,
|
||||||
|
DISPLAY_PM10P0,
|
||||||
|
DISPLAY_TEMP,
|
||||||
|
DISPLAY_HUM,
|
||||||
|
DISPLAY_CO2,
|
||||||
|
DISPLAY_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
// sprite elements
|
||||||
TFT_eSPI tft = TFT_eSPI();
|
TFT_eSPI tft = TFT_eSPI();
|
||||||
TFT_eSprite needle = TFT_eSprite(&tft); // Sprite object for needle
|
TFT_eSprite needle = TFT_eSprite(&tft); // Sprite object for needle
|
||||||
TFT_eSprite spr = TFT_eSprite(&tft); // Sprite for meter reading
|
TFT_eSprite spr = TFT_eSprite(&tft); // Sprite for meter reading
|
||||||
TFT_eSprite nameSpr = TFT_eSprite(&tft);
|
TFT_eSprite nameSpr = TFT_eSprite(&tft);
|
||||||
TFT_eSprite unitSpr = TFT_eSprite(&tft);
|
TFT_eSprite unitSpr = TFT_eSprite(&tft);
|
||||||
|
TFT_eSprite ProgressBar = TFT_eSprite(&tft);
|
||||||
// Jpeg image array attached to this sketch
|
|
||||||
#include "dial.h"
|
|
||||||
|
|
||||||
// Include the jpeg decoder library
|
|
||||||
#include <TJpg_Decoder.h>
|
|
||||||
|
|
||||||
uint16_t *tft_buffer;
|
uint16_t *tft_buffer;
|
||||||
bool buffer_loaded = false;
|
bool buffer_loaded = false;
|
||||||
uint16_t spr_width = 0;
|
uint16_t spr_width = 0;
|
||||||
uint16_t name_spr_width = 0;
|
uint16_t name_spr_width = 0;
|
||||||
|
bool progessbarActive = false;
|
||||||
|
|
||||||
void createNeedle(void);
|
DISPLAY_STATE displaystate = DISPLAY_PM1P0;
|
||||||
void plotNeedle(int16_t angle, uint16_t ms_delay);
|
uint32_t display_last_update = 0;
|
||||||
|
|
||||||
|
uint32_t backlightTimeout = 0;
|
||||||
|
uint8_t backlightBrightness = BACKLIGHTONBRGT;
|
||||||
|
|
||||||
// =======================================================================================
|
// =======================================================================================
|
||||||
// This function will be called during decoding of the jpeg file
|
// Declarations
|
||||||
|
// =======================================================================================
|
||||||
|
void createNeedle(void);
|
||||||
|
void plotNeedle(int16_t angle, uint16_t ms_delay);
|
||||||
|
void setBacklight(uint8_t value);
|
||||||
|
bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t *bitmap);
|
||||||
|
void backlightRefresh(void);
|
||||||
|
|
||||||
|
// =======================================================================================
|
||||||
|
// implementation
|
||||||
// =======================================================================================
|
// =======================================================================================
|
||||||
bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t *bitmap)
|
bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t *bitmap)
|
||||||
{
|
{
|
||||||
@@ -69,200 +74,37 @@ bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t *bitmap)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================================
|
void setBacklight(uint8_t value)
|
||||||
// Setup
|
|
||||||
// =======================================================================================
|
|
||||||
void initLCD()
|
|
||||||
{
|
{
|
||||||
Serial.print("InitLCD:");
|
ledcWrite(TFT_BL_PWMCHANNEL, value);
|
||||||
// The byte order can be swapped (set true for TFT_eSPI)
|
|
||||||
TJpgDec.setSwapBytes(true);
|
|
||||||
|
|
||||||
// The jpeg decoder must be given the exact name of the rendering function above
|
|
||||||
TJpgDec.setCallback(tft_output);
|
|
||||||
|
|
||||||
tft.begin();
|
|
||||||
tft.setRotation(0);
|
|
||||||
tft.fillScreen(TFT_BLACK);
|
|
||||||
|
|
||||||
// Draw the dial
|
|
||||||
TJpgDec.drawJpg(0, 0, dial, sizeof(dial));
|
|
||||||
tft.drawCircle(DIAL_CENTRE_X, DIAL_CENTRE_Y, NEEDLE_RADIUS - NEEDLE_LENGTH, TFT_DARKGREY);
|
|
||||||
|
|
||||||
// Load the font and create the Sprite for reporting the value
|
|
||||||
spr.loadFont(AA_FONT_LARGE);
|
|
||||||
spr_width = spr.textWidth("277");
|
|
||||||
spr.createSprite(spr_width, spr.fontHeight());
|
|
||||||
uint16_t bg_color = tft.readPixel(120, 120); // Get colour from dial centre
|
|
||||||
spr.fillSprite(bg_color);
|
|
||||||
spr.setTextColor(TFT_WHITE, bg_color);
|
|
||||||
spr.setTextDatum(MC_DATUM);
|
|
||||||
spr.setTextPadding(spr_width);
|
|
||||||
spr.drawNumber(0, spr_width / 2, spr.fontHeight() / 2);
|
|
||||||
spr.pushSprite(DIAL_CENTRE_X - spr_width / 2, DIAL_CENTRE_Y - spr.fontHeight() / 2);
|
|
||||||
|
|
||||||
// Plot the label text
|
|
||||||
nameSpr.setTextFont(3);
|
|
||||||
name_spr_width = nameSpr.textWidth("Temperature");
|
|
||||||
nameSpr.createSprite(name_spr_width, nameSpr.fontHeight() * 2 + 2);
|
|
||||||
nameSpr.fillSprite(bg_color);
|
|
||||||
nameSpr.setTextColor(TFT_WHITE, bg_color);
|
|
||||||
nameSpr.setTextDatum(MC_DATUM);
|
|
||||||
nameSpr.setTextPadding(name_spr_width);
|
|
||||||
nameSpr.drawString("Sensor Name", name_spr_width / 2, nameSpr.fontHeight() / 2);
|
|
||||||
nameSpr.drawString("Unit", name_spr_width / 2, nameSpr.fontHeight() / 2 * 3 + 2); nameSpr.pushSprite(DIAL_CENTRE_X - name_spr_width / 2, DIAL_CENTRE_Y + 40, 2);
|
|
||||||
nameSpr.pushSprite(DIAL_CENTRE_X - name_spr_width / 2, DIAL_CENTRE_Y + 40, 2);
|
|
||||||
|
|
||||||
// Define where the needle pivot point is on the TFT before
|
|
||||||
// creating the needle so boundary calculation is correct
|
|
||||||
tft.setPivot(DIAL_CENTRE_X, DIAL_CENTRE_Y);
|
|
||||||
|
|
||||||
// Create the needle Sprite
|
|
||||||
createNeedle();
|
|
||||||
|
|
||||||
// Reset needle position to 0
|
|
||||||
plotNeedle(0, 0, 0);
|
|
||||||
|
|
||||||
delay(2000);
|
|
||||||
Serial.println("OK");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================================
|
void ProgressbarVisible(bool visible)
|
||||||
// Loop
|
|
||||||
// =======================================================================================
|
|
||||||
enum DISPLAY_STATE
|
|
||||||
{
|
{
|
||||||
DISPLAY_PM1P0,
|
progessbarActive = visible;
|
||||||
DISPLAY_PM2P5,
|
if (!visible)
|
||||||
DISPLAY_PM10P0,
|
|
||||||
DISPLAY_TEMP,
|
|
||||||
DISPLAY_HUM,
|
|
||||||
DISPLAY_CO2,
|
|
||||||
DISPLAY_LAST
|
|
||||||
};
|
|
||||||
|
|
||||||
DISPLAY_STATE displaystate = DISPLAY_PM1P0;
|
|
||||||
uint32_t display_last_update = 0;
|
|
||||||
|
|
||||||
#define MAXGUAGE 240
|
|
||||||
#define MINGUAGE 0
|
|
||||||
#define DISPLAY_ROTATE 10 //sec
|
|
||||||
|
|
||||||
void handleLCD()
|
|
||||||
{
|
|
||||||
static uint32_t value;
|
|
||||||
static uint16_t angle;
|
|
||||||
DISPLAY_STATE displaystate_next = DISPLAY_PM1P0;
|
|
||||||
sensor_e nextSensor = AE_1P0;
|
|
||||||
|
|
||||||
switch (displaystate)
|
|
||||||
{
|
{
|
||||||
case DISPLAY_PM1P0:
|
ProgressBar.fillSprite(TFT_BLACK);
|
||||||
{
|
ProgressBar.pushSprite(10, 270);
|
||||||
nextSensor = AE_1P0;
|
|
||||||
displaystate_next = DISPLAY_PM2P5;
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case DISPLAY_PM2P5:
|
|
||||||
{
|
|
||||||
nextSensor = AE_2P5;
|
|
||||||
displaystate_next = DISPLAY_PM10P0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DISPLAY_PM10P0:
|
|
||||||
{
|
|
||||||
nextSensor = AE_10P0;
|
|
||||||
displaystate_next = DISPLAY_TEMP;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DISPLAY_TEMP:
|
|
||||||
{
|
|
||||||
nextSensor = SCD30_temp;
|
|
||||||
displaystate_next = DISPLAY_HUM;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DISPLAY_HUM:
|
|
||||||
{
|
|
||||||
nextSensor = SCD30_hum;
|
|
||||||
displaystate_next = DISPLAY_CO2;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DISPLAY_CO2:
|
|
||||||
{
|
|
||||||
nextSensor = SCD30_hum;
|
|
||||||
displaystate_next = DISPLAY_PM1P0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DISPLAY_LAST:
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
displaystate_next = DISPLAY_PM1P0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//rotate display
|
|
||||||
uint32_t timenow = millis();
|
|
||||||
if (timenow - display_last_update > (DISPLAY_ROTATE * 1000))
|
|
||||||
{
|
|
||||||
displaystate = displaystate_next;
|
|
||||||
display_last_update = timenow;
|
|
||||||
Serial.println("LCD next State");
|
|
||||||
}
|
|
||||||
//calculate value to angle
|
|
||||||
|
|
||||||
AQSSensor *sensor = getSensor(nextSensor);
|
|
||||||
if (sensor == NULL)
|
|
||||||
{
|
|
||||||
Serial.println("LCD: getSensor=NULL!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
angle = map(value, sensor->getMin(), sensor->getMax(), MINGUAGE, MAXGUAGE);
|
|
||||||
|
|
||||||
plotNeedle(angle, 15, value);
|
|
||||||
|
|
||||||
nameSpr.drawString(sensor->getName().c_str(), name_spr_width / 2, nameSpr.fontHeight() / 2);
|
|
||||||
nameSpr.drawString(sensor->getUnit().c_str(), name_spr_width / 2, nameSpr.fontHeight() / 2 * 3 + 2);
|
|
||||||
nameSpr.pushSprite(DIAL_CENTRE_X - name_spr_width / 2, DIAL_CENTRE_Y + 40, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================================
|
void setOTAProgress(uint8_t value)
|
||||||
// Create the needle Sprite
|
|
||||||
// =======================================================================================
|
|
||||||
void createNeedle(void)
|
|
||||||
{
|
{
|
||||||
needle.setColorDepth(16);
|
uint16_t progress = map(value, 0, 100, 0, 212);
|
||||||
needle.createSprite(NEEDLE_WIDTH, NEEDLE_LENGTH); // create the needle Sprite
|
ProgressBar.drawRoundRect(0, 2, 220, 22, 5, TFT_BLUE);
|
||||||
|
ProgressBar.fillRoundRect(4, 5, progress, 15, 3, TFT_BLUE);
|
||||||
needle.fillSprite(TFT_BLACK); // Fill with black
|
if (progessbarActive)
|
||||||
|
{
|
||||||
// Define needle pivot point relative to top left corner of Sprite
|
ProgressBar.pushSprite(10, 270);
|
||||||
uint16_t piv_x = NEEDLE_WIDTH / 2; // pivot x in Sprite (middle)
|
}
|
||||||
uint16_t piv_y = NEEDLE_RADIUS; // pivot y in Sprite
|
}
|
||||||
needle.setPivot(piv_x, piv_y); // Set pivot point in this Sprite
|
|
||||||
|
void backlightRefresh(void)
|
||||||
// Draw the red needle in the Sprite
|
{
|
||||||
needle.fillRect(0, 0, NEEDLE_WIDTH, NEEDLE_LENGTH, TFT_MAROON);
|
backlightTimeout = millis();
|
||||||
needle.fillRect(1, 1, NEEDLE_WIDTH - 2, NEEDLE_LENGTH - 2, TFT_RED);
|
|
||||||
|
|
||||||
// Bounding box parameters to be populated
|
|
||||||
int16_t min_x;
|
|
||||||
int16_t min_y;
|
|
||||||
int16_t max_x;
|
|
||||||
int16_t max_y;
|
|
||||||
|
|
||||||
// Work out the worst case area that must be grabbed from the TFT,
|
|
||||||
// this is at a 45 degree rotation
|
|
||||||
needle.getRotatedBounds(45, &min_x, &min_y, &max_x, &max_y);
|
|
||||||
|
|
||||||
// Calculate the size and allocate the buffer for the grabbed TFT area
|
|
||||||
tft_buffer = (uint16_t *)malloc(((max_x - min_x) + 2) * ((max_y - min_y) + 2) * 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================================
|
|
||||||
// Move the needle to a new position
|
|
||||||
// =======================================================================================
|
|
||||||
void plotNeedle(int16_t angle, uint16_t ms_delay, uint32_t value)
|
void plotNeedle(int16_t angle, uint16_t ms_delay, uint32_t value)
|
||||||
{
|
{
|
||||||
static int16_t old_angle = -120; // Starts at -120 degrees
|
static int16_t old_angle = -120; // Starts at -120 degrees
|
||||||
@@ -283,7 +125,6 @@ void plotNeedle(int16_t angle, uint16_t ms_delay, uint32_t value)
|
|||||||
// Move the needle until new angle reached
|
// Move the needle until new angle reached
|
||||||
while (angle != old_angle || !buffer_loaded)
|
while (angle != old_angle || !buffer_loaded)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (old_angle < angle)
|
if (old_angle < angle)
|
||||||
old_angle++;
|
old_angle++;
|
||||||
else
|
else
|
||||||
@@ -323,3 +164,236 @@ void plotNeedle(int16_t angle, uint16_t ms_delay, uint32_t value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================================
|
// =======================================================================================
|
||||||
|
// Setup
|
||||||
|
// =======================================================================================
|
||||||
|
void createProgressBar(void)
|
||||||
|
{
|
||||||
|
ProgressBar.createSprite(220, 30);
|
||||||
|
ProgressBar.fillSprite(TFT_BLACK);
|
||||||
|
ProgressBar.drawRoundRect(0, 2, 220, 22, 5, TFT_BLUE);
|
||||||
|
ProgressBar.pushSprite(10, 270);
|
||||||
|
}
|
||||||
|
|
||||||
|
void createNameSprite(void)
|
||||||
|
{
|
||||||
|
nameSpr.setTextFont(2);
|
||||||
|
name_spr_width = nameSpr.textWidth("---Sensor Name---");
|
||||||
|
nameSpr.createSprite(name_spr_width, nameSpr.fontHeight() * 2 + 2);
|
||||||
|
uint16_t bg_color = tft.readPixel(120, 120); // Get colour from dial centre
|
||||||
|
|
||||||
|
nameSpr.fillSprite(bg_color);
|
||||||
|
nameSpr.setTextColor(TFT_WHITE, bg_color);
|
||||||
|
nameSpr.setTextDatum(MC_DATUM);
|
||||||
|
nameSpr.setTextPadding(name_spr_width);
|
||||||
|
nameSpr.drawString("Sensor Name", name_spr_width / 2, nameSpr.fontHeight() / 2);
|
||||||
|
nameSpr.drawString("Unit", name_spr_width / 2, nameSpr.fontHeight() / 2 * 3 + 2);
|
||||||
|
nameSpr.pushSprite(DIAL_CENTRE_X - name_spr_width / 2, DIAL_CENTRE_Y + 40, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void createValueSprinte(void)
|
||||||
|
{
|
||||||
|
spr.loadFont(AA_FONT_LARGE);
|
||||||
|
spr_width = spr.textWidth("277");
|
||||||
|
spr.createSprite(spr_width, spr.fontHeight());
|
||||||
|
uint16_t bg_color = tft.readPixel(120, 120); // Get colour from dial centre
|
||||||
|
spr.fillSprite(bg_color);
|
||||||
|
spr.setTextColor(TFT_WHITE, bg_color);
|
||||||
|
spr.setTextDatum(MC_DATUM);
|
||||||
|
spr.setTextPadding(spr_width);
|
||||||
|
spr.drawNumber(0, spr_width / 2, spr.fontHeight() / 2);
|
||||||
|
spr.pushSprite(DIAL_CENTRE_X - spr_width / 2, DIAL_CENTRE_Y - spr.fontHeight() / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void createNeedle(void)
|
||||||
|
{
|
||||||
|
needle.setColorDepth(16);
|
||||||
|
needle.createSprite(NEEDLE_WIDTH, NEEDLE_LENGTH); // create the needle Sprite
|
||||||
|
|
||||||
|
needle.fillSprite(TFT_BLACK); // Fill with black
|
||||||
|
|
||||||
|
// Define needle pivot point relative to top left corner of Sprite
|
||||||
|
uint16_t piv_x = NEEDLE_WIDTH / 2; // pivot x in Sprite (middle)
|
||||||
|
uint16_t piv_y = NEEDLE_RADIUS; // pivot y in Sprite
|
||||||
|
needle.setPivot(piv_x, piv_y); // Set pivot point in this Sprite
|
||||||
|
|
||||||
|
// Draw the red needle in the Sprite
|
||||||
|
needle.fillRect(0, 0, NEEDLE_WIDTH, NEEDLE_LENGTH, TFT_MAROON);
|
||||||
|
needle.fillRect(1, 1, NEEDLE_WIDTH - 2, NEEDLE_LENGTH - 2, TFT_RED);
|
||||||
|
|
||||||
|
// Bounding box parameters to be populated
|
||||||
|
int16_t min_x;
|
||||||
|
int16_t min_y;
|
||||||
|
int16_t max_x;
|
||||||
|
int16_t max_y;
|
||||||
|
|
||||||
|
// Work out the worst case area that must be grabbed from the TFT,
|
||||||
|
// this is at a 45 degree rotation
|
||||||
|
needle.getRotatedBounds(45, &min_x, &min_y, &max_x, &max_y);
|
||||||
|
|
||||||
|
// Calculate the size and allocate the buffer for the grabbed TFT area
|
||||||
|
tft_buffer = (uint16_t *)malloc(((max_x - min_x) + 2) * ((max_y - min_y) + 2) * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void createDail(void)
|
||||||
|
{
|
||||||
|
TJpgDec.setSwapBytes(true);
|
||||||
|
|
||||||
|
// The jpeg decoder must be given the exact name of the rendering function above
|
||||||
|
TJpgDec.setCallback(tft_output);
|
||||||
|
// Draw the dial
|
||||||
|
TJpgDec.drawJpg(0, 0, dial, sizeof(dial));
|
||||||
|
tft.drawCircle(DIAL_CENTRE_X, DIAL_CENTRE_Y, NEEDLE_RADIUS - NEEDLE_LENGTH, TFT_DARKGREY);
|
||||||
|
|
||||||
|
// Define where the needle pivot point is on the TFT before
|
||||||
|
// creating the needle so boundary calculation is correct
|
||||||
|
tft.setPivot(DIAL_CENTRE_X, DIAL_CENTRE_Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void initLCD()
|
||||||
|
{
|
||||||
|
Serial.print("InitLCD:");
|
||||||
|
// The byte order can be swapped (set true for TFT_eSPI)
|
||||||
|
|
||||||
|
tft.begin();
|
||||||
|
tft.setRotation(0);
|
||||||
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
|
||||||
|
// Create the Sprites
|
||||||
|
createProgressBar();
|
||||||
|
createDail();
|
||||||
|
createValueSprinte();
|
||||||
|
createNeedle();
|
||||||
|
createNameSprite();
|
||||||
|
|
||||||
|
ledcSetup(TFT_BL_PWMCHANNEL, TFT_BL_FREQ, TFT_BL_BITS);
|
||||||
|
ledcAttachPin(TFT_BL, TFT_BL_PWMCHANNEL);
|
||||||
|
ledcWrite(TFT_BL_PWMCHANNEL, BACKLIGHTONBRGT);
|
||||||
|
|
||||||
|
// Reset needle position to 0
|
||||||
|
plotNeedle(0, 0, 0);
|
||||||
|
|
||||||
|
Serial.println("OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================================
|
||||||
|
// Loop
|
||||||
|
// =======================================================================================
|
||||||
|
void handleBacklight(void)
|
||||||
|
{
|
||||||
|
uint32_t timeNow = millis();
|
||||||
|
if (!backlightTimeout)
|
||||||
|
{
|
||||||
|
backlightRefresh();
|
||||||
|
}
|
||||||
|
if (timeNow - backlightTimeout > BACKLIGHTTIMEOUT)
|
||||||
|
{
|
||||||
|
if (backlightBrightness > BACKLIGHTSTEP)
|
||||||
|
{
|
||||||
|
backlightBrightness -= BACKLIGHTSTEP;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backlightBrightness = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (backlightBrightness < BACKLIGHTONBRGT)
|
||||||
|
{
|
||||||
|
backlightBrightness += BACKLIGHTSTEP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ledcWrite(TFT_BL_PWMCHANNEL, backlightBrightness);
|
||||||
|
}
|
||||||
|
|
||||||
|
sensor_e displaySensor[] =
|
||||||
|
{
|
||||||
|
AE_1P0,
|
||||||
|
AE_2P5,
|
||||||
|
AE_10P0,
|
||||||
|
SCD30_temp,
|
||||||
|
SCD30_hum,
|
||||||
|
SCD30_co2,
|
||||||
|
SGP30_TVOC,
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t displaySensorSize = 7;
|
||||||
|
|
||||||
|
uint8_t displaySensorIndex = 0;
|
||||||
|
|
||||||
|
void nextSensor(void)
|
||||||
|
{
|
||||||
|
if (displaySensorIndex < displaySensorSize - 1)
|
||||||
|
{
|
||||||
|
displaySensorIndex++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
displaySensorIndex = 0;
|
||||||
|
}
|
||||||
|
display_last_update = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
void previousSensor(void)
|
||||||
|
{
|
||||||
|
if (displaySensorIndex > 0)
|
||||||
|
{
|
||||||
|
displaySensorIndex--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
displaySensorIndex = displaySensorSize - 1;
|
||||||
|
}
|
||||||
|
display_last_update = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleplotSensor(void)
|
||||||
|
{
|
||||||
|
if(!backlightBrightness)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AQSSensor *sensor = getSensor(displaySensor[displaySensorIndex]);
|
||||||
|
if (sensor == NULL)
|
||||||
|
{
|
||||||
|
Serial.println("LCD: getSensor=NULL!");
|
||||||
|
nextSensor();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t angle = map(sensor->value(), sensor->getMin(), sensor->getMax(), MINGUAGE, MAXGUAGE);
|
||||||
|
|
||||||
|
plotNeedle(angle, 15, sensor->value());
|
||||||
|
|
||||||
|
nameSpr.drawString(sensor->getName().c_str(), name_spr_width / 2, nameSpr.fontHeight() / 2);
|
||||||
|
nameSpr.drawString(sensor->getUnit().c_str(), name_spr_width / 2, nameSpr.fontHeight() / 2 * 3 + 2);
|
||||||
|
nameSpr.pushSprite(DIAL_CENTRE_X - name_spr_width / 2, DIAL_CENTRE_Y + 40, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleDisplayRotate(void)
|
||||||
|
{
|
||||||
|
//rotate display
|
||||||
|
if(!backlightBrightness)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t timenow = millis();
|
||||||
|
if (timenow - display_last_update > (DISPLAY_ROTATE * 1000))
|
||||||
|
{
|
||||||
|
Serial.println("LCD next State");
|
||||||
|
nextSensor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleLCD()
|
||||||
|
{
|
||||||
|
handleDisplayRotate();
|
||||||
|
|
||||||
|
handleplotSensor();
|
||||||
|
|
||||||
|
handleBacklight();
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================================
|
||||||
|
|||||||
11
lcd.h
11
lcd.h
@@ -3,7 +3,18 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "sensor.h"
|
#include "sensor.h"
|
||||||
|
|
||||||
|
#include "NotoSansBold36.h"
|
||||||
|
#include <TFT_eSPI.h>
|
||||||
|
#include "dial.h"
|
||||||
|
#include <TJpg_Decoder.h>
|
||||||
|
|
||||||
void initLCD();
|
void initLCD();
|
||||||
void handleLCD();
|
void handleLCD();
|
||||||
|
|
||||||
void plotNeedle(int16_t angle, uint16_t ms_delay, uint32_t value);
|
void plotNeedle(int16_t angle, uint16_t ms_delay, uint32_t value);
|
||||||
|
void setOTAProgress(uint8_t value);
|
||||||
|
void ProgressbarVisible(bool visible);
|
||||||
|
|
||||||
|
void backlightRefresh(void);
|
||||||
|
void nextSensor(void);
|
||||||
|
void previousSensor(void);
|
||||||
50
lib/IP5306/IP5306.cpp
Normal file
50
lib/IP5306/IP5306.cpp
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
IP5306.cpp - Library for IP5306_I2C Power controller.
|
||||||
|
Created by Sebastian Haap, December 3, 2019.
|
||||||
|
Based on https://gist.github.com/me-no-dev/7702f08dd578de5efa47caf322250b57
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Wire.h"
|
||||||
|
#include "IP5306.h"
|
||||||
|
|
||||||
|
int ip5306_get_reg(uint8_t reg){
|
||||||
|
Wire.beginTransmission(0x75);
|
||||||
|
Wire.write(reg);
|
||||||
|
if(Wire.endTransmission(false) == 0 && Wire.requestFrom(0x75, 1)){
|
||||||
|
return Wire.read();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ip5306_set_reg(uint8_t reg, uint8_t value){
|
||||||
|
Wire.beginTransmission(0x75);
|
||||||
|
Wire.write(reg);
|
||||||
|
Wire.write(value);
|
||||||
|
if(Wire.endTransmission(true) == 0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ip5306_get_bits(uint8_t reg, uint8_t index, uint8_t bits){
|
||||||
|
int value = ip5306_get_reg(reg);
|
||||||
|
if(value < 0){
|
||||||
|
//Serial.printf("ip5306_get_bits fail: 0x%02x\n", reg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return (value >> index) & ((1 << bits)-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ip5306_set_bits(uint8_t reg, uint8_t index, uint8_t bits, uint8_t value){
|
||||||
|
uint8_t mask = (1 << bits) - 1;
|
||||||
|
int v = ip5306_get_reg(reg);
|
||||||
|
if(v < 0){
|
||||||
|
//Serial.printf("ip5306_get_reg fail: 0x%02x\n", reg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
v &= ~(mask << index);
|
||||||
|
v |= ((value & mask) << index);
|
||||||
|
if(ip5306_set_reg(reg, v)){
|
||||||
|
//Serial.printf("ip5306_set_bits fail: 0x%02x\n", reg);
|
||||||
|
}
|
||||||
|
}
|
||||||
110
lib/IP5306/IP5306.h
Normal file
110
lib/IP5306/IP5306.h
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
IP5306.h - Library for IP5306_I2C Power controller.
|
||||||
|
Created by Sebastian Haap, December 3, 2019.
|
||||||
|
Based on https://gist.github.com/me-no-dev/7702f08dd578de5efa47caf322250b57
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef IP5306_h
|
||||||
|
#define IP5306_h
|
||||||
|
|
||||||
|
#include "Wire.h"
|
||||||
|
|
||||||
|
#define IP5306_REG_SYS_0 0x00
|
||||||
|
#define IP5306_REG_SYS_1 0x01
|
||||||
|
#define IP5306_REG_SYS_2 0x02
|
||||||
|
#define IP5306_REG_CHG_0 0x20
|
||||||
|
#define IP5306_REG_CHG_1 0x21
|
||||||
|
#define IP5306_REG_CHG_2 0x22
|
||||||
|
#define IP5306_REG_CHG_3 0x23
|
||||||
|
#define IP5306_REG_CHG_4 0x24
|
||||||
|
#define IP5306_REG_READ_0 0x70
|
||||||
|
#define IP5306_REG_READ_1 0x71
|
||||||
|
#define IP5306_REG_READ_2 0x72
|
||||||
|
#define IP5306_REG_READ_3 0x77
|
||||||
|
#define IP5306_REG_READ_4 0x78
|
||||||
|
|
||||||
|
#define IP5306_GetKeyOffEnabled() ip5306_get_bits(IP5306_REG_SYS_0, 0, 1)
|
||||||
|
#define IP5306_SetKeyOffEnabled(v) ip5306_set_bits(IP5306_REG_SYS_0, 0, 1, v)//0:dis,*1:en
|
||||||
|
|
||||||
|
#define IP5306_GetBoostOutputEnabled() ip5306_get_bits(IP5306_REG_SYS_0, 1, 1)
|
||||||
|
#define IP5306_SetBoostOutputEnabled(v) ip5306_set_bits(IP5306_REG_SYS_0, 1, 1, v)//*0:dis,1:en
|
||||||
|
|
||||||
|
#define IP5306_GetPowerOnLoadEnabled() ip5306_get_bits(IP5306_REG_SYS_0, 2, 1)
|
||||||
|
#define IP5306_SetPowerOnLoadEnabled(v) ip5306_set_bits(IP5306_REG_SYS_0, 2, 1, v)//0:dis,*1:en
|
||||||
|
|
||||||
|
#define IP5306_GetChargerEnabled() ip5306_get_bits(IP5306_REG_SYS_0, 4, 1)
|
||||||
|
#define IP5306_SetChargerEnabled(v) ip5306_set_bits(IP5306_REG_SYS_0, 4, 1, v)//0:dis,*1:en
|
||||||
|
|
||||||
|
#define IP5306_GetBoostEnabled() ip5306_get_bits(IP5306_REG_SYS_0, 5, 1)
|
||||||
|
#define IP5306_SetBoostEnabled(v) ip5306_set_bits(IP5306_REG_SYS_0, 5, 1, v)//0:dis,*1:en
|
||||||
|
|
||||||
|
#define IP5306_GetLowBatShutdownEnable() ip5306_get_bits(IP5306_REG_SYS_1, 0, 1)
|
||||||
|
#define IP5306_SetLowBatShutdownEnable(v) ip5306_set_bits(IP5306_REG_SYS_1, 0, 1, v)//0:dis,*1:en
|
||||||
|
|
||||||
|
#define IP5306_GetBoostAfterVin() ip5306_get_bits(IP5306_REG_SYS_1, 2, 1)
|
||||||
|
#define IP5306_SetBoostAfterVin(v) ip5306_set_bits(IP5306_REG_SYS_1, 2, 1, v)//0:Closed, *1:Open
|
||||||
|
|
||||||
|
#define IP5306_GetShortPressBoostSwitchEnable() ip5306_get_bits(IP5306_REG_SYS_1, 5, 1)
|
||||||
|
#define IP5306_SetShortPressBoostSwitchEnable(v) ip5306_set_bits(IP5306_REG_SYS_1, 5, 1, v)//*0:disabled, 1:enabled
|
||||||
|
|
||||||
|
#define IP5306_GetFlashlightClicks() ip5306_get_bits(IP5306_REG_SYS_1, 6, 1)
|
||||||
|
#define IP5306_SetFlashlightClicks(v) ip5306_set_bits(IP5306_REG_SYS_1, 6, 1, v)//*0:short press twice, 1:long press
|
||||||
|
|
||||||
|
#define IP5306_GetBoostOffClicks() ip5306_get_bits(IP5306_REG_SYS_1, 7, 1)
|
||||||
|
#define IP5306_SetBoostOffClicks(v) ip5306_set_bits(IP5306_REG_SYS_1, 7, 1, v)//*0:long press, 1:short press twice
|
||||||
|
|
||||||
|
#define IP5306_GetLightLoadShutdownTime() ip5306_get_bits(IP5306_REG_SYS_2, 2, 2)
|
||||||
|
#define IP5306_SetLightLoadShutdownTime(v) ip5306_set_bits(IP5306_REG_SYS_2, 2, 2, v)//0:8s, *1:32s, 2:16s, 3:64s
|
||||||
|
|
||||||
|
#define IP5306_GetLongPressTime() ip5306_get_bits(IP5306_REG_SYS_2, 4, 1)
|
||||||
|
#define IP5306_SetLongPressTime(v) ip5306_set_bits(IP5306_REG_SYS_2, 4, 1, v)//*0:2s, 1:3s
|
||||||
|
|
||||||
|
#define IP5306_GetChargingFullStopVoltage() ip5306_get_bits(IP5306_REG_CHG_0, 0, 2)
|
||||||
|
#define IP5306_SetChargingFullStopVoltage(v) ip5306_set_bits(IP5306_REG_CHG_0, 0, 2, v)//0:4.14V, *1:4.17V, 2:4.185V, 3:4.2V (values are for charge cutoff voltage 4.2V, 0 or 1 is recommended)
|
||||||
|
|
||||||
|
#define IP5306_GetChargeUnderVoltageLoop() ip5306_get_bits(IP5306_REG_CHG_1, 2, 3) //Automatically adjust the charging current when the voltage of VOUT is greater than the set value
|
||||||
|
#define IP5306_SetChargeUnderVoltageLoop(v) ip5306_set_bits(IP5306_REG_CHG_1, 2, 3, v)//Vout=4.45V + (v * 0.05V) (default 4.55V) //When charging at the maximum current, the charge is less than the set value. Slowly reducing the charging current to maintain this voltage
|
||||||
|
|
||||||
|
#define IP5306_GetEndChargeCurrentDetection() ip5306_get_bits(IP5306_REG_CHG_1, 6, 2)
|
||||||
|
#define IP5306_SetEndChargeCurrentDetection(v) ip5306_set_bits(IP5306_REG_CHG_1, 6, 2, v)//0:200mA, 1:400mA, *2:500mA, 3:600mA
|
||||||
|
|
||||||
|
#define IP5306_GetVoltagePressure() ip5306_get_bits(IP5306_REG_CHG_2, 0, 2)
|
||||||
|
#define IP5306_SetVoltagePressure(v) ip5306_set_bits(IP5306_REG_CHG_2, 0, 2, v)//0:none, 1:14mV, *2:28mV, 3:42mV (28mV recommended for 4.2V)
|
||||||
|
|
||||||
|
#define IP5306_GetChargeCutoffVoltage() ip5306_get_bits(IP5306_REG_CHG_2, 2, 2)
|
||||||
|
#define IP5306_SetChargeCutoffVoltage(v) ip5306_set_bits(IP5306_REG_CHG_2, 2, 2, v)//*0:4.2V, 1:4.3V, 2:4.35V, 3:4.4V
|
||||||
|
|
||||||
|
#define IP5306_GetChargeCCLoop() ip5306_get_bits(IP5306_REG_CHG_3, 5, 1)
|
||||||
|
#define IP5306_SetChargeCCLoop(v) ip5306_set_bits(IP5306_REG_CHG_3, 5, 1, v)//0:BAT, *1:VIN
|
||||||
|
|
||||||
|
#define IP5306_GetVinCurrent() ip5306_get_bits(IP5306_REG_CHG_4, 0, 5)
|
||||||
|
#define IP5306_SetVinCurrent(v) ip5306_set_bits(IP5306_REG_CHG_4, 0, 5, v)//ImA=(v*100)+50 (default 2250mA)
|
||||||
|
|
||||||
|
#define IP5306_GetShortPressDetected() ip5306_get_bits(IP5306_REG_READ_3, 0, 1)
|
||||||
|
#define IP5306_ClearShortPressDetected() ip5306_set_bits(IP5306_REG_READ_3, 0, 1, 1)
|
||||||
|
|
||||||
|
#define IP5306_GetLongPressDetected() ip5306_get_bits(IP5306_REG_READ_3, 1, 1)
|
||||||
|
#define IP5306_ClearLongPressDetected() ip5306_set_bits(IP5306_REG_READ_3, 1, 1, 1)
|
||||||
|
|
||||||
|
#define IP5306_GetDoubleClickDetected() ip5306_get_bits(IP5306_REG_READ_3, 2, 1)
|
||||||
|
#define IP5306_ClearDoubleClickDetected() ip5306_set_bits(IP5306_REG_READ_3, 2, 1, 1)
|
||||||
|
|
||||||
|
#define IP5306_GetPowerSource() ip5306_get_bits(IP5306_REG_READ_0, 3, 1)//0:BAT, 1:VIN
|
||||||
|
#define IP5306_GetBatteryFull() ip5306_get_bits(IP5306_REG_READ_1, 3, 1)//0:CHG/DIS, 1:FULL
|
||||||
|
#define IP5306_GetLevelLeds() ((~ip5306_get_bits(IP5306_REG_READ_4, 4, 4)) & 0x0F)//LED[0-4] State (inverted)
|
||||||
|
#define IP5306_GetOutputLoad() ip5306_get_bits(IP5306_REG_READ_2, 2, 1)//0:heavy, 1:light
|
||||||
|
|
||||||
|
#define IP5306_LEDS2PCT(byte) \
|
||||||
|
((byte & 0x01 ? 25 : 0) + \
|
||||||
|
(byte & 0x02 ? 25 : 0) + \
|
||||||
|
(byte & 0x04 ? 25 : 0) + \
|
||||||
|
(byte & 0x08 ? 25 : 0))
|
||||||
|
|
||||||
|
int ip5306_get_reg(uint8_t reg);
|
||||||
|
int ip5306_set_reg(uint8_t reg, uint8_t value);
|
||||||
|
uint8_t ip5306_get_bits(uint8_t reg, uint8_t index, uint8_t bits);
|
||||||
|
void ip5306_set_bits(uint8_t reg, uint8_t index, uint8_t bits, uint8_t value);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
1
lib/JC_Button
Submodule
1
lib/JC_Button
Submodule
Submodule lib/JC_Button added at f379405f8a
38
main.cpp
38
main.cpp
@@ -41,6 +41,7 @@
|
|||||||
#include "CO2_sensor.h"
|
#include "CO2_sensor.h"
|
||||||
#include "VOC_sensor.h"
|
#include "VOC_sensor.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
|
#include "esp_ota.h"
|
||||||
|
|
||||||
/*--------------------------- Program ---------------------------------------*/
|
/*--------------------------- Program ---------------------------------------*/
|
||||||
/**
|
/**
|
||||||
@@ -52,17 +53,33 @@ void setup()
|
|||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.print("Air Quality Sensor starting up, v");
|
Serial.print("Air Quality Sensor starting up, v");
|
||||||
Serial.println(VERSION);
|
Serial.println(VERSION);
|
||||||
|
ProgressbarVisible(true);
|
||||||
|
initLCD();
|
||||||
|
setOTAProgress(10);
|
||||||
|
|
||||||
digitalWrite(5, false);
|
|
||||||
|
|
||||||
initWifi();
|
|
||||||
initMQTT();
|
|
||||||
initSensor();
|
|
||||||
initParticles();
|
|
||||||
initCO2sensor();
|
|
||||||
initVOCsensor();
|
|
||||||
//initLCD();
|
|
||||||
initButtons();
|
initButtons();
|
||||||
|
setOTAProgress(20);
|
||||||
|
initWifi();
|
||||||
|
setOTAProgress(30);
|
||||||
|
|
||||||
|
initEspOta();
|
||||||
|
setOTAProgress(40);
|
||||||
|
|
||||||
|
initMQTT();
|
||||||
|
setOTAProgress(50);
|
||||||
|
|
||||||
|
initSensor();
|
||||||
|
setOTAProgress(60);
|
||||||
|
|
||||||
|
initParticles();
|
||||||
|
setOTAProgress(70);
|
||||||
|
|
||||||
|
initCO2sensor();
|
||||||
|
setOTAProgress(80);
|
||||||
|
|
||||||
|
initVOCsensor();
|
||||||
|
setOTAProgress(90);
|
||||||
|
ProgressbarVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,6 +92,7 @@ void loop()
|
|||||||
handleVOCsensor();
|
handleVOCsensor();
|
||||||
handleButtons();
|
handleButtons();
|
||||||
handleSensor();
|
handleSensor();
|
||||||
//handleLCD();
|
handleLCD();
|
||||||
handleMQTT();
|
handleMQTT();
|
||||||
|
handleEspOta();
|
||||||
}
|
}
|
||||||
|
|||||||
1
mqtt.cpp
1
mqtt.cpp
@@ -87,6 +87,7 @@ bool initWifi()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Connect to wifi
|
// Connect to wifi
|
||||||
|
WiFi.setHostname(HOST_NAME);
|
||||||
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
|
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
|
||||||
|
|
||||||
// Wait for connection set amount of intervals
|
// Wait for connection set amount of intervals
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ char g_command_topic[50]; // MQTT topic for receiving commands
|
|||||||
#define PMS_STATE_READY 2 // Warmed up, ready to give data
|
#define PMS_STATE_READY 2 // Warmed up, ready to give data
|
||||||
#define PMSMAX 50
|
#define PMSMAX 50
|
||||||
#define PSMMIN 0
|
#define PSMMIN 0
|
||||||
#define PPDMAX 2000
|
#define PPDMAX 3000
|
||||||
uint8_t g_pms_state = PMS_STATE_WAKING_UP;
|
uint8_t g_pms_state = PMS_STATE_WAKING_UP;
|
||||||
|
|
||||||
uint32_t g_pms_state_start = 0; // Timestamp when PMS state last changed
|
uint32_t g_pms_state_start = 0; // Timestamp when PMS state last changed
|
||||||
|
|||||||
@@ -21,8 +21,12 @@ lib_deps =
|
|||||||
knolleary/PubSubClient
|
knolleary/PubSubClient
|
||||||
robtillaart/RunningMedian
|
robtillaart/RunningMedian
|
||||||
bodmer/Tjpg_decoder
|
bodmer/Tjpg_decoder
|
||||||
adafruit/Adafruit SCD30
|
; adafruit/Adafruit SCD30
|
||||||
adafruit/Adafruit BusIO
|
; adafruit/Adafruit BusIO
|
||||||
|
; adafruit/Adafruit SGP30 Sensor
|
||||||
|
http://192.168.2.3:3000/libs/JCButton.git
|
||||||
|
sparkfun/SparkFun SCD30 Arduino Library@^1.0.13
|
||||||
|
sparkfun/SparkFun SGP30 Arduino Library@^1.0.5
|
||||||
|
|
||||||
[env:esp32]
|
[env:esp32]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
@@ -32,4 +36,15 @@ monitor_speed = 115200
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps_builtin}
|
${common.lib_deps_builtin}
|
||||||
${common.lib_deps}
|
${common.lib_deps}
|
||||||
adafruit/Adafruit SGP30 Sensor@^2.0.0
|
|
||||||
|
|
||||||
|
[env:esp32_ota]
|
||||||
|
platform = espressif32
|
||||||
|
board = esp-wrover-kit
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
lib_deps =
|
||||||
|
${common.lib_deps_builtin}
|
||||||
|
${common.lib_deps}
|
||||||
|
upload_protocol = espota
|
||||||
|
upload_port = 192.168.2.165
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ void initSensor(void)
|
|||||||
void handleSensor(void)
|
void handleSensor(void)
|
||||||
{
|
{
|
||||||
publishAll();
|
publishAll();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AQSSensor* getSensor(sensor_e sensor)
|
AQSSensor* getSensor(sensor_e sensor)
|
||||||
|
|||||||
31
sensor.h
31
sensor.h
@@ -42,6 +42,7 @@ class AQSSensor
|
|||||||
bool _publish = false;
|
bool _publish = false;
|
||||||
const uint32_t _scaleMin;
|
const uint32_t _scaleMin;
|
||||||
const uint32_t _scaleMax;
|
const uint32_t _scaleMax;
|
||||||
|
bool _valid;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AQSSensor(String name, sensor_e sensor, String unit,
|
AQSSensor(String name, sensor_e sensor, String unit,
|
||||||
@@ -58,14 +59,23 @@ public:
|
|||||||
sprintf(_topic, "Sensors/%s/%s", deviceID.c_str(), name.c_str());
|
sprintf(_topic, "Sensors/%s/%s", deviceID.c_str(), name.c_str());
|
||||||
sprintf(_topic_1h, "Sensors/%s/%s/1h/", deviceID.c_str(), name.c_str());
|
sprintf(_topic_1h, "Sensors/%s/%s/1h/", deviceID.c_str(), name.c_str());
|
||||||
sprintf(_topic_24h, "Sensors/%s/%s/24h/", deviceID.c_str(), name.c_str());
|
sprintf(_topic_24h, "Sensors/%s/%s/24h/", deviceID.c_str(), name.c_str());
|
||||||
|
_valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void publish(void)
|
void publish(void)
|
||||||
{
|
{
|
||||||
_publish = true;
|
if (_valid)
|
||||||
|
{
|
||||||
|
_publish = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.printf("Sensor %s : Not published (invalid)\n", _name.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getName(void)
|
String
|
||||||
|
getName(void)
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
@@ -88,9 +98,18 @@ public:
|
|||||||
|
|
||||||
virtual void set(uint32_t value)
|
virtual void set(uint32_t value)
|
||||||
{
|
{
|
||||||
_value = value;
|
if ((value > _scaleMin) && (value < _scaleMax))
|
||||||
_average1h.add(_value);
|
{
|
||||||
_average24h.add(_value);
|
_value = value;
|
||||||
|
_average1h.add(_value);
|
||||||
|
_average24h.add(_value);
|
||||||
|
_valid = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.printf("Sensor %s set(%d): value out of bounds\n", _name.c_str(), _value);
|
||||||
|
_valid = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t value() { return _value; }
|
uint32_t value() { return _value; }
|
||||||
@@ -105,7 +124,7 @@ public:
|
|||||||
|
|
||||||
sensor_e getSensor(void) { return _sensor; }
|
sensor_e getSensor(void) { return _sensor; }
|
||||||
|
|
||||||
String getUnit(void) { return _unit;}
|
String getUnit(void) { return _unit; }
|
||||||
|
|
||||||
uint32_t getMin(void) { return _scaleMin; }
|
uint32_t getMin(void) { return _scaleMin; }
|
||||||
uint32_t getMax(void) { return _scaleMax; }
|
uint32_t getMax(void) { return _scaleMax; }
|
||||||
|
|||||||
Reference in New Issue
Block a user