This commit is contained in:
BIN
.vscode/.BROWSE.C_CPP.DB
vendored
BIN
.vscode/.BROWSE.C_CPP.DB
vendored
Binary file not shown.
8
.vscode/c_cpp_properties.json
vendored
8
.vscode/c_cpp_properties.json
vendored
@ -7,9 +7,10 @@
|
||||
"name": "Win32",
|
||||
"includePath": [
|
||||
"c:/Users/furyf/Dev/deskcontrol/src",
|
||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/DHT sensor library for ESPx_ID2029",
|
||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/Homie/src",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266mDNS/src",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/Ticker",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/DNSServer/src",
|
||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/ESP Async WebServer_ID306/src",
|
||||
@ -24,7 +25,6 @@
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/cores/esp8266",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/tools/sdk/lwip2/include",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/variants/nodemcu",
|
||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/Syslog_ID1506/src",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ArduinoOTA",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/EEPROM",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266AVRISP/src",
|
||||
@ -55,9 +55,10 @@
|
||||
"databaseFilename": "${workspaceRoot}/.vscode/.browse.c_cpp.db",
|
||||
"path": [
|
||||
"c:/Users/furyf/Dev/deskcontrol/src",
|
||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/DHT sensor library for ESPx_ID2029",
|
||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/Homie/src",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266mDNS/src",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPClient/src",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/Ticker",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/DNSServer/src",
|
||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/ESP Async WebServer_ID306/src",
|
||||
@ -72,7 +73,6 @@
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/cores/esp8266",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/tools/sdk/lwip2/include",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/variants/nodemcu",
|
||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/Syslog_ID1506/src",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ArduinoOTA",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/EEPROM",
|
||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266AVRISP/src",
|
||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"terminal.integrated.env.windows": {
|
||||
"PATH": "C:\\Program Files (x86)\\STMicroelectronics\\st_toolset\\asm;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files (x86)\\STMicroelectronics\\STM32 ST-LINK Utility\\ST-LINK Utility;C:\\Program Files\\doxygen\\bin;C:\\Program Files (x86)\\QuickTime\\QTSystem\\;C:\\Users\\furyf\\scoop\\apps\\nodejs\\current\\bin;C:\\Users\\furyf\\scoop\\apps\\nodejs\\current;C:\\Users\\furyf\\go\\bin;C:\\Users\\furyf\\scoop\\apps\\composer\\current\\home\\vendor\\bin;C:\\Users\\furyf\\scoop\\apps\\ruby\\current\\gems\\bin;C:\\Users\\furyf\\scoop\\apps\\ruby\\current\\bin;C:\\Users\\furyf\\scoop\\apps\\python27\\current\\scripts;C:\\Users\\furyf\\scoop\\apps\\latex\\current\\texmfs\\install\\miktex\\bin;C:\\Users\\furyf\\scoop\\apps\\gcc\\current\\bin;C:\\Users\\furyf\\scoop\\apps\\nmap\\current\\bin;C:\\Users\\furyf\\AppData\\Local\\Programs\\Python\\Launcher\\;C:\\Users\\furyf\\scoop\\shims;C:\\Users\\furyf\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\furyf\\scoop\\apps\\msys\\current\\bin;C:\\Users\\furyf\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\System\\PATH;%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files (x86)\\STMicroelectronics\\st_toolset\\asm;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files (x86)\\STMicroelectronics\\STM32 ST-LINK Utility\\ST-LINK Utility;C:\\Program Files\\doxygen\\bin;C:\\Program Files (x86)\\QuickTime\\QTSystem\\;C:\\Users\\furyf\\scoop\\apps\\nodejs\\current\\bin;C:\\Users\\furyf\\scoop\\apps\\nodejs\\current;C:\\Users\\furyf\\go\\bin;C:\\Users\\furyf\\scoop\\apps\\composer\\current\\home\\vendor\\bin;C:\\Users\\furyf\\scoop\\apps\\ruby\\current\\gems\\bin;C:\\Users\\furyf\\scoop\\apps\\ruby\\current\\bin;C:\\Users\\furyf\\scoop\\apps\\python27\\current\\scripts;C:\\Users\\furyf\\scoop\\apps\\latex\\current\\texmfs\\install\\miktex\\bin;C:\\Users\\furyf\\scoop\\apps\\gcc\\current\\bin;C:\\Users\\furyf\\scoop\\apps\\nmap\\current\\bin;C:\\Users\\furyf\\AppData\\Local\\Programs\\Python\\Launcher\\;C:\\Users\\furyf\\scoop\\shims;C:\\Users\\furyf\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\furyf\\scoop\\apps\\msys\\current\\bin;C:\\Users\\furyf\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\System\\PATH;%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps",
|
||||
"PATH": "C:\\Program Files (x86)\\STMicroelectronics\\st_toolset\\asm;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files (x86)\\STMicroelectronics\\STM32 ST-LINK Utility\\ST-LINK Utility;C:\\Program Files\\doxygen\\bin;C:\\Program Files (x86)\\QuickTime\\QTSystem\\;C:\\Users\\furyf\\scoop\\apps\\ruby\\current\\gems\\bin;C:\\Users\\furyf\\scoop\\apps\\ruby\\current\\bin;C:\\Users\\furyf\\scoop\\apps\\nodejs\\current\\bin;C:\\Users\\furyf\\scoop\\apps\\nodejs\\current;C:\\Users\\furyf\\go\\bin;C:\\Users\\furyf\\scoop\\apps\\composer\\current\\home\\vendor\\bin;C:\\Users\\furyf\\scoop\\apps\\python27\\current\\scripts;C:\\Users\\furyf\\scoop\\apps\\latex\\current\\texmfs\\install\\miktex\\bin;C:\\Users\\furyf\\scoop\\apps\\gcc\\current\\bin;C:\\Users\\furyf\\scoop\\apps\\nmap\\current\\bin;C:\\Users\\furyf\\AppData\\Local\\Programs\\Python\\Launcher\\;C:\\Users\\furyf\\scoop\\shims;C:\\Users\\furyf\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\furyf\\scoop\\apps\\msys\\current\\bin;C:\\Users\\furyf\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\System\\PATH;%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files (x86)\\STMicroelectronics\\st_toolset\\asm;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files (x86)\\STMicroelectronics\\STM32 ST-LINK Utility\\ST-LINK Utility;C:\\Program Files\\doxygen\\bin;C:\\Program Files (x86)\\QuickTime\\QTSystem\\;C:\\Users\\furyf\\scoop\\apps\\ruby\\current\\gems\\bin;C:\\Users\\furyf\\scoop\\apps\\ruby\\current\\bin;C:\\Users\\furyf\\scoop\\apps\\nodejs\\current\\bin;C:\\Users\\furyf\\scoop\\apps\\nodejs\\current;C:\\Users\\furyf\\go\\bin;C:\\Users\\furyf\\scoop\\apps\\composer\\current\\home\\vendor\\bin;C:\\Users\\furyf\\scoop\\apps\\python27\\current\\scripts;C:\\Users\\furyf\\scoop\\apps\\latex\\current\\texmfs\\install\\miktex\\bin;C:\\Users\\furyf\\scoop\\apps\\gcc\\current\\bin;C:\\Users\\furyf\\scoop\\apps\\nmap\\current\\bin;C:\\Users\\furyf\\AppData\\Local\\Programs\\Python\\Launcher\\;C:\\Users\\furyf\\scoop\\shims;C:\\Users\\furyf\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\furyf\\scoop\\apps\\msys\\current\\bin;C:\\Users\\furyf\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\System\\PATH;%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps",
|
||||
"PLATFORMIO_CALLER": "vscode"
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ framework = arduino
|
||||
upload_speed=921600
|
||||
|
||||
build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
||||
lib_deps = https://github.com/homieiot/homie-esp8266.git#develop-v3
|
||||
lib_deps = https://github.com/homieiot/homie-esp8266.git#develop-v3, DHT sensor library for ESPx
|
||||
|
||||
[env:nodemcu]
|
||||
board = nodemcu
|
||||
|
27
src/main.cpp
27
src/main.cpp
@ -1,11 +1,16 @@
|
||||
#include <Homie.h>
|
||||
#include <WiFiUdp.h>
|
||||
|
||||
#include "DHTesp.h"
|
||||
DHTesp dht;
|
||||
const int TEMPERATURE_INTERVAL = 10;
|
||||
unsigned long lastTemperatureSent = 0;
|
||||
|
||||
const int PIN_RELAY = D1;
|
||||
#define OUTPUT_SET(x) digitalWrite(PIN_RELAY, x ? LOW : HIGH)
|
||||
unsigned int timer = 0;
|
||||
unsigned int next_timer_update = 0;
|
||||
HomieNode powerNode("power", "Power", "switch");
|
||||
HomieNode temperatureNode("temperature", "Temperature", "temperature");
|
||||
|
||||
bool powerStateHandler(const HomieRange& range, const String& value) {
|
||||
if (value != "on" && value != "off") return false;
|
||||
@ -43,6 +48,9 @@ void setupHandler() {
|
||||
OUTPUT_SET(false);
|
||||
powerNode.setProperty("state").send("off");
|
||||
powerNode.setProperty("timer").send("0");
|
||||
|
||||
|
||||
dht.setup(D1, DHTesp::DHT11); // Connect DHT sensor to GPIO 17
|
||||
}
|
||||
|
||||
void loopHandler() {
|
||||
@ -64,8 +72,18 @@ void loopHandler() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (millis() - lastTemperatureSent >= TEMPERATURE_INTERVAL * 1000UL || lastTemperatureSent == 0)
|
||||
{
|
||||
float humidity = dht.getHumidity();
|
||||
float temperature = dht.getTemperature();
|
||||
|
||||
Homie.getLogger() << "Temperature: " << temperature << "°C " << humidity << "% Humidty" << endl;
|
||||
temperatureNode.setProperty("temperature").send(String(temperature));
|
||||
temperatureNode.setProperty("humidity").send(String(humidity));
|
||||
lastTemperatureSent = millis();
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
@ -75,8 +93,13 @@ void setup() {
|
||||
Homie.disableResetTrigger();
|
||||
powerNode.advertise("state").settable(powerStateHandler);
|
||||
powerNode.advertise("timer").settable(powerTimerHandler);
|
||||
|
||||
temperatureNode.advertise("humidity");
|
||||
temperatureNode.advertise("temperature");
|
||||
|
||||
Homie.setSetupFunction(setupHandler);
|
||||
Homie.setLoopFunction(loopHandler);
|
||||
|
||||
Homie.setup();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user