0% found this document useful (0 votes)
28 views1 page

Code

This code connects an ESP8266 to WiFi and Firebase. It defines credentials and pins. In setup, it connects to WiFi, Firebase, and sets an initial LED status of 0. In loop, it gets the LED status from Firebase and turns the LED pin on or off accordingly.

Uploaded by

fyyn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views1 page

Code

This code connects an ESP8266 to WiFi and Firebase. It defines credentials and pins. In setup, it connects to WiFi, Firebase, and sets an initial LED status of 0. In loop, it gets the LED status from Firebase and turns the LED pin on or off accordingly.

Uploaded by

fyyn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <ESP8266WiFi.

h>
#include <FirebaseArduino.h>

#define FIREBASE_HOST " " // Firebase host


#define FIREBASE_AUTH " " //Firebase Auth code
#define WIFI_SSID " " //Enter your wifi Name
#define WIFI_PASSWORD " " // Enter your password
int fireStatus = 0;

void setup() {
Serial.begin(9600);
pinMode(D1, OUTPUT);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.println("Connected.");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
Firebase.set("LED_STATUS", 0);
}

void loop() {
fireStatus = Firebase.getInt("LED_STATUS");
if (fireStatus == 1) {
Serial.println("Led Turned ON");
digitalWrite(D1, HIGH);
}
else if (fireStatus == 0) {
Serial.println("Led Turned OFF");
digitalWrite(D1, LOW);
}
else {
Serial.println("Command Error! Please send 0/1");
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy