Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Arduino.h>
- #if defined(ESP32)
- #include <WiFi.h>
- #elif defined(ESP8266)
- #include <ESP8266WiFi.h>
- #endif
- #include <Firebase_ESP_Client.h>
- //Provide the token generation process info.
- #include "addons/TokenHelper.h"
- //Provide the RTDB payload printing info and other helper functions.
- #include "addons/RTDBHelper.h"
- // Insert your network credentials
- #define WIFI_SSID "Galaxy S22+3663" פה לשנות!!!!!!!!!!!!!!!!
- #define WIFI_PASSWORD "fnyh1479" פה לשנות!!!!!!!!!!!!!!!!
- // Insert Firebase project API Key
- #define API_KEY "AIzaSyAjG_MOsClpLU7N7o-D1PkI08_tFO84w-c" פה לשנות!!!!!!!!!!!!!!!!
- // Insert RTDB URLefine the RTDB URL */
- #define DATABASE_URL "https://facerecognition-tank-default-rtdb.firebaseio.com" פה לשנות!!!!!!!!!!!!!!!!
- //Define Firebase Data object
- FirebaseData fbdo;
- FirebaseAuth auth;
- FirebaseConfig config;
- unsigned long sendDataPrevMillis = 0;
- int intValue;
- float floatValue;
- bool signupOK = false;
- void setup() {
- Serial.begin(115200);
- WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
- Serial.print("Connecting to Wi-Fi");
- while (WiFi.status() != WL_CONNECTED) {
- Serial.print(".");
- delay(300);
- }
- Serial.println();
- Serial.print("Connected with IP: ");
- Serial.println(WiFi.localIP());
- Serial.println();
- /* Assign the api key (required) */
- config.api_key = API_KEY;
- /* Assign the RTDB URL (required) */
- config.database_url = DATABASE_URL;
- /* Sign up */
- if (Firebase.signUp(&config, &auth, "", "")) {
- Serial.println("ok");
- signupOK = true;
- }
- else {
- Serial.printf("%s\n", config.signer.signupError.message.c_str());
- }
- /* Assign the callback function for the long running token generation task */
- config.token_status_callback = tokenStatusCallback; //see addons/TokenHelper.h
- Firebase.begin(&config, &auth);
- Firebase.reconnectWiFi(true);
- }
- void loop() {
- if (Firebase.ready() && signupOK && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) {
- sendDataPrevMillis = millis();
- if (Firebase.RTDB.getInt(&fbdo, "/test/int")) {
- if (fbdo.dataType() == "int") {
- intValue = fbdo.intData();
- Serial.println(intValue);
- }
- }
- else {
- Serial.println(fbdo.errorReason());
- }
- if (Firebase.RTDB.getFloat(&fbdo, "/test/float")) {
- if (fbdo.dataType() == "float") {
- floatValue = fbdo.floatData();
- Serial.println(floatValue);
- }
- }
- else {
- Serial.println(fbdo.errorReason());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement