From b2173aba39b164c3a52015f467cba86a03ac6141 Mon Sep 17 00:00:00 2001 From: starcalc Date: Tue, 30 Aug 2022 17:34:15 +0200 Subject: [PATCH] Initial code --- data/homie/config.json | 16 ++++++++++++++++ platformio.ini | 5 +++++ src/main.cpp | 28 ++++++++++++++++++++++++---- 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 data/homie/config.json diff --git a/data/homie/config.json b/data/homie/config.json new file mode 100644 index 0000000..c885793 --- /dev/null +++ b/data/homie/config.json @@ -0,0 +1,16 @@ +{ + "name": "HOSTNAME", + "device_id": "HOSTNAME", + "wifi": { + "ssid": "WIFISSID", + "password": "WIFIPASS" + }, + "mqtt": { + "host": "raum.ctdo.de", + "port": 1883, + "auth": false + }, + "ota": { + "enabled": true + } +} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 4fa4a6d..9a38d96 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,3 +12,8 @@ platform = espressif8266 board = d1_mini framework = arduino +lib_deps = + https://github.com/homieiot/homie-esp8266 +# bblanchon/ArduinoJson +upload_speed = 1500000 +monitor_speed = 115200 \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 58b344c..bbab52b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,9 +1,29 @@ -#include +#include +#include + +//D4 auf ground macht led leuchten + +#define PIN_LED D4 + +HomieNode knobNode("blinky", "blinky", "commands"); void setup() { - // put your setup code here, to run once: + Serial.begin(115200); + Serial << endl << endl; + + pinMode(PIN_LED, OUTPUT); + + Homie_setFirmware("blinky", "0.1.0"); + + Homie.setup(); + ArduinoOTA.setHostname(Homie.getConfiguration().deviceId); + ArduinoOTA.onStart([]() { + Homie.getLogger() << "Arduino OTA angefragt" << endl; + }); + ArduinoOTA.begin(); } void loop() { - // put your main code here, to run repeatedly: -} \ No newline at end of file + Homie.loop(); + ArduinoOTA.handle(); +}