Created
February 2, 2019 00:04
-
-
Save felansu/3d4b0a5186b40820fa0217823683937c to your computer and use it in GitHub Desktop.
Arduino read humidity and temperature and save in firebase
This file contains hidden or 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 <ArduinoJson.h> | |
#include <ArduinoOTA.h> | |
#include <Firebase.h> | |
#include <FirebaseHttpClient.h> | |
#include <FirebaseArduino.h> | |
#include <ESP8266WiFi.h> | |
#include <FirebaseArduino.h> | |
#include "DHT.h" | |
#define FIREBASE_HOST "firebase host" | |
#define FIREBASE_AUTH "firebase auth" | |
#define WIFI_SSID "wifi name" | |
#define WIFI_PASSWORD "wifi password" | |
#define DHTTYPE DHT11 | |
#define DHTPIN 2 | |
DHT dht(DHTPIN, DHTTYPE); | |
void setup() { | |
Serial.begin(9600); | |
WiFi.begin(WIFI_SSID, WIFI_PASSWORD); | |
Serial.print("Connecting"); | |
while (WiFi.status() != WL_CONNECTED) { | |
Serial.print("."); | |
delay(500); | |
} | |
Serial.println(); | |
Serial.print("Connected: "); | |
Serial.println(WiFi.localIP()); | |
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); | |
} | |
void loop() { | |
Firebase.setFloat("humidity", dht.readHumidity()); | |
Firebase.setFloat("temperature", dht.readTemperature()); | |
delay(6000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment