-
-
Save solars/1bebe10d0a9175a5876b1f3ea60aa6a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <Adafruit_BME280.h> | |
#include <ESP8266WiFi.h> | |
const char* ssid = "casablanca"; | |
const char* password = "xxx"; | |
WiFiClient client; | |
Adafruit_BME280 bme; // I2C | |
void setup() { | |
Serial.begin(115200); | |
WiFi.begin(ssid, password); | |
Serial.println(); | |
Serial.println(); | |
Serial.print("Connecting to "); | |
Serial.println(ssid); | |
WiFi.begin(ssid, password); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(500); | |
Serial.print("."); | |
} | |
Serial.println(""); | |
Serial.println("WiFi connected"); | |
if (!bme.begin()) { | |
Serial.println("Could not find a valid BME280 sensor, check wiring!"); | |
while (1); | |
} | |
} | |
void loop() { | |
float t = bme.readTemperature(); | |
float p = bme.readPressure(); | |
float h = bme.readHumidity(); | |
Serial.print("Temperature: "); | |
Serial.print(t); | |
Serial.print(" degrees Celcius Pressure: "); | |
Serial.print(p); | |
Serial.print(" Humidity: "); | |
Serial.print(h); | |
Serial.println("% send to Thingspeak"); | |
delay(20000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment