"nodemcu with firebase" Code Answer's

You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "nodemcu with firebase" answered properly. Developers are finding an appropriate answer about nodemcu with firebase related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like nodemcu with firebase. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on nodemcu with firebase. 

nodemcu with firebase

By Nervous NewtNervous Newt on Mar 13, 2021
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#define FIREBASE_HOST "**********"           // Your Firebase Project URL 
#define FIREBASE_AUTH "************"         // Your Firebase Database Secret
#define WIFI_SSID "**************"           // your WiFi SSID
#define WIFI_PASSWORD "********"             // your WiFi PASSWORD
 
#define Relay1 12 //D6
int value1;
 
#define Relay2 14 //D2
int value2;
 
#define Relay3 4  //D1
int value3;
 
#define Relay4 5 //D5
int value4;
 
void setup() 
{
  Serial.begin(115200);               
  pinMode(Relay1,OUTPUT);
  pinMode(Relay2,OUTPUT);
  pinMode(Relay3,OUTPUT);
  pinMode(Relay4,OUTPUT);
 
  digitalWrite(Relay1,HIGH);
  digitalWrite(Relay2,HIGH);
  digitalWrite(Relay3,HIGH);
  digitalWrite(Relay4,HIGH);
 
  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.setInt("S1",0);        
  Firebase.setInt("S2",0); 
  Firebase.setInt("S3",0); 
  Firebase.setInt("S4",0); 
  
}
 
 
void firebasereconnect()
{
  Serial.println("Trying to reconnect");
    Firebase.begin(FIREBASE_HOST);
  }
 
void loop() 
{
  if (Firebase.failed())
      {
      Serial.print("setting number failed:");
      Serial.println(Firebase.error());
      firebasereconnect();
      return;
      }
      
  value1=Firebase.getString("S1").toInt();        //Reading the Status of Variable 1 from the firebase
  
  if(value1==1)                                             
     {
      digitalWrite(Relay1,LOW);
      Serial.println("Relay 1 ON");
    }
    else if(value1==0)                                    
    {                                      
      digitalWrite(Relay1,HIGH);
      Serial.println("Relay 1 OFF");
    }
 
  value2=Firebase.getString("S2").toInt();         //Reading the Status of Variable 2 from the firebase
  
  if(value2==1)                                                           
     {
      digitalWrite(Relay2,LOW);
      Serial.println("Relay 2 ON");
    }
    else if(value2==0)                                                   
    {                                      
      digitalWrite(Relay2,HIGH);
      Serial.println("Relay 2 OFF");
    }
 
   value3=Firebase.getString("S3").toInt();         //Reading the Status of Variable 3 from the firebase
  
  if(value3==1)                                                         
     {
      digitalWrite(Relay3,LOW);
      Serial.println("Relay 3 ON");
    }
    else if(value3==0)                                                    
    {                                      
      digitalWrite(Relay3,HIGH);
      Serial.println("Relay 3 OFF");
    }
 
   value4=Firebase.getString("S4").toInt();         //Reading the Status of Variable 4 from the firebase
  
  if(value4==1)                                                           
     {
      digitalWrite(Relay4,LOW);
      Serial.println("Relay 4 ON");
    }
    else if(value4==0)                                                    
    {                                      
      digitalWrite(Relay4,HIGH);
      Serial.println("Relay 4 OFF");
    }    
}

Source: how2electronics.com

Add Comment

0

All those coders who are working on the Whatever based application and are stuck on nodemcu with firebase can get a collection of related answers to their query. Programmers need to enter their query on nodemcu with firebase related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about nodemcu with firebase for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of nodemcu with firebase while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "nodemcu with firebase". Visit this developer's friendly online web community, CodeProZone, and get your queries like nodemcu with firebase resolved professionally and stay updated to the latest Whatever updates. 

Whatever answers related to "nodemcu with firebase"

View All Whatever queries

Whatever queries related to "nodemcu with firebase"

nodemcu with firebase if (!firebase.apps.length) { firebase.initializeApp({}); }else { firebase.app(); // if already initialized, use that one } nodemcu esp8266 relay control how to firebase.database().ref push unique id in same unique id firebase firebaseError: Firebase: Firebase App named '[DEFAULT'] already exists (app/duplicate-app). firebase snapshot to array Can't resolve 'firebase/app' in firebase update cloud function no firebase app ' default ' has been created flutter firebase deploy only specific functions firebase deploy hosting test listviewbuilder flutter firebase How to add document in firebase firestore firebase deploy functions multiple firebase start emulator emulators run star tonly fucntions firebase used to retrieve dat from firebase realtime datastore firebase flutter crashilitics firebase push notification ios no sound how to show user dropdown list from firebase and select flutter how to set read and write rules for public access firebase ionic firebase phone number verification ios api key firebase firebase auth make website on firebase firebase cloud method update firebase get download url firebase functions firebase get doc collection firebase find api key deploy to firebase hosting test Undefined index: bathroomId (View: firebase firebase update return result Could not build Objective-C module 'Firebase' How to deploy firebase application in raspberry firebase auth functions in larvel deleting enviroment variables in firebase cloud functions realtime firebase database : How to check if document exists npm run build npm ERR! Missing script: "build" for firebase Cloud function for deleting unverified users for flutter on firebase with NodJs firebase database get child count firebase notification icon not showing firebase installations service is unavailable. please try again later what is firebase API_KEY firebase db.collection (specific id) firebase create-react-app how to protect secrets add firebase to nativescript app firebase query multiple keys firebase cloud function flutter publishing test channel in firebase flutter firebase database medium unhandled Exception: MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core) firebase start function emulator firebase ! [W] undefined:undefined - Ruleset uses old version (version [1]). Please update to the latest version (version [2]). How to get the date and time when uploading image to firebase? introduction to firebase database android kotlin example how to get the API KEY of my firebase project Firebase real-time queries flutter firebase timestamp firebase.initializeapp() flutter how to set data in firebase apple authentication firebase how to use firebase in the emulator in the flutter firebase hosting delete older versions firebase snapshot.downloadURL vue firestore not found in firebase how to add data in firebase in flutter firebase set vs update getDownload url in firebase firebase realtime database correct architecture how to sign out user in flutter with firebase authentication firebase realtime database read data firebase realtime database rules sigup and sign out using firebase auth in flutter Namespace 'firebase' has no exported member 'default' firebase auth phone otp count the number of times data apears in firebase database firebase database xaamarin forms trigger firebase copy child data to another

Browse Other Code Languages

CodeProZone