Untitled

mail@pastecode.io avatar
unknown
plain_text
4 years ago
998 B
4
Indexable
Never
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <ESP8266HTTPClient.h>
#include <ArduinoJson.h>

#define FIREBASE_HOST "https://ugrsdb.firebaseio.com"
#define FIREBASE_AUTH "XH4XPAV7MlnjpKwxQjt3euAHFoEMW2JJIw2ODVCe"
#define WIFI_SSID "B.net_96991"
#define WIFI_PASSWORD "0ef72342o967"

String mystring;

void setup() {
  pinMode(13, INPUT);
  
  
  //Wifi and Firebase connection
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.begin(115200);
  while(WiFi.status()!=WL_CONNECTED)
  {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.print("IP Address: ");
  Serial.print(WiFi.localIP());

  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}
 
void loop() {
  int detect=digitalRead(13);
  mystring=String(detect);
  delay(1000); 
  if(detect==LOW){
    Serial.print("Item detected \n");
    Firebase.setString("object/value1","si lud");
  }else{
     Serial.print("No items detected \n");
     Firebase.setString("object/value1",mystring);
  }
   delay(300);
}