Closed msamoeed009 closed 3 years ago
The reasons can be your WiFi AP does not have the internet connectivity or the server is not valid.
First, try to reset router, change WiFi AP or connect via mobile WiFi hotspot.
Then, run this example to test your internet connection.
In Arduino IDE, select board, ESP32 Dev Module, select Files > Examples > HTTPClient > BasicHttpsClient
If you can run above example, the internet is ok otherwise not ok.
If internet is ok, make sure the DATABASE_URL defined in the Firebase example sketch is valid.
This is where you get the DATABASE_URL or FIREBASE_HOST in old examples
Thank you, it has started to work. Thank you for your help.
Hey there, I am having trouble trying to push an array of short into the cloudfirestore, i guess i dont understand the syntax of it. Is there a snippet that can help?
On Mon, May 24, 2021 at 1:29 AM Muhammad Abdul Moeed < @.***> wrote:
Thank you, it has started to work. Thank you for your help.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mobizt/Firebase-ESP32/issues/164#issuecomment-846876235, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANGJB2MSU7B2Y4IF2OXPAMDTPIE5NANCNFSM45MWUYPA .
You need to use Firebase ESP Client library This is the examples.
js.set("fields/watt/doubleValue/", measurements[0]); js.set("fields/current/arrayValue/", data); //data is an array of type short
js.toString(content);
Serial.print("Create a document... ");
(Firebase.Firestore.createDocument(&fbdo, FIREBASE_PROJECT_ID, "" / databaseId can be (default) or empty /, documentPath.c_str(), content.c_str() )); Serial.printf("ok\n%s\n\n", fbdo.payload().c_str());
Using this example but getting errors
On Wed, May 26, 2021 at 7:22 AM mobizt @.***> wrote:
You need to use Firebase ESP Client library https://github.com/mobizt/Firebase-ESP-Client This is the examples https://github.com/mobizt/Firebase-ESP-Client/tree/main/examples/Firestore .
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mobizt/Firebase-ESP32/issues/164#issuecomment-848811938, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANGJB2NS5TINTMIOZ7FXLRLTPT72JANCNFSM45MWUYPA .
You should post the error,
You need to post at the Firebase ESP Client repos instead of here.
Use Discussions to post the question as it is not the library issue.
Make sure your code at line js.set is valid.
FirebaseJson doc is here.
The field value when you construct it with FirebaseJon should follow this API reference.
https://cloud.google.com/firestore/docs/reference/rest/v1/Value
You need to learn Firestore concept and its API from Firestore document and you should known it well before use the library.
I can't provide Firebase products getting started or how to.
Ok, I will check.
String documentPath = String((auth.token.uid).c_str());
for (int x = 0; x < LOCAL_MEASUREMENTS - 1; x++) { data[x] = measurements[x]; }
js.set("fields/watt/doubleValue/", measurements[0]);
js.set("fields/current/arrayValue/", data); //data is an array of String. (GETTING ERROR HERE)
js.toString(content);
Serial.print("Create a document... ");
(Firebase.Firestore.createDocument(&fbdo, FIREBASE_PROJECT_ID, "" / databaseId can be (default) or empty /, documentPath.c_str(), content.c_str ())); Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); // else Serial.println(fbdo.errorReason()); }
//ERROR
Invalid value at 'document.fields[1].value.array_value' ( type.googleapis.com/google.firestore.v1.ArrayValue), \"\"
On Wed, May 26, 2021 at 8:06 AM mobizt @.***> wrote:
I can't provide Firebase products getting started or how to.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mobizt/Firebase-ESP32/issues/164#issuecomment-848848734, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANGJB2J3WFQW654GC4RSWPLTPUE73ANCNFSM45MWUYPA .
You need to learn Firestore before use.
If you understand the Firestore data structure well, you can create simple or complex data without the limit.
This is the example for create doc with field array
String content;
FirebaseJson js;
String documentPath = "test_collection/test_document";
for (size_t i = 0; i < 10;i++)
{
String filedPath = "fields/test_array/arrayValue/values/[" + String(i) + "]/stringValue";
String arrValue = "Hello World! " + String(i);
js.set(filedPath.c_str(), arrValue.c_str());
}
js.toString(content);
Serial.print("Create a document... ");
if (Firebase.Firestore.createDocument(&fbdo, FIREBASE_PROJECT_ID, "", documentPath.c_str(), content.c_str()))
Serial.printf("ok\n%s\n\n", fbdo.payload().c_str());
else
Serial.println(fbdo.errorReason());
Thanks a lot. I have not worked on C alot but have been using Firebase with dart, js and C# and never had issues. Sorry for the trouble.
On Wed, May 26, 2021 at 9:26 PM mobizt @.***> wrote:
If you understand the Firestore data structure well, you can create simple or complex data without the limit.
This is the example for create doc with field array
String content; FirebaseJson js;
String documentPath = "test_collection/test_document"; for (size_t i = 0; i < 10;i++) { String filedPath = "fields/test_array/arrayValue/values/[" + String(i) + "]/stringValue"; String arrValue = "Hello World! " + String(i); js.set(filedPath.c_str(), arrValue.c_str()); }
js.toString(content);
Serial.print("Create a document... "); if (Firebase.Firestore.createDocument(&fbdo, FIREBASE_PROJECT_ID, "", documentPath.c_str(), content.c_str())) Serial.printf("ok\n%s\n\n", fbdo.payload().c_str());else Serial.println(fbdo.errorReason());
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mobizt/Firebase-ESP32/issues/164#issuecomment-849309360, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANGJB2KNREWWAX5P6EB3LVDTPXCXJANCNFSM45MWUYPA .
The reasons can be your WiFi AP does not have the internet connectivity or the server is not valid.
First, try to reset router, change WiFi AP or connect via mobile WiFi hotspot.
Then, run this example to test your internet connection.
In Arduino IDE, select board, ESP32 Dev Module, select Files > Examples > HTTPClient > BasicHttpsClient
If you can run above example, the internet is ok otherwise not ok.
If internet is ok, make sure the DATABASE_URL defined in the Firebase example sketch is valid.
This is where you get the DATABASE_URL or FIREBASE_HOST in old examples
Could you reshare the image? shows not found
Connecting to Wi-Fi.
19:15:51.086 -> Connected with IP: 192.168.10.19 19:15:51.086 -> 19:15:51.086 -> Firebase Client v2.2.4 19:15:51.086 -> 19:15:51.121 -> Token info: type = id token, status = on request 19:17:53.910 -> Token info: type = id token, status = error 19:17:53.910 -> Token error: code: -5, message: connection lost 19:17:53.910 -> Token info: type = id token, status = on request 19:19:53.980 -> Token info: type = id token, status = error 19:19:54.014 -> Token error: code: -5, message: connection lost 19:19:54.014 -> Token info: type = id token, status = on request 19:20:12.409 -> Token info: type = id token, status = error 19:20:12.409 -> Token error: code: -5, message: connection lost 19:20:12.409 -> Token info: type = id token, status = on request
Internet is stable. Still getting this issue?