DS1820 DS18B20 ESP01 Webserver STM32NucleoL152RE basiert auf dem DS1820-Example von Paul Staron
Dependencies: LCD_i2c_GSOE ESP8266WebserverGSOE DS1820
Revision 3:33bd03e2244f, committed 2021-08-07
- Comitter:
- jack1930
- Date:
- Sat Aug 07 18:33:20 2021 +0000
- Parent:
- 2:2c947079aae0
- Commit message:
- DS1820 mit Webserver
Changed in this revision
ESP8266WebserverGSOE.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 2c947079aae0 -r 33bd03e2244f ESP8266WebserverGSOE.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ESP8266WebserverGSOE.lib Sat Aug 07 18:33:20 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/jack1930/code/ESP8266WebserverGSOE/#0d5c64c91538
diff -r 2c947079aae0 -r 33bd03e2244f main.cpp --- a/main.cpp Sat Aug 07 18:17:28 2021 +0000 +++ b/main.cpp Sat Aug 07 18:33:20 2021 +0000 @@ -3,21 +3,52 @@ #include "mbed.h" #include "DS1820.h" #include "LCD.h" +#include "ESP8266Webserver.h" + DigitalOut led(LED1); -lcd mylcd; +lcd myLCD; #define DATA_PIN PB_0 #define MAX_PROBES 16 DS1820* probe[MAX_PROBES]; +ESP8266Webserver myWebserver; + Timer t; int DS; float Temp[16]; +string getRootPage() +{ + string webpage; + webpage="<!DOCTYPE html>"; + //HTML + webpage+="<html>"; + webpage+="<head>"; + webpage+="<title>STM32 HTTP</title>"; + webpage+="</head>"; + webpage+="<body>"; + webpage+="<h1>WIFI mit STM32 ESP01</h1>\n"; + webpage+="<p>Temperatur= "+to_string(Temp[0])+"C</p>\n"; + webpage+="</body>"; + webpage+="</html>"; + return webpage; +} + +void testfunc() +{ + myWebserver.send(200,"text/html",getRootPage()); +} + int main(){ - mylcd.clear(); + myWebserver.on("/",&testfunc); + myWebserver.begin(); + myLCD.clear(); + myLCD.cursorpos(0); + myLCD.printf("%s",myWebserver.gibIP()); + printf("\033[0m\033[2J\033[HInitialise...!\n\n"); while (DS1820::unassignedProbe(DATA_PIN)) { @@ -45,7 +76,7 @@ t.start(); while(1) { - + myWebserver.handleClient(); printf("\033[0m\033[2J\033[HDS Sensor data..\n\n"); int DS_error = 0; @@ -56,9 +87,9 @@ DS_error++; } printf("Probe %d: %3.2f %cc\r\n",i,Temp[i],0xb0); - mylcd.clear(); - mylcd.cursorpos(0); - mylcd.printf("%3.1f",Temp[i]); + + myLCD.cursorpos(0x40); + myLCD.printf("%3.1f ",Temp[0]); } printf("\nDS errors: %d\n\n", DS_error);