Im trying to make this example code to work but I can't see why it's keep telling me "bad request".
Any help would be appreciated.
Serial Monitor
Making Firebase request : [ 18543][V][WiFiClientImpl.h:317] tcpConnect(): Starting socket
bad request
---------------[ 34004][V][WiFiClientImpl.h:317] tcpConnect(): Starting socket
Set int... bad request
Making Firebase request : [ 34776][V][WiFiClientImpl.h:317] tcpConnect(): Starting socket
bad request
---------------[ 50540][V][WiFiClientImpl.h:317] tcpConnect(): Starting socket
Set int... bad request
Making Firebase request : [ 51107][V][WiFiClientImpl.h:317] tcpConnect(): Starting socket
bad request
---------------[ 66720][V
Code
/**
* Created by K. Suwatchai (Mobizt)
*
* Email: k_suwatchai@hotmail.com
*
* Github: https://github.com/mobizt/Firebase-ESP8266
*
* Copyright (c) 2023 mobizt
*
*/
/** This example will show how to access the RTDB in Test Mode (no authentication).
*/
#include <Arduino.h>
#include <WiFi.h>
#include <FirebaseESP32.h>
// Provide the RTDB payload printing info and other helper functions.
#include <addons/RTDBHelper.h>
/* 1. Define the WiFi credentials */
#define WIFI_SSID "####"
#define WIFI_PASSWORD "####"
/* 2. Define the RTDB URL */
#define DATABASE_URL "https://##########.firebasedatabase.app" //<databaseName>.firebaseio.com or <databaseName>.<region>.firebasedatabase.app
/* 3. Define the Firebase Data object */
FirebaseData fbdo;
/* 4, Define the FirebaseAuth data for authentication data */
FirebaseAuth auth;
/* Define the FirebaseConfig data for config data */
FirebaseConfig config;
unsigned long dataMillis = 0;
int count = 0;
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();
Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION);
/* Assign the certificate file (optional) */
// config.cert.file = "/cert.cer";
// config.cert.file_storage = StorageType::FLASH;
/* Assign the database URL(required) */
config.database_url = DATABASE_URL;
config.signer.test_mode = true;
/**
Set the database rules to allow public read and write.
{
"rules": {
".read": true,
".write": true
}
}
*/
// Comment or pass false value when WiFi reconnection will control by your code or third party library e.g. WiFiManager
Firebase.reconnectNetwork(true);
// Since v4.4.x, BearSSL engine was used, the SSL buffer need to be set.
// Large data transmission may require larger RX buffer, otherwise connection issue or data read time out can be occurred.
//fbdo.setBSSLBufferSize(4096 /* Rx buffer size in bytes from 512 - 16384 */, 1024 /* Tx buffer size in bytes from 512 - 16384 */);
/* Initialize the library with the Firebase authen and config */
Firebase.begin(&config, &auth);
}
void update_data() {
Serial.print("\n Making Firebase request : ");
FirebaseJson updateData;
FirebaseJson json;
json.set("_data2", "_value2");
updateData.set("data1", "value1");
updateData.set("data2", json);
if (Firebase.updateNode(fbdo, "/test/update", updateData)) {
Serial.println(fbdo.dataPath());
Serial.println(fbdo.dataType());
Serial.println(fbdo.jsonString());
} else {
Serial.println(fbdo.errorReason());
}
}
void loop() {
for (int i = 0; i < 15; i++) {
delay(1000);
Serial.print("-");
}
Serial.printf("Set int... %s\n", Firebase.setInt(fbdo, "/test/int", count++) ? "ok" : fbdo.errorReason().c_str());
update_data();
}
Hello !
Im trying to make this example code to work but I can't see why it's keep telling me "bad request".
Any help would be appreciated.
Serial Monitor
Code