mobizt / Firebase-Arduino-WiFiNINA

Firebase Arduino Library for ARM/AVR WIFI Dev Boards based on WiFiNINA
MIT License
65 stars 12 forks source link

firebaseData.errorReason - Error: not found, 404 Not Found #35

Closed Karl-Gil closed 2 years ago

Karl-Gil commented 2 years ago

Hi, I am trying to send data from my Arduino Uno WiFi Rev2 to firebase but it does not seem to work. Here is my code. I would like to send the number 1634631042000 to my real-time database. When I run the code, it connects to the internet but then when it tries to push data I get the error "Error: not found, 404 Not Found". Thank you

`/*

//Example shows how to connect to Firebase RTDB and perform basic operation for set, get, push and update data to database

//Required WiFiNINA Library for Arduino from https://github.com/arduino-libraries/WiFiNINA

include "Firebase_Arduino_WiFiNINA.h"

define DATABASE_URL "humid-sample.firebaseio.com" //.firebaseio.com or ..firebasedatabase.app

define DATABASE_SECRET "__"

define WIFISSID "____"

define WIFI_PASSWORD "__"

//Define Firebase data object FirebaseData fbdo;

void setup() {

Serial.begin(9600); delay(100); Serial.println();

Serial.print("Connecting to Wi-Fi"); int status = WL_IDLE_STATUS; while (status != WL_CONNECTED) { status = WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("."); delay(100); } Serial.println(); Serial.print("Connected with IP: "); Serial.println(WiFi.localIP()); Serial.println();

//Provide the autntication data Firebase.begin(DATABASE_URL, DATABASE_SECRET, WIFI_SSID, WIFI_PASSWORD); Firebase.reconnectWiFi(true);

String path = "/test"; String jsonStr;

Serial.print("Set int... ");

unsigned long long val = 1634631042000;

if (Firebase.setInt(fbdo, path + "/int/data", val)) //support large number { Serial.println("ok"); Serial.println("path: " + fbdo.dataPath()); Serial.println("type: " + fbdo.dataType()); Serial.print("value: "); if (fbdo.dataType() == "int") Serial.println(fbdo.intData()); if (fbdo.dataType() == "int64") Serial.println(fbdo.int64Data()); if (fbdo.dataType() == "uint64") Serial.println(fbdo.uint64Data()); else if (fbdo.dataType() == "double") Serial.println(fbdo.doubleData()); else if (fbdo.dataType() == "float") Serial.println(fbdo.floatData()); else if (fbdo.dataType() == "boolean") Serial.println(fbdo.boolData() == 1 ? "true" : "false"); else if (fbdo.dataType() == "string") Serial.println(fbdo.stringData()); else if (fbdo.dataType() == "json") Serial.println(fbdo.jsonData()); else if (fbdo.dataType() == "array") Serial.println(fbdo.arrayData()); } else { Serial.println("error, " + fbdo.errorReason()); }

Serial.println();

}

void loop() { }`

mobizt commented 2 years ago

I test your code with Arduino WiFi Rev2 and it works normally.

Please try to renew the database secret or test with another project.

mobizt commented 2 years ago

The project URL in your code was not found.

You can click this link to check https://humid-sample.firebaseio.com/

mobizt commented 2 years ago

The database URL should be taken from this

database url

Karl-Gil commented 2 years ago

Thank you for coming back to me, I made a new firebase and did as you instructed. Just to confirm, for the DATABASE_URL, do you use the full URL as you indicated in the image above, or do you just take your project id and then you insert .firebaseio.com. I tried both ways but am still getting an error. When using the full link I get an error connection refused and then when I try inserting my project id and then.firebaseio.com, I get the 404 error again. I tried on entering my new link into my browser and it doesn't seem to work again.

mobizt commented 2 years ago

What is your new database url?

mobizt commented 2 years ago

When you create new project, you will get the full database url as https://-default-rtdb..firebasedatabase.app/

Then the database URL defined in your sketch will be -default-rtdb..firebasedatabase.app

Karl-Gil commented 2 years ago

I think I left the "HTTPS" in the URL, but I changed it and it is working now, thank you very much :)