diff options
Diffstat (limited to 'linz/oekofen_thermo/src/main.cpp')
| -rw-r--r-- | linz/oekofen_thermo/src/main.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
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 @@ | |||
| 1 | #include <Arduino.h> | ||
| 2 | #include <WiFiManager.h> | ||
| 3 | #include <ESP8266WebServer.h> | ||
| 4 | |||
| 5 | #include "MCP42010.h" | ||
| 6 | |||
| 7 | ESP8266WebServer http_service(80); | ||
| 8 | MCP42010 msp42010(D8); | ||
| 9 | |||
| 10 | void setup() { | ||
| 11 | Serial.begin(115200); | ||
| 12 | msp42010.setup(); | ||
| 13 | |||
| 14 | WiFiManager wifiManager; | ||
| 15 | wifiManager.setConfigPortalTimeout(600); | ||
| 16 | Serial.printf_P(PSTR("Setting up WiFi\n")); | ||
| 17 | WiFi.hostname("oekofen"); | ||
| 18 | if (!wifiManager.autoConnect("oekofen-thermo")) | ||
| 19 | { | ||
| 20 | Serial.printf_P(PSTR("Failed to connect and hit timeout\n")); | ||
| 21 | delay(5000); | ||
| 22 | ESP.restart(); | ||
| 23 | } | ||
| 24 | |||
| 25 | http_service.on("/", HTTP_GET, []() { | ||
| 26 | uint8_t val = random(0, 255); | ||
| 27 | //msp42010.setPot(MCP42010::P0, val); | ||
| 28 | msp42010.setPot(MCP42010::P1, val); | ||
| 29 | http_service.send(200, PSTR("text/plain"), String(val)); | ||
| 30 | }); | ||
| 31 | http_service.begin(); | ||
| 32 | |||
| 33 | Serial.println("Setup done"); | ||
| 34 | } | ||
| 35 | |||
| 36 | void loop() { | ||
| 37 | //http_service.handleClient(); | ||
| 38 | if (Serial.available() > 0) | ||
| 39 | { | ||
| 40 | while (Serial.read() >= 0) {} | ||
| 41 | uint8_t val = random(0, 255); | ||
| 42 | //msp42010.setPot(MCP42010::P0, val); | ||
| 43 | msp42010.setPot(MCP42010::P1, val); | ||
| 44 | Serial.println(val, DEC); | ||
| 45 | } | ||
| 46 | } | ||
