Hallo
Habe ein problem mit dem esp8266. hab den BME280 sensor und ein LCD Displasy hd n44780 20x4 ueber I2C angeschlossen. Funktioniert auch alles soweit ganz gut Werde fuer Temperatur, Luftfeuchte und Luftdruck werden angezeigt nur leider werden die so schnell aktualliesiert das man die werte nach dem punt kaum lesen kann. Werte sind auch ueber den ESP8266 Webserver abrufbar.
Danke im Vorraus
hier mein Code
#include <ESP8266WiFi.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <LiquidCrystal_I2C.h>
#define SEALEVELPRESSURE_HPA (1013.25)
LiquidCrystal_I2C lcd(0x27,20,4);
const char* ssid = "Funkwelle_Kloosterburen";
const char* password = "T30h19A76l";
unsigned long delayTime;
float h, t, p;
char temperatureCString[6];
char humidityString[6];
char pressureString[7];
Adafruit_BME280 bme;
WiFiServer server(80);
void setup() {
lcd.init();
lcd.backlight();
Serial.begin(115200);
delay(10);
Serial.println(F("BME280 test"));
bool status;
status = bme.begin(0x76);
IPAddress ip(192, 168, 1, 52);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress dns(213, 75, 63, 75);
WiFi.config(ip, dns, gateway, subnet);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.println(WiFi.localIP());
}
void getWeather() {
h = bme.readHumidity();
t = bme.readTemperature();
p = bme.readPressure()/ 100.0;
dtostrf(t, 5, 1, temperatureCString);
dtostrf(h, 5, 1, humidityString);
dtostrf(p, 6, 1, pressureString);
delay(100);
}
void loop() {
lcd.home();
lcd.print("Wetterstation");
lcd.setCursor(0, 1);
lcd.print("Temperatur:");
lcd.print(bme.readTemperature());
lcd.print("c");
lcd.setCursor(0, 2);
lcd.print("Luftfeuchte:");
lcd.print(bme.readHumidity());
lcd.print("%");
lcd.setCursor(0, 3);
lcd.print("Luftdfruck:");
lcd.print(bme.readPressure());
lcd.print("hPa");
// Check if a client has connected
WiFiClient client = server.available();
if (client) {
Serial.println("New client");
// bolean to locate when the http request ends
boolean blank_line = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == '\n' && blank_line) {
getWeather();
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println();
// your actual web page that displays temperature
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("<head><META HTTP-EQUIV=\"refresh\" CONTENT=\"15\"></head>");
client.println("<body><h1>Wetterstation Kloosterburen/Niederlande</h1>");
client.println("<table border=\"2\" width=\"456\" cellpadding=\"10\"><tbody><tr><td>");
client.println("<h3>Temperatur = ");
client.println(temperatureCString);
client.println("°C</h3><h3>Luftfeuchte = ");
client.println(humidityString);
client.println("%</h3>");
client.println("<h3>Luftdruck = ");
client.println(pressureString);
client.println("hPa");
client.println("</h3></td></tr></tbody></table></body></html>");
break;
}
if (c == '\n') {
// when starts reading a new line
blank_line = true;
}
else if (c != '\r') {
// when finds a character on the current line
blank_line = false;
}
}
}
// closing the client connection
delay(1);
client.stop();
Serial.println("Client disconnected.");
}
}