I was trying to make my Arduino to read the temperature of my room and send it to real time database, so I could access it easily, but when connecting it crash saying "Bus fault is caused by precise data access violation". I tried to use a library for HTTPS, thinking it was the problem but nothing.
One thing that I noted is that if I connect to "firebaseapp.com" not crash, but when trying to connect to "arduino-r4-ambient-default-rtdb.europe-west1.firebasedatabase.app" it does.
When connecting to "europe-west1.firebasedatabase.app" ERROR.mConnectBasicClient: Failed to connect to server using basic client.
This is the code that I used: I removed some lines that I do not use, like "sendToFirebase" function and some #define constant containg firebase keys
#include <Arduino.h>
#include "WiFiS3.h"
#include <ESP_SSLClient.h>
ESP_SSLClient ssl_client;
WiFiClient basic_client;
#define SSID "TIM-88519218"
#define PASSWORD "*************"
const char* firebaseHost = "arduino-r4-ambient-default-rtdb.europe-west1.firebasedatabase.app"; // /v1/projects/arduino-r4-ambient/databases/(default)/documents/ambient
int status = WL_IDLE_STATUS;
void connectFB() {
//WiFiClient client;
Serial.println("mi sto per connettere");
bool connectionResult = ssl_client.connect(firebaseHost, 443);
delay(1000);
Serial.print("Connection result: ");
Serial.println(connectionResult ? "Success" : "Failed");
if (connectionResult) {
Serial.println("aaaoooooo");
delay(500);
ssl_client.stop();
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
String fv = WiFi.firmwareVersion();
if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
Serial.println("Please upgrade the firmware");
}
status = WiFi.begin(SSID, PASSWORD);
delay(10000);
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
long rssi = WiFi.RSSI();
Serial.print("Signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
ssl_client.setInsecure();
ssl_client.setBufferSizes(1024 /* rx */, 1024 /* tx */);
ssl_client.setDebugLevel(1);
ssl_client.setClient(&basic_client);
connectFB();
//sendToFirebase(30, 67);
}
void loop() {
// put your main code here, to run repeatedly:
}
and this is the result in the Serial monitor
17:36:44.163 -> addr: 20007e5c data: 00000000
17:36:44.291 -> addr: 20007e60 data: 00000000
17:36:44.291 -> addr: 20007e64 data: 00017c00
17:36:44.291 -> addr: 20007e68 data: 200002a0
17:36:44.455 -> addr: 20007e6c data: 000001bb
17:36:44.455 -> addr: 20007e70 data: 0001f51a
17:36:44.455 -> addr: 20007e74 data: 00015281
17:36:44.587 -> addr: 20007e78 data: 0000a500
17:36:44.587 -> addr: 20007e7c data: 00017cdd
17:36:44.587 -> addr: 20007e80 data: 20000278
17:36:44.587 -> addr: 20007e84 data: 000153cf
17:36:44.719 -> addr: 20007e88 data: ffffffc6
17:36:44.719 -> addr: 20007e8c data: 00004040
17:36:44.719 -> addr: 20007e90 data: ffffffc6
17:36:44.850 -> addr: 20007e94 data: 00004040
17:36:44.850 -> addr: 20007e98 data: 0000a500
17:36:44.850 -> addr: 20007e9c data: 00004129
17:36:44.982 -> addr: 20007ea0 data: ffffffc6
17:36:44.982 -> addr: 20007ea4 data: 00004287
17:36:44.982 -> addr: 20007ea8 data: 20000fcc
17:36:44.982 -> addr: 20007eac data: 200016d0
17:36:45.145 -> addr: 20007eb0 data: 00000005
17:36:45.145 -> addr: 20007eb4 data: 00000005
17:36:45.145 -> addr: 20007eb8 data: 0002513c
17:36:45.278 -> addr: 20007ebc data: 00000000
17:36:45.278 -> addr: 20007ec0 data: 00000000
17:36:45.278 -> addr: 20007ec4 data: 00000000
17:36:45.411 -> addr: 20007ec8 data: 4bb2a8c0
17:36:45.411 -> addr: 20007ecc data: 00000000
17:36:45.411 -> addr: 20007ed0 data: 00000000
17:36:45.411 -> addr: 20007ed4 data: 00017fb5
17:36:45.542 -> addr: 20007ed8 data: 000251f9
17:36:45.542 -> addr: 20007edc data: 40046f00
17:36:45.542 -> addr: 20007ee0 data: 00000000
17:36:45.673 -> addr: 20007ee4 data: 00017ff7
17:36:45.673 -> addr: 20007ee8 data: 000251f9
17:36:45.673 -> addr: 20007eec data: 000154ab
17:36:45.804 -> addr: 20007ef0 data: 000251f9
17:36:45.804 -> addr: 20007ef4 data: 000159f3
17:36:45.804 -> addr: 20007ef8 data: 000159e9
17:36:45.804 -> addr: 20007efc data: 00002599
17:36:45.967 -> ====================================
17:36:45.967 -> =================== Registers information ====================
17:36:46.097 -> R0 : 65726966 R1 : 0001fe8c R2 : 00000000 R3 : 20000402
17:36:46.097 -> R12: 20007cf3 LR : 000049e3 PC : 00017ae6 PSR: 410f0000
17:36:46.229 -> ==============================================================
17:36:46.229 -> Bus fault is caused by precise data access violation
17:36:46.360 -> The bus fault occurred address is 65726966
17:36:46.360 -> Show more call stack info by run: addr2line -e "/private/var/folders/kd/fclmfxnx21j2lfds68750yvc0000gn/T/arduino/sketches/53F834E1D0402592C13E101BE50B98A0/upload-dh11-to-firebase.ino".elf -a -f 00017ae6 000049e2 0000541e 00005894 00014bfa 0001c758 00015250 00015280 00017cdc 000153ce 00004128 00004286 00017fb4 00017ff6 000154aa 000159f2
If I run addr2line command it says that the line is
bool connectionResult = ssl_client.connect(firebaseHost, 443);
Does someone had the same problem? I try to search on google and asked to chatGPT but I found nothing.