So der Code wurde angepasst, funktioniert leider noch nich jetzt gar keine ausgabe der Sensor Daten auf der Webseite, Microcontroller wäre ein ESP32, angepasster Code
schicke ich mit
#include "wlan.h"
#include "ota.h"
#include "button.h"
#include "uhrzeit.h"
#include "max6675.h"
#include "DS18B20.h"
#include <WebServer.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
int thermoDO = 15; // SO
int thermoCS = 2; // CS
int thermoCLK = 0; // SCK
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int thermoDO2 = 16; // SO
int thermoCS2 = 17; // CS
int thermoCLK2 = 5; // SCK
MAX6675 thermocouple2(thermoCLK2, thermoCS2, thermoDO2);
unsigned long tempzeit = 0;
int intervalltemp = 3000;
WebServer server(80);
//-----------------------------------------------
int buttonState = 0;
unsigned long aktuelleZeit = 0;
int intervall = 500;
unsigned long aktuelleZeit2 = 0;
int intervall2 = 7000;
int mode = 0;
int lcdStufe;
//-----------------------------------------------
int aktuelleUhrzeit = 0;
int intervallUhrzeit = 1000;
void setup() {
//Serial.begin(9600);
wlaninit();
otainit();
lcd.init();
buttonInit();
uhrzeitInit();
ds18b20init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Press Button");
server.on("/", indexHTML);
server.on("/json", handleJson);
// server.on("/TempWeb", TempRaum); // TempOfenrohr TempRaum
// server.on("/TempWeb2", TempOfenrohr);
//server.on("/TempWeb3", TempInnenraum);
//server.on("/", handle_root);
server.begin();
}
void loop() {
//ensureWIFIConnection();
ArduinoOTA.handle();
timeClient.update();
server.handleClient();
schalten();
lcdSchalten(lcdStufe);
}
// ----------------------------------------------------------------------------------
void lcdSchalten(int schalt) {
//static int altPower = -1;
// if (altPower == power) return;
// altPower = power;
switch (schalt) {
case 0:
// lcd.setCursor(0, 0);
// lcd.print(TempMesungDS());
if (WiFi.status() == WL_CONNECTED) {
lcd.setCursor(0, 0);
// lcd.print(timeClient.getFormattedTime());
lcd.print("Verbunden mit");
// lcd.print("Fuehler 1");
//lcd.setCursor(0, 1);
// lcd.print(TempMesungDS2());
lcd.setCursor(0, 1);
lcd.print(String(WiFi.SSID()));
} else {
lcd.setCursor(0, 0);
lcd.print("Nicht Verbunden");
lcd.setCursor(0, 1);
lcd.print("Mit Wlan");
}
//lcd.print("Fuehler 2");
break;
case 1:
// lcd.setCursor(0, 0);
// lcd.print(TempMesungDS());
if (WiFi.status() == WL_CONNECTED) {
lcd.setCursor(0, 0);
lcd.print("IP Adresse: ");
// lcd.setCursor(0, 1);
// lcd.print(FeuchtMesungDHT11());
lcd.setCursor(0, 1);
lcd.print(WiFi.localIP().toString());
} else {
lcd.setCursor(0, 0);
lcd.print("IP Adresse: ");
lcd.setCursor(0, 1);
lcd.print("-----------");
}
//lcd.print("Luft ");
break;
case 2:
// lcd.setCursor(0, 0);
// lcd.print(TempMesungDS2());
if (WiFi.status() == WL_CONNECTED) {
lcd.setCursor(0, 3);
lcd.print(timeClient.getFormattedTime());
// lcd.setCursor(0, 1);
// lcd.print(FeuchtMesungDHT11());
lcd.setCursor(10, 3);
lcd.print(daysOfTheWeek[timeClient.getDay()]);
} else {
lcd.setCursor(0, 3);
lcd.print("Uhr");
lcd.setCursor(4, 3);
lcd.print("Ist Offline");
}
break;
case 3:
// lcd.setCursor(0, 0);
// lcd.print(TempMesungDS2());
if (millis() - tempzeit > intervalltemp) {
lcd.setCursor(12, 0);
lcd.print(thermocouple.readCelsius());
lcd.setCursor(18, 0);
printX("&0& "); //----------------------------------------------------
tempzeit = millis();
lcd.setCursor(0, 0);
lcd.print("Ofenrohr");
lcd.setCursor(12, 1);
lcd.print(thermocouple2.readCelsius());
lcd.setCursor(18, 1);
printX("&0& "); //----------------------------------------------------
lcd.setCursor(0, 1);
lcd.print("Innenraum");
lcd.setCursor(12, 2);
lcd.print(TempMesungDS());
lcd.setCursor(18, 2);
printX("&0& "); //----------------------------------------------------
lcd.setCursor(0, 2);
lcd.print("Raum");
}
if (WiFi.status() == WL_CONNECTED) {
lcd.setCursor(0, 3);
lcd.print(timeClient.getFormattedTime());
// lcd.setCursor(0, 1);
// lcd.print(FeuchtMesungDHT11());
lcd.setCursor(10, 3);
lcd.print(daysOfTheWeek[timeClient.getDay()]);
} else {
lcd.setCursor(0, 3);
lcd.print("Uhr");
lcd.setCursor(4, 3);
lcd.print("Ist Offline");
}
break;
}
}
//------------------------------------------------------------------------------------
void mode0() {
mode = 0;
Serial.println("Mode0");
lcd.clear();
lcdStufe = 0;
lcdSchalten(lcdStufe);
}
void mode1() {
mode = 1;
Serial.println("Mode1");
lcd.clear();
lcdStufe = 1;
lcdSchalten(lcdStufe);
}
void mode2() {
mode = 2;
Serial.println("Mode2");
lcd.clear();
lcdStufe = 2;
lcdSchalten(lcdStufe);
}
void mode3() {
mode = 3;
Serial.println("Mode3");
lcd.clear();
lcdStufe = 3;
lcdSchalten(lcdStufe);
}
void schalten() {
// read the state of the pushbutton value:
buttonState = button();
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// check mode
if (millis() - aktuelleZeit > intervall) {
if (mode == 0) {
mode2();
} else if (mode == 1) {
mode2();
} else if (mode == 2) {
mode3();
} else if (mode == 3) {
mode0();
}
aktuelleZeit = millis();
}
}
if (millis() - aktuelleZeit2 > intervall2) {
if (mode == 0) {
mode1();
} else if (mode == 1) {
mode0();
}
aktuelleZeit2 = millis();
}
}
//---------------------------------------------------------------------------------
void uhrzeit() {
if (millis() - aktuelleUhrzeit > intervallUhrzeit) {
Serial.println(timeClient.getFormattedTime());
aktuelleUhrzeit = millis();
}
}
//--------------------------------------------------------------------------------
void printX(const char a[]) {
int i = 0;
while (true) {
char ch = a[i++];
if (ch == 0) return;
if (ch == '&') {
ch = a[i++];
switch (ch) {
case 'a':
lcd.write(0xE1);
break;
case 'o':
lcd.write(0xEF);
break;
case 'u':
lcd.write(0xF5);
break;
case '0':
lcd.write(0xDF);
break;
default:
if (ch < 128) lcd.write(ch);
}
} else if (ch < 128) {
lcd.write(ch);
}
}
}
//--------------------------------------------------------------------------------
void indexHTML() {
server.send(200, "text/html",
"<!DOCTYPE html>\
<html>\
<head>\
<title>Temperaturanzeige</title>\
<meta http-equiv='content-type' content='text/html'; charset='utf-8'>\
<style>\
body { background-color: #585858; font-size: 50px; font-family: Arial, Helvetica, Sans-Serif; color: #F2F2F2; margin-left: 40px; }\
h1 { color: #2ECCFA; margin-top: 50px; margin-bottom: 0px; }\
h2 { font-size: 20px; margin-top: 0px; margin-bottom: 50px; }\
#tempInnenraum { width: 230px; height: 80px; border: 5px solid #F2F2F2; text-align:center; padding: 1px; color: #9AFE2E; background-color: #000000; font-size: 60px; }\
#tempOfenrohr { width: 230px; height: 80px; border: 5px solid #F2F2F2; text-align:center; padding: 1px; color: #9AFE2E; background-color: #000000; font-size: 60px; }\
</style>\
</head>\
<body>\
<h1>Temperaturanzeige</h1>\
<h2>(Ofen)</h2>\
<table><tr><td>Aktuelle InnenraumTemp: </td>\
<td id='tempInnenraum'><span id='Innenraum'>-</span>°C</td></tr></table>\
<table><tr><td>Aktuelle OfenrohrTemp : </td>\
<td id='tempOfenrohr'><span id='Ofenrohr'>-</span>°C</td></tr></table>\
<script>\
setInterval(function() {\
getData();\
}, 1000);\
function getData() {\
var xhttp = new XMLHttpRequest();\
if (this.readyState == 4) {\
if (this.status == 200) {\
if (this.responseText != null) {\
var jo=JSON.parse(this.responseText);\
for (var i in jo)\
{if(document.getElementById(i)) document.getElementById(i).innerHTML=jo[i];}\
}}}\
};\
xhttp.open('GET', 'json', true);\
xhttp.send();\
}\
</script>\
</body>\
</html>\
");
}
void TempRaum() {
String Raum = String(TempMesungDS());
server.send(200, "text/plane", Raum);
}
void TempOfenrohr() {
String Ofenrohr = String(thermocouple.readCelsius());
server.send(200, "text/plane", Ofenrohr);
}
void TempInnenraum() {
String Innenraum = String(thermocouple2.readCelsius());
server.send(200, "text/plane", Innenraum);
}
void handleJson() {
String message;
message.reserve(1000);
message = (F("{\"Raum\":")); // Start of JSON and the first object "ss":
message += String(TempMesungDS());
message += (F(",\"Ofenrohr\":"));
message += thermocouple.readCelsius();
message += (F(",\"Innenraum\":"));
message += thermocouple2.readCelsius();
message += (F("}")); // End of JSON
server.send(200, "application/json", message);
}
// TempMesungDS() Raum
// thermocouple.readCelsius() Ofenrohr
// thermocouple2.readCelsius() Innenraum