Test Firebase

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <ESP8266WiFi.

h>
#include "FirebaseArduino.h"

#define WIFI_SSID "M******"


#define WIFI_PASSWORD "c******"
#define FIREBASE_HOST "https://ledlampicaesp.firebaseio.com/"
#define FIREBASE_AUTH "Y0CEFLiaiQ7WnY9nObrLOjY4AS5iLju5kb1Hw6qW"

int LED = 4;

void setup() {
// put your setup code here, to run once:++
Serial.begin(115200);
pinMode(LED,OUTPUT);
delay(2000);
Serial.println('\n');
wifiConnect();
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
delay(10);
}

void loop() {
// put your main code here, to run repeatedly:
Serial.print(Firebase.getString("LED"));
analogWrite(LED, Firebase.getString("LED").toInt());
delay(10);
if(WiFi.status() != WL_CONNECTED){ wifiConnect(); }
delay(10);
}
void wifiConnect()
{
WiFi.begin(WIFI_SSID, WIFI_PASSWORD); // Connect to the network
Serial.print("Connecting to ");
Serial.print(WIFI_SSID); Serial.println(" ...");

int teller = 0;
while (WiFi.status() != WL_CONNECTED)
{ // Wait for the Wi-Fi to connect
delay(1000);
Serial.print(++teller); Serial.print(' ');
}

Serial.println('\n');
Serial.println("Connection established!");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to
the computer
}

You might also like