Compare commits
17 Commits
8387a0610b
...
master
Author | SHA1 | Date | |
---|---|---|---|
0067a0b8a9 | |||
602ec3add6 | |||
be24ee7816 | |||
b927b1fdb9 | |||
d0f3845dc5 | |||
e9e0c17a8a | |||
2966170165 | |||
6be0baf301 | |||
cee415446a | |||
91a29db8ed | |||
7a37df2fff | |||
b5498b7173 | |||
0287456f1e | |||
019592f1ad | |||
c1c07a4003 | |||
|
cf380443a7 | ||
|
b8e68bed7c |
@ -21,5 +21,12 @@ steps:
|
|||||||
base_url: https://code.jcktrue.dk
|
base_url: https://code.jcktrue.dk
|
||||||
files:
|
files:
|
||||||
- .pio/build/nodemcu/firmware.bin
|
- .pio/build/nodemcu/firmware.bin
|
||||||
|
checksum:
|
||||||
|
- md5
|
||||||
|
- sha1
|
||||||
|
- sha256
|
||||||
|
- sha512
|
||||||
|
- adler32
|
||||||
|
- crc32
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
.pioenvs
|
|
||||||
.piolibdeps
|
|
||||||
.pio
|
.pio
|
||||||
data/homie/config.json
|
data/homie/config.json
|
||||||
nbproject
|
.vscode
|
||||||
|
output/doxygen
|
||||||
|
BIN
.vscode/.BROWSE.C_CPP.DB
vendored
BIN
.vscode/.BROWSE.C_CPP.DB
vendored
Binary file not shown.
129
.vscode/c_cpp_properties.json
vendored
129
.vscode/c_cpp_properties.json
vendored
@ -1,129 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "!!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"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/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",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/Hash/src",
|
|
||||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/Bounce2_ID1106/src",
|
|
||||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/AsyncMqttClient_ID346/src",
|
|
||||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/ESPAsyncTCP_ID305/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src",
|
|
||||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/ArduinoJson_ID64/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/tools/sdk/include",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/include",
|
|
||||||
"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/.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",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPUpdateServer/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266LLMNR",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266NetBIOS",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266SSDP",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266SdFat/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WebServer/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFiMesh/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266httpUpdate/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/Ethernet/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/GDBStub/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/SD/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/SDFS/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/SPI",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/SPISlave/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/Servo/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/SoftwareSerial/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/TFT_Touch_Shield_V2",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/Wire",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/esp8266/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/tool-unity",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"browse": {
|
|
||||||
"limitSymbolsToIncludedHeaders": true,
|
|
||||||
"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/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",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/Hash/src",
|
|
||||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/Bounce2_ID1106/src",
|
|
||||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/AsyncMqttClient_ID346/src",
|
|
||||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/ESPAsyncTCP_ID305/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src",
|
|
||||||
"c:/Users/furyf/Dev/deskcontrol/.pio/libdeps/nodemcu/ArduinoJson_ID64/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/tools/sdk/include",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/include",
|
|
||||||
"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/.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",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266HTTPUpdateServer/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266LLMNR",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266NetBIOS",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266SSDP",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266SdFat/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WebServer/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFiMesh/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266httpUpdate/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/Ethernet/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/GDBStub/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/SD/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/SDFS/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/SPI",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/SPISlave/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/Servo/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/SoftwareSerial/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/TFT_Touch_Shield_V2",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/Wire",
|
|
||||||
"C:/Users/furyf/.platformio/packages/framework-arduinoespressif8266/libraries/esp8266/src",
|
|
||||||
"C:/Users/furyf/.platformio/packages/tool-unity",
|
|
||||||
""
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"defines": [
|
|
||||||
"PLATFORMIO=40000",
|
|
||||||
"ESP8266",
|
|
||||||
"ARDUINO_ARCH_ESP8266",
|
|
||||||
"ARDUINO_ESP8266_NODEMCU",
|
|
||||||
"PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY",
|
|
||||||
"F_CPU=80000000L",
|
|
||||||
"__ets__",
|
|
||||||
"ICACHE_FLASH",
|
|
||||||
"ARDUINO=10805",
|
|
||||||
"ARDUINO_BOARD=\"PLATFORMIO_NODEMCU\"",
|
|
||||||
"FLASHMODE_QIO",
|
|
||||||
"LWIP_OPEN_SRC",
|
|
||||||
"NONOSDK221=1",
|
|
||||||
"TCP_MSS=536",
|
|
||||||
"LWIP_FEATURES=1",
|
|
||||||
"LWIP_IPV6=0",
|
|
||||||
"VTABLES_IN_FLASH",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"intelliSenseMode": "clang-x64",
|
|
||||||
"cStandard": "c99",
|
|
||||||
"cppStandard": "c++11",
|
|
||||||
"compilerPath": "\"C:/Users/furyf/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-gcc.exe\" -mlongcalls -mtext-section-literals"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
7
.vscode/extensions.json
vendored
7
.vscode/extensions.json
vendored
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
|
||||||
// for the documentation about the extensions.json format
|
|
||||||
"recommendations": [
|
|
||||||
"platformio.platformio-ide"
|
|
||||||
]
|
|
||||||
}
|
|
32
.vscode/launch.json
vendored
32
.vscode/launch.json
vendored
@ -1,32 +0,0 @@
|
|||||||
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
|
|
||||||
|
|
||||||
// PIO Unified Debugger
|
|
||||||
//
|
|
||||||
// Documentation: https://docs.platformio.org/page/plus/debugging.html
|
|
||||||
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
|
|
||||||
|
|
||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "platformio-debug",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "PIO Debug",
|
|
||||||
"executable": "c:/Users/furyf/Dev/deskcontrol/.pio/build/nodemcu/firmware.elf",
|
|
||||||
"toolchainBinDir": "C:/Users/furyf/.platformio/packages/toolchain-xtensa/bin",
|
|
||||||
"preLaunchTask": {
|
|
||||||
"type": "PlatformIO",
|
|
||||||
"task": "Pre-Debug"
|
|
||||||
},
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "platformio-debug",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "PIO Debug (skip Pre-Debug)",
|
|
||||||
"executable": "c:/Users/furyf/Dev/deskcontrol/.pio/build/nodemcu/firmware.elf",
|
|
||||||
"toolchainBinDir": "C:/Users/furyf/.platformio/packages/toolchain-xtensa/bin",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"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\\scoop\\apps\\latex\\current\\texmfs\\install\\miktex\\bin\\x64;C:\\Users\\furyf\\scoop\\apps\\latex\\current\\texmfs\\install\\miktex\\bin;C:\\Users\\furyf\\scoop\\apps\\ruby\\current\\gems\\bin;C:\\Users\\furyf\\scoop\\apps\\ruby\\current\\bin;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\\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\\scoop\\apps\\latex\\current\\texmfs\\install\\miktex\\bin\\x64;C:\\Users\\furyf\\scoop\\apps\\latex\\current\\texmfs\\install\\miktex\\bin;C:\\Users\\furyf\\scoop\\apps\\ruby\\current\\gems\\bin;C:\\Users\\furyf\\scoop\\apps\\ruby\\current\\bin;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\\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"
|
|
||||||
}
|
|
||||||
}
|
|
3
Makefile
3
Makefile
@ -4,3 +4,6 @@ build:
|
|||||||
otaupload:
|
otaupload:
|
||||||
pip install -r .pio/libdeps/nodemcu/Homie/scripts/ota_updater/requirements.txt
|
pip install -r .pio/libdeps/nodemcu/Homie/scripts/ota_updater/requirements.txt
|
||||||
python .pio/libdeps/nodemcu/Homie/scripts/ota_updater/ota_updater.py -l mqtt.jcktrue.dk -i 18fe34f2f987 .pio/build/nodemcu/firmware.bin
|
python .pio/libdeps/nodemcu/Homie/scripts/ota_updater/ota_updater.py -l mqtt.jcktrue.dk -i 18fe34f2f987 .pio/build/nodemcu/firmware.bin
|
||||||
|
|
||||||
|
docs:
|
||||||
|
doxygen .\.doxygen
|
||||||
|
36
include/config.h
Normal file
36
include/config.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* \class Config
|
||||||
|
*/
|
||||||
|
#ifndef CONFIG_H
|
||||||
|
#define CONFIG_H
|
||||||
|
|
||||||
|
#ifndef VERSION
|
||||||
|
//SEMVER style version
|
||||||
|
/**
|
||||||
|
* \brief Version string.
|
||||||
|
* Update as needed. Formatted as SEMVER style string.
|
||||||
|
* See https://semver.org/ for more information.
|
||||||
|
*/
|
||||||
|
#define VERSION "0.4.5-Dev"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the default Serial baudrate in bits/seconds
|
||||||
|
*/
|
||||||
|
#define CONFIG_SERIAL_BAUDRATE 115200
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin ID of the output relay
|
||||||
|
*/
|
||||||
|
#define CONFIG_IO_RELAY D1
|
||||||
|
/**
|
||||||
|
* Pin ID of the DHT11 temperature sensor
|
||||||
|
*/
|
||||||
|
#define CONFIG_IO_DHT11 D2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interval at which the tempreature is sent in seconds
|
||||||
|
*/
|
||||||
|
#define CONFIG_TEMPERATURE_SEND_INTERVAL 60
|
||||||
|
#endif
|
0
output/FOR_GENERATED_FILES
Normal file
0
output/FOR_GENERATED_FILES
Normal file
@ -1,30 +1,11 @@
|
|||||||
#
|
|
||||||
# Project Configuration File
|
|
||||||
#
|
|
||||||
# A detailed documentation with the EXAMPLES is located here:
|
|
||||||
# http://docs.platformio.org/en/latest/projectconf.html
|
|
||||||
#
|
|
||||||
|
|
||||||
# A sign `#` at the beginning of the line indicates a comment
|
|
||||||
# Comment lines are ignored.
|
|
||||||
|
|
||||||
# Simple and base environment
|
|
||||||
# [env:mybaseenv]
|
|
||||||
# platform = %INSTALLED_PLATFORM_NAME_HERE%
|
|
||||||
# framework =
|
|
||||||
# board =
|
|
||||||
#
|
|
||||||
# Automatic targets - enable auto-uploading
|
|
||||||
# targets = upload
|
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
platform = espressif8266
|
platform = espressif8266
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
|
||||||
upload_speed=921600
|
upload_speed=921600
|
||||||
|
|
||||||
build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY -DVERSION=${sysenv.DRONE_SEMVER}
|
||||||
lib_deps = https://github.com/homieiot/homie-esp8266.git#develop-v3, DHT sensor library for ESPx
|
lib_deps = https://github.com/homieiot/homie-esp8266.git#develop, DHT sensor library for ESPx, HomieLoggerNode
|
||||||
|
|
||||||
[env:nodemcu]
|
[env:nodemcu]
|
||||||
board = nodemcu
|
board = nodemcu
|
||||||
|
137
src/main.cpp
137
src/main.cpp
@ -1,35 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* \brief Entry point
|
||||||
|
*
|
||||||
|
* Deskcontrol is a simple on/off timer switch inteded for use with an ATX PSU.
|
||||||
|
* The theory of operation is turning on and off power by pulling the control line low/high while
|
||||||
|
* running of the 5V standby line.
|
||||||
|
*
|
||||||
|
* Additional features include support for a DHT11 to log the temperature.
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <Homie.h>
|
#include <Homie.h>
|
||||||
|
|
||||||
#include "DHTesp.h"
|
#include <LoggerNode.h>
|
||||||
DHTesp dht;
|
LoggerNode LN; ///<Instance of the LoggerNode library
|
||||||
const int TEMPERATURE_INTERVAL = 60;
|
|
||||||
unsigned long lastTemperatureSent = 0;
|
#include "DHTesp.h"
|
||||||
|
DHTesp dht; ///< Instance of the DHT temperature controller.
|
||||||
|
|
||||||
|
|
||||||
|
#define OUTPUT_SET(x) digitalWrite(CONFIG_IO_RELAY, x ? LOW : HIGH) ///< Macro for controlling the output state.
|
||||||
|
unsigned int timer = 0; ///< Remaining time when counting down.
|
||||||
|
unsigned int next_timer_update = 0; ///< Timer used to control when the timer value should be pushed to the server
|
||||||
|
|
||||||
const int PIN_RELAY = D1;
|
|
||||||
const int PIN_DHT11 = D2;
|
|
||||||
#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 powerNode("power", "Power", "switch");
|
||||||
HomieNode temperatureNode("temperature", "Temperature", "temperature");
|
HomieNode temperatureNode("temperature", "Temperature", "temperature");
|
||||||
|
|
||||||
bool powerStateHandler(const HomieRange& range, const String& value) {
|
/** Power state handler
|
||||||
if (value != "on" && value != "off") return false;
|
* Handles event on the power state MQTT node
|
||||||
|
* \param[in] range Currently unused
|
||||||
|
* \param[in] value New value of the power state. (Either "on" or off")
|
||||||
|
* \return False if input is invalid. Otherwise true.
|
||||||
|
*/
|
||||||
|
bool powerStateHandler(const HomieRange& range, const String& value)
|
||||||
|
{
|
||||||
|
if (value != "on" && value != "off")
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
powerNode.setProperty("state").send(value);
|
powerNode.setProperty("state").send(value);
|
||||||
powerNode.setProperty("timer").send("0");
|
powerNode.setProperty("timer").send("0");
|
||||||
timer = 0;
|
timer = 0;
|
||||||
if(value == "on") {
|
|
||||||
|
if(value == "on")
|
||||||
|
{
|
||||||
OUTPUT_SET(true);
|
OUTPUT_SET(true);
|
||||||
Homie.getLogger() << "Power is on" << endl;
|
LN.logf(__PRETTY_FUNCTION__, LoggerNode::INFO, "Power ON");
|
||||||
} else {
|
}
|
||||||
OUTPUT_SET(false);
|
else
|
||||||
Homie.getLogger() << "Power is off" << endl;
|
{
|
||||||
|
OUTPUT_SET(false); LN.logf(__PRETTY_FUNCTION__, LoggerNode::INFO, "Power OFF");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool powerTimerHandler(const HomieRange& range, const String& value) {
|
/**
|
||||||
|
* \brief powerTimer event handler.
|
||||||
|
* Handler for events on the powerTimer node.
|
||||||
|
* \param[in] range Currently unused.
|
||||||
|
* \param[in] value New value for the timer in minutes. ASCII representation of an integer from 1 to 120.
|
||||||
|
* \return False if input is invalid. Otherwise true.
|
||||||
|
*/
|
||||||
|
bool powerTimerHandler(const HomieRange& range, const String& value)
|
||||||
|
{
|
||||||
int settimer = value.toInt();
|
int settimer = value.toInt();
|
||||||
if(settimer == 0 || settimer > 120)
|
if(settimer == 0 || settimer > 120)
|
||||||
return false;
|
return false;
|
||||||
@ -38,23 +73,29 @@ bool powerTimerHandler(const HomieRange& range, const String& value) {
|
|||||||
next_timer_update = millis() + 60*1000;
|
next_timer_update = millis() + 60*1000;
|
||||||
powerNode.setProperty("timer").send(String(settimer));
|
powerNode.setProperty("timer").send(String(settimer));
|
||||||
powerNode.setProperty("state").send("on");
|
powerNode.setProperty("state").send("on");
|
||||||
Homie.getLogger() << "Power is on for " << settimer << "minutes" << endl;
|
LN.logf(__PRETTY_FUNCTION__, LoggerNode::INFO, "Power on for %d minutes", settimer);
|
||||||
OUTPUT_SET(true);
|
OUTPUT_SET(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
void setupHandler() {
|
* setupHandler. Comply with Homie interface
|
||||||
pinMode(PIN_RELAY, OUTPUT);
|
*/
|
||||||
|
void setupHandler()
|
||||||
|
{
|
||||||
|
pinMode(CONFIG_IO_RELAY, OUTPUT);
|
||||||
OUTPUT_SET(false);
|
OUTPUT_SET(false);
|
||||||
powerNode.setProperty("state").send("off");
|
powerNode.setProperty("state").send("off");
|
||||||
powerNode.setProperty("timer").send("0");
|
powerNode.setProperty("timer").send("0");
|
||||||
|
|
||||||
|
dht.setup(CONFIG_IO_DHT11, DHTesp::DHT11); // Connect DHT sensor to GPIO 17
|
||||||
dht.setup(PIN_DHT11, DHTesp::DHT11); // Connect DHT sensor to GPIO 17
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loopHandler() {
|
/**
|
||||||
|
* Handle timer updates from the main event loop
|
||||||
|
*/
|
||||||
|
void loopHandleTimer()
|
||||||
|
{
|
||||||
if(timer)
|
if(timer)
|
||||||
{
|
{
|
||||||
if(timer < millis())
|
if(timer < millis())
|
||||||
@ -65,36 +106,62 @@ void loopHandler() {
|
|||||||
powerNode.setProperty("state").send("off");
|
powerNode.setProperty("state").send("off");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(next_timer_update && millis() > next_timer_update) {
|
if(next_timer_update && millis() > next_timer_update)
|
||||||
|
{
|
||||||
next_timer_update = millis() + 60*1000;
|
next_timer_update = millis() + 60*1000;
|
||||||
unsigned int time_remaining = timer - millis();
|
unsigned int time_remaining = timer - millis();
|
||||||
unsigned int min_left = time_remaining / (60*1000);
|
unsigned int min_left = time_remaining / (60*1000);
|
||||||
powerNode.setProperty("timer").send(String(min_left));
|
powerNode.setProperty("timer").send(String(min_left));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (millis() - lastTemperatureSent >= TEMPERATURE_INTERVAL * 1000UL || lastTemperatureSent == 0)
|
/**
|
||||||
|
* Handle periodic temperature measurements from the main event loop
|
||||||
|
*/
|
||||||
|
void loopHandleTemperature()
|
||||||
|
{
|
||||||
|
static unsigned long lastTemperatureSent = 0;
|
||||||
|
if (millis() - lastTemperatureSent >= CONFIG_TEMPERATURE_SEND_INTERVAL * 1000UL || lastTemperatureSent == 0)
|
||||||
{
|
{
|
||||||
float humidity = dht.getHumidity();
|
float humidity = dht.getHumidity();
|
||||||
float temperature = dht.getTemperature();
|
float temperature = dht.getTemperature();
|
||||||
|
LN.logf(__PRETTY_FUNCTION__, LoggerNode::DEBUG, "Temperature: %f C Humidity: %f", temperature, humidity);
|
||||||
Homie.getLogger() << "Temperature: " << temperature << "°C " << humidity << "% Humidty" << endl;
|
|
||||||
temperatureNode.setProperty("temperature").send(String(temperature));
|
temperatureNode.setProperty("temperature").send(String(temperature));
|
||||||
temperatureNode.setProperty("humidity").send(String(humidity));
|
temperatureNode.setProperty("humidity").send(String(humidity));
|
||||||
lastTemperatureSent = millis();
|
lastTemperatureSent = millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
/**
|
||||||
Serial.begin(115200);
|
* Main event loop. Part of the Homie API. This runs while the device is active and connected.
|
||||||
|
*
|
||||||
|
* \callgraph
|
||||||
|
*/
|
||||||
|
void loopHandler()
|
||||||
|
{
|
||||||
|
loopHandleTimer();
|
||||||
|
loopHandleTemperature();
|
||||||
|
}
|
||||||
|
|
||||||
Homie_setFirmware("deskcontrol", "0.4.2");
|
/**
|
||||||
|
* Arduino style setup() routine.
|
||||||
|
* Configure the Homie framework by adding the two nodes "power" and "temperature"
|
||||||
|
*/
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
|
||||||
|
Homie_setFirmware("deskcontrol", VERSION);
|
||||||
|
Homie.setLoggingPrinter(&Serial);
|
||||||
|
Serial.begin(CONFIG_SERIAL_BAUDRATE);
|
||||||
|
|
||||||
Homie.disableResetTrigger();
|
Homie.disableResetTrigger();
|
||||||
|
|
||||||
|
//Power
|
||||||
powerNode.advertise("state").settable(powerStateHandler);
|
powerNode.advertise("state").settable(powerStateHandler);
|
||||||
powerNode.advertise("timer").settable(powerTimerHandler);
|
powerNode.advertise("timer").settable(powerTimerHandler);
|
||||||
|
|
||||||
|
//Temperature
|
||||||
temperatureNode.advertise("humidity");
|
temperatureNode.advertise("humidity");
|
||||||
temperatureNode.advertise("temperature");
|
temperatureNode.advertise("temperature");
|
||||||
|
|
||||||
@ -104,6 +171,10 @@ void setup() {
|
|||||||
Homie.setup();
|
Homie.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
/**
|
||||||
|
* Arduino main loop. Forwarded to Homie framework
|
||||||
|
*/
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
Homie.loop();
|
Homie.loop();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user