Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Load Wi-Fi library
- #include <ESP8266WiFi.h>
- #include <Wire.h>
- #include <Adafruit_BME280.h>
- #include <Adafruit_Sensor.h>
- //uncomment the following lines if you're using SPI
- /*#include <SPI.h>
- #define BME_SCK 14
- #define BME_MISO 12
- #define BME_MOSI 13
- #define BME_CS 15*/
- #define SEALEVELPRESSURE_HPA (1022.4)
- Adafruit_BME280 bme; // I2C
- //Adafruit_BME280 bme(BME_CS); // hardware SPI
- //Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
- // Replace with your network credentials
- const char* ssid = "xxxxxxxxxxxxxx";
- const char* password = "xxxxxxxxxxxxxx";
- // Set web server port number to 80
- WiFiServer server(80);
- void setup() {
- Serial.begin(115200);
- bool status;
- // default settings
- // (you can also pass in a Wire library object like &Wire2)
- //status = bme.begin();
- if (!bme.begin(0x76)) {
- Serial.println("Could not find a valid BME280 sensor, check wiring!");
- while (1);
- }
- // Connect to Wi-Fi network with SSID and password
- Serial.print("Connecting to ");
- Serial.println(ssid);
- WiFi.begin(ssid, password);
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(".");
- }
- // Print local IP address and start web server
- Serial.println("");
- Serial.println("WiFi connected.");
- Serial.println("IP address: ");
- Serial.println(WiFi.localIP());
- server.begin();
- }
- void loop(){
- WiFiClient client = server.available(); // Listen for incoming clients
- // Web Page Heading
- client.println("Temperatur 1");
- client.println("Messung");
- client.print("Temperatur C. ");
- client.print(bme.readTemperature());
- client.println(" *C");
- client.print("Temperatur F. ");
- client.print(1.8 * bme.readTemperature() + 32);
- client.println(" *F");
- client.print("Luftdruck ");
- client.print(bme.readPressure() / 100.0F);
- client.println(" hPa");
- client.print("Hoehe ca. ");
- client.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
- client.println(" m");
- client.print("Luftfeuchte ");
- client.print(bme.readHumidity());
- client.println(" %");
- // The HTTP response ends with another blank line
- client.println();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement