From 0b8366c59fa0b34a70b6b453bfb0f8eaf34a2f16 Mon Sep 17 00:00:00 2001 From: manuel Date: Wed, 21 Oct 2020 15:55:29 +0200 Subject: Add Linz --- linz/oekofen_thermo/src/main.cpp | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 linz/oekofen_thermo/src/main.cpp (limited to 'linz/oekofen_thermo/src/main.cpp') diff --git a/linz/oekofen_thermo/src/main.cpp b/linz/oekofen_thermo/src/main.cpp new file mode 100644 index 0000000..5713a0b --- /dev/null +++ b/linz/oekofen_thermo/src/main.cpp @@ -0,0 +1,46 @@ +#include +#include +#include + +#include "MCP42010.h" + +ESP8266WebServer http_service(80); +MCP42010 msp42010(D8); + +void setup() { + Serial.begin(115200); + msp42010.setup(); + + WiFiManager wifiManager; + wifiManager.setConfigPortalTimeout(600); + Serial.printf_P(PSTR("Setting up WiFi\n")); + WiFi.hostname("oekofen"); + if (!wifiManager.autoConnect("oekofen-thermo")) + { + Serial.printf_P(PSTR("Failed to connect and hit timeout\n")); + delay(5000); + ESP.restart(); + } + + http_service.on("/", HTTP_GET, []() { + uint8_t val = random(0, 255); + //msp42010.setPot(MCP42010::P0, val); + msp42010.setPot(MCP42010::P1, val); + http_service.send(200, PSTR("text/plain"), String(val)); + }); + http_service.begin(); + + Serial.println("Setup done"); +} + +void loop() { + //http_service.handleClient(); + if (Serial.available() > 0) + { + while (Serial.read() >= 0) {} + uint8_t val = random(0, 255); + //msp42010.setPot(MCP42010::P0, val); + msp42010.setPot(MCP42010::P1, val); + Serial.println(val, DEC); + } +} -- cgit v1.2.3