

<?php
require 'firebaseLib.php';$Distance = $_GET["distance"];$Temperature = $_GET["temp_f"];$Humidity= $_GET["humidity"];
// --- This is your Firebase URL$url = 'https://thesis1-69.firebaseio.com';// --- Use your token from Firebase here$token = 'MI3ZrLNP8YrtJbZqcr2vazG8x7wPh5cheiCyR1rM';// --- Here is your parameter from the http GET
$_devicestatus= array('Distance' => $Distance,'Temperature' => $Temperature,'Humidity' => $Humidity,
);$firebasePath = '/thesis1-69/';/// --- Making calls$fb = new fireBase($url, $token);$fb->update($firebasePath, $_devicestatus);
?>
Fatal error: Uncaught Error: Class 'fireBase' not found
$firebasePath = '/thesis1-69/';

https://<yourdomain.com>/<your ProjectBucket>/yourphpfile.php?trash=Trash1&distance=150&temperature=27.51&humidity=91
<?php
require 'firebaseLib.php';$Trash = $_GET["trash"]; // new entry here to get trash location$Distance = $_GET["distance"];$Temperature = $_GET["temperature"];$Humidity= $_GET["humidity"];
// --- This is your Firebase URL$baseURI = '<your url here>';
// --- Use your token from Firebase here$token = '<your database secret here>';
// --- path or ProjectBucket$firebasePath = '/<your project bucket here>/';
// --- Here are your parameters from the http GET$devicestatus= array('Distance' => $Distance,'Temperature' => $Temperature,'Humidity' => $Humidity);
// - - - Combine the Location with the status
$full= array($Trash => $devicestatus);
/// --- Making calls$fb = new Firebase($baseURI, $token);$fb -> update($firebasePath, $full);
?>
You don't need to create anything, the first run will generate the datasets
Now you can access the data from the app by calling in each dataset by its name: Trash1, Trash2 etc.
Enjoy :)
#include <SoftwareSerial.h>#include <DHT.h>;
SoftwareSerial Serial1(10, 11); // Rx, Tx/* DHT SENSOR SETUP */
#define DHTTYPE DHT11#define DHTPIN 2#define TRIGGER_PIN 4#define ECHO_PIN 3
DHT dht(DHTPIN, DHTTYPE, 11);
float humidity, temp_f;int distance;long duration;
void setup() {
Serial.begin(9600); // PC Arduino Serial Monitor Serial1.begin(9600); // Arduino to ESP01 Communication //ESP8266.begin(9600); dht.begin(); pinMode(TRIGGER_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); connectWiFi(); // To connect to Wifi}
void loop() { // put your main code here, to run repeatedly: // float analog_val = analogRead(temp_sensor); // Read Analog Temperature
//j=tempc; temp_f = dht.readTemperature(); humidity = dht.readHumidity(); digitalWrite(TRIGGER_PIN, LOW); delayMicroseconds(2); digitalWrite(TRIGGER_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIGGER_PIN, LOW);
duration = pulseIn(ECHO_PIN, HIGH); distance = duration * 0.034 / 2;
Serial1.println("AT+CIPMUX=0\r\n"); // To Set MUX = 0 delay(500); // Wait for 2 sec
// TCP connection String cmd = "AT+CIPSTART=\"TCP\",\""; // TCP connection with https://thingspeak.com server // cmd += "184.106.153.149"; // IP addr of api.thingspeak.com cmd += "expository-spoke.000webhostapp.com"; // ip address of my site cmd += "\",80\r\n\r\n"; // Port No. = 80
Serial1.println(cmd); // Display above Command on PC Serial.println(cmd); // Send above command to Rx1, Tx1
delay(500); // Wait for 20 Sec
if (Serial1.find("ERROR")) // If returns error in TCP connection { Serial.println("AT+CIPSTART error"); // Display error msg to PC //return; }
// prepare GET string Serial.println(getStr); // Display GET String on PC
cmd = "AT+CIPSEND="; // send data length cmd += String(getStr.length()); cmd += "\r\n";
Serial.println(cmd); // Display Data length on PC Serial1.println(cmd); // Send Data length command to Tx1, Rx1
delay(500); // wait for 20sec
if (Serial1.find(">")) // If prompt opens //verify connection with cloud { Serial.println("connected to Cloud"); // Display confirmation msg to PC Serial1.print(getStr); // Send GET String to Rx1, Tx1 } else { Serial1.println("AT+CIPCLOSE\r\n"); // Send Close Connection command to Rx1, Tx1 Serial.println("AT+CIPCLOSE"); // Display Connection closed command on PC }
}
boolean connectWiFi() { // Connect to Wifi Function Serial1.println("AT+CWMODE=1\r\n"); // Setting Mode = 1 delay(100); // wait for 100 mSec
String cmd = "AT+CWJAP=\""; // Connect to WiFi cmd += "c902b6"; // ssid_name cmd += "\",\""; cmd += "262459105"; // password cmd += "\"\r\n"; Serial.println(cmd); // Display Connect Wifi Command on PC Serial1.println(cmd); // send Connect WiFi command to Rx1, Tx1
delay(500); // wait for 10 sec
Serial1.println("AT+CWJAP?"); // Verify Connected WiFi
if (Serial1.find("+CWJAP")) { Serial.println("OK, Connected to WiFi."); // Display Confirmation msg on PC return true; } else { Serial.println("Can not connect to the WiFi."); // Display Error msg on PC return false; }}