Coder Social home page Coder Social logo

Comments (46)

mobizt avatar mobizt commented on June 4, 2024

First, update the library to latest version.
Then test and post your working code that expect to be issue.

The decoded stack was not complete, nothing related to the main task.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

Just updated to version 2.1.6 as you said. Still crashes on me sadly..

`Exception (3):
epc1=0x401003e9 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4000bf21 depc=0x00000000

ctx: cont
sp: 3ffffb50 end: 3fffffd0 offset: 01a0

stack>>>
3ffffcf0: 3fffc278 40101fdc 3fffc200 00000022
3ffffd00: 3ffea770 00000076 ff000000 0000007d
3ffffd10: 4021b6c5 00000030 00000018 ffffffff
3ffffd20: 4020a76c 3ffffe13 3fff5454 00000061
3ffffd30: 00000065 00000070 ff000000 0000007d
3ffffd40: 00000000 3ffffe32 000000ff 00000000
3ffffd50: 3fff1ad4 3fff5454 3ffffe40 3fff14fc
3ffffd60: 0000002c 3ffef964 00000039 401004e4
3ffffd70: 3fff1ef9 7fffffff 00000039 4020f2bc
3ffffd80: 0000ff00 00ff0000 0000002c 4021bb48
3ffffd90: 3fff1ef9 00000000 00000000 4021bc4e
3ffffda0: 00000022 00000000 3fff1e1c 40225ec7
3ffffdb0: 00000000 00000003 0000002c f732bb2b
3ffffdc0: 16cf6584 a6f019d2 3ddc3ccf 3fff14fc
3ffffdd0: 00000000 0000002c 3ffef964 4021bcfc
3ffffde0: 3ffffe38 3a226874 3ffe865c 3fff5700
3ffffdf0: 3fff14fc 0000002c 3ffef964 4021bda2
3ffffe00: 00000003 3fff56f4 3fff1e1c 4022639c
3ffffe10: 64747570 3a617461 70227b20 3fff1ad4
3ffffe20: 3fff5454 7fffffff 3ffef964 4021bdd0
3ffffe30: 3fff14fc 3a226174 7d343731 3fffefb0
3ffffe40: 3fff5454 000000ff 3ffef8b0 4021bde4
3ffffe50: 3fff5454 7fffffff 3ffef8b0 4020d9b0
3ffffe60: 3fffc200 40106bac 00000020 40106bf4
3ffffe70: 40213fa8 00000000 00003a98 4000050c
3ffffe80: 3fffff20 3fff18b4 3fff1d9c 3fff18ec
3ffffe90: 40208fd0 00000001 4020f498 00000000
3ffffea0: 3ffefe0c 00000000 00000000 fffffffe
3ffffeb0: 3fff52bc 3ffefb58 00000001 3fff14fc
3ffffec0: 00000000 00000000 3ffef944 00000001
3ffffed0: 00000000 3ffef950 0000000c 00000001
3ffffee0: 00000001 000035c0 00000000 3ffef960
3ffffef0: 00000000 00000001 3ffef8b0 4021bb9e
3fffff00: 3fffff20 00000032 00000032 00000032
3fffff10: 00000000 3ffefb58 3ffef8b0 4020e4b0
3fffff20: 40213fa8 00000000 00003a98 4020266a
3fffff30: 3ffef9b4 3fff18b4 3fff1d9c 3fff18ec
3fffff40: 3ffefe0c 3ffefe0c 3ffe865c 3ffefc40
3fffff50: 3fff0674 402093b8 4020f42c 3ffefbec
3fffff60: 3ffef8b0 3ffefb58 3ffefb40 4020e553
3fffff70: 3fffdad0 3ffef8b0 3ffefbe4 40208b38
3fffff80: 00000000 00000000 00000000 00000000
3fffff90: 00000000 00000000 00000000 3ffefbec
3fffffa0: 3fffdad0 00000000 3ffefbe4 40208fd0
3fffffb0: 3fffdad0 00000000 3ffefbe4 4020f4b8
3fffffc0: feefeffe feefeffe 3ffe865c 40100721
<<<stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
vbb28d4a3
~ld`

0x4021b6c5: strstr at ../../../.././newlib/libc/string/strstr.c line 62 0x4021bb48: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator const&) at /Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 619 0x4021bc4e: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) at /Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 479 0x40225ec7: basic_read at ssl/tls1.c line 1374 0x4021bcfc: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) at /Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 685 0x4021bda2: std::string::assign(char const*, unsigned int) at /Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 276 0x4022639c: ssl_read at ssl/tls1.c line 314 0x4021bdd0: std::string::assign(char const*) at /Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 1132 0x4021bde4: std::string::operator=(char const*) at /Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 555 0x4021bb9e: std::basic_string , std::allocator >::~basic_string() at /Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 539

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Post your sketch.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

Sketch:

#include <Arduino.h>
#include <string>
#include "FirebaseESP8266.h"
#include <ESP8266WiFi.h>
#include <ArduinoJson.h>

#define JSON_SIZE 323 // calculated the size based on the json output from Firebase https://arduinojson.org/v6/assistant/

#define RELAY_1 D9
#define RELAY_2 D8
#define RELAY_3 D7
#define RELAY_4 D6
#define RELAY_5 D5
#define RELAY_6 D4
#define RELAY_7 D3
#define RELAY_8 D2

#define RELAY_1_PATH "/relays/relay_1"
#define RELAY_2_PATH "/relays/relay_2"
#define RELAY_3_PATH "/relays/relay_3"
#define RELAY_4_PATH "/relays/relay_4"
#define RELAY_5_PATH "/relays/relay_5"
#define RELAY_6_PATH "/relays/relay_6"
#define RELAY_7_PATH "/relays/relay_7"
#define RELAY_8_PATH "/relays/relay_8"

#define LED_1_R "/ledstrip-1/r"
#define LED_1_G "/ledstrip-1/g"
#define LED_1_B "/ledstrip-1/b"
#define LED_1_BRIGHTNESS "/ledstrip-1/brightness"
#define LED_MAX_BRIGHTNESS 255

#define RELAY_ON HIGH
#define RELAY_OFF LOW

#define FIREBASE_HOST "aa.firebaseio.com"
#define FIREBASE_AUTH "aa"
#define WIFI_SSID "aa"
#define WIFI_PASSWORD "aa"

StaticJsonDocument<JSON_SIZE> doc;

FirebaseData firebaseData;

struct Relay {
  int pin;

  String path;
};

struct LedStrip {
  int rPin;
  int gPin;
  int bPin;
  int brightnessValue;
  int rValue;
  int gValue;
  int bValue;
};

struct Relay relay1;
struct Relay relay2;
struct Relay relay3;
struct Relay relay4;
struct Relay relay5;
struct Relay relay6;
struct Relay relay7;
struct Relay relay8;

struct Relay relays[8];

struct LedStrip ledStrip;

void SetupRelays();
void handleDataStream();
void checkRelayData(String, int);
void checkLedData(String, int);
void resetRelay(struct Relay *r, String, int);
int calculateLedValue(int);


void setup() {
  Serial.begin(115200);

  // Set all relay pins to output (LOW), LOW = no closed circuit
  SetupRelays();

  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();

  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
  Firebase.reconnectWiFi(true);
  // Firebase.setMaxRetry(firebaseData, 0);

    Serial.println("Starting streaming connection");
    
  if (!Firebase.beginStream(firebaseData, "stream-data")) {
    Serial.println("------------------------------------");
    Serial.println("Can't begin stream connection...");
    Serial.println("REASON: " + firebaseData.errorReason());
    Serial.println("------------------------------------");
    Serial.println();
  }
  
  ledStrip.rPin = D10;
  ledStrip.gPin = D11;
  ledStrip.bPin = D12;

  pinMode(ledStrip.rPin, OUTPUT);
  pinMode(ledStrip.gPin, OUTPUT);
  pinMode(ledStrip.bPin, OUTPUT);
}

void loop() {
  handleDataStream();
}

void handleDataStream() {
  if (!Firebase.readStream(firebaseData)) {
    Serial.println("Stream error:");
    Serial.println(firebaseData.errorReason());
  }

  if (firebaseData.streamTimeout()) {
    Serial.println("Stream timeout, resume streaming...");
    Serial.println();
  }

  if (firebaseData.streamAvailable()) {
    Serial.println("\nIncomming data...");
    Serial.println(firebaseData.dataType());
    Serial.println(firebaseData.dataPath());

    if (firebaseData.dataType() == "int") {
      Serial.println(firebaseData.intData());

      checkRelayData(firebaseData.dataPath(), firebaseData.intData());
      checkLedData(firebaseData.dataPath(), firebaseData.intData());
    }

    else if (firebaseData.dataType() == "float")
      Serial.println(firebaseData.floatData(), 5);

    else if (firebaseData.dataType() == "double")
      Serial.printf("%.9lf\n", firebaseData.doubleData());

    else if (firebaseData.dataType() == "boolean")
      Serial.println(firebaseData.boolData() == 1 ? "true" : "false");

    else if (firebaseData.dataType() == "string")
      Serial.println(firebaseData.stringData());

    else if (firebaseData.dataType() == "json") {
      Serial.println(firebaseData.jsonData());

      DeserializationError error = deserializeJson(doc, firebaseData.jsonData());

      if (error) {
        Serial.print(F("deserializeJson() failed: "));
        Serial.println(error.c_str());
        return;
      }

      digitalWrite(relay1.pin, ((int) doc["relays"]["relay_1"]) > 0 ? 1 : 0);
      delay(100);
      digitalWrite(relay2.pin, ((int) doc["relays"]["relay_2"]) > 0 ? 1 : 0);
      delay(100);
      digitalWrite(relay3.pin, ((int) doc["relays"]["relay_3"]) > 0 ? 1 : 0);
      delay(100);
      digitalWrite(relay4.pin, ((int) doc["relays"]["relay_4"]) > 0 ? 1 : 0);
      delay(100);
      digitalWrite(relay5.pin, ((int) doc["relays"]["relay_5"]) > 0 ? 1 : 0);
      delay(100);
      digitalWrite(relay6.pin, ((int) doc["relays"]["relay_6"]) > 0 ? 1 : 0);
      delay(100);
      digitalWrite(relay7.pin, ((int) doc["relays"]["relay_7"]) > 0 ? 1 : 0);
      delay(100);
      digitalWrite(relay8.pin, ((int) doc["relays"]["relay_8"]) > 0 ? 1 : 0);
      delay(100);

      ledStrip.brightnessValue = (int) doc["ledstrip-1"]["brightness"];

      ledStrip.brightnessValue = ledStrip.brightnessValue > 255 ? LED_MAX_BRIGHTNESS : ledStrip.brightnessValue;
      ledStrip.brightnessValue = ledStrip.brightnessValue < 0 ? 0 : ledStrip.brightnessValue;

      ledStrip.rValue = (int) doc["ledstrip-1"]["r"];
      delay(100);
      ledStrip.gValue = (int) doc["ledstrip-1"]["g"];
      delay(100);
      ledStrip.bValue = (int) doc["ledstrip-1"]["b"];

      analogWrite(ledStrip.rPin, calculateLedValue(ledStrip.rValue));
      delay(100);
      analogWrite(ledStrip.gPin, calculateLedValue(ledStrip.gValue));
      delay(100);
      analogWrite(ledStrip.bPin, calculateLedValue(ledStrip.bValue));
      delay(100);

    }
    
  }
}

int calculateLedValue(int value) {
  // Serial.println("Calucalting brightness");

  // float brightnessPercentage = ((float) ledStrip.brightnessValue) / ((float) LED_MAX_BRIGHTNESS);
  // Serial.println(brightnessPercentage);

  // float color = ((float) value) * brightnessPercentage;
  // Serial.println(color);
  // Serial.println((int) color);

  // return (int) color;

  return value;
}

void checkRelayData(String path, int i) {
  // TODO -> check if contains relay

  for (struct Relay r : relays) {
    if (!r.path.equalsIgnoreCase(path)) continue;

    Serial.println("Relay changed Pin:");
    Serial.println(r.pin);

    digitalWrite(r.pin, i);
    break;
  }
}

void checkLedData(String path, int i) {
  // TODO -> check if contains ledstrip

  if (path.equalsIgnoreCase(LED_1_R)) {
    Serial.println("Led Red value changed.");
    
    ledStrip.rValue = i;
    analogWrite(ledStrip.rPin, calculateLedValue(ledStrip.rValue));
  }
  else if (path.equalsIgnoreCase(LED_1_G)) {
    Serial.println("Led Green value changed.");

    ledStrip.gValue = i;
    analogWrite(ledStrip.gPin, calculateLedValue(ledStrip.gValue));
  }
  else if (path.equalsIgnoreCase(LED_1_B)) {
    Serial.println("Led Blue value changed.");

    ledStrip.bValue = i;
    analogWrite(ledStrip.bPin, calculateLedValue(ledStrip.bValue));
  }
  else if (path.equalsIgnoreCase(LED_1_BRIGHTNESS)) {
    Serial.println("Led Brightness value changed.");

    ledStrip.brightnessValue = i;

    ledStrip.brightnessValue = ledStrip.brightnessValue > 255 ? LED_MAX_BRIGHTNESS : ledStrip.brightnessValue;
    ledStrip.brightnessValue = ledStrip.brightnessValue < 0 ? 0 : ledStrip.brightnessValue;

    analogWrite(ledStrip.rPin, calculateLedValue(ledStrip.rValue));
    analogWrite(ledStrip.gPin, calculateLedValue(ledStrip.gValue));
    analogWrite(ledStrip.bPin, calculateLedValue(ledStrip.bValue));
  }
}

void SetupRelays() {
  resetRelay(&relay1, RELAY_1_PATH, RELAY_1);
  resetRelay(&relay2, RELAY_2_PATH, RELAY_2);
  resetRelay(&relay3, RELAY_3_PATH, RELAY_3);
  resetRelay(&relay4, RELAY_4_PATH, RELAY_4);
  resetRelay(&relay5, RELAY_5_PATH, RELAY_5);
  resetRelay(&relay6, RELAY_6_PATH, RELAY_6);
  resetRelay(&relay7, RELAY_7_PATH, RELAY_7);
  resetRelay(&relay8, RELAY_8_PATH, RELAY_8);

  relays[0] = relay1; 
  relays[1] = relay2; 
  relays[2] = relay3; 
  relays[3] = relay4; 
  relays[4] = relay5; 
  relays[5] = relay6; 
  relays[6] = relay7; 
  relays[7] = relay8; 

  for (struct Relay i : relays) {
    pinMode(i.pin, OUTPUT);
    delay(100);
  }
}

void resetRelay(struct Relay *r, String path, int pin) {
  r->path = path;
  r->pin = pin;
}

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

It's better, if you pin point where is the possible lines of code that cause the issue.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

Just edited the loop for you:

void loop() {
 handleDataStream();
}

void handleDataStream() {
 if (!Firebase.readStream(firebaseData)) {
   Serial.println("Stream error:");
   Serial.println(firebaseData.errorReason());
 }

 if (firebaseData.streamTimeout()) {
   Serial.println("Stream timeout, resume streaming...");
   Serial.println();
 }

 if (firebaseData.streamAvailable()) {
   // CRASHES before it can print  "incomming data..."
   Serial.println("\nIncomming data...");
 }
}

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

If I change something by hand in firebase it works fine. But when I change 3 or more within half a second it crashes.

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

It's not caused by library by that basic usage.
You need to check free heap to make sure your no memory leak.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

It gives an exception(3) which could lead to a memory leak which is true... any advice on how to tackle that problem?

EDIT:

Also found out if I send messages at 1500 ms interval the system won't crash.

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Where is the line that you "send messages"?
You need to print ESP.getFreeHeap() before and after some function call or anywhere you want.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

This ESP just listens to the firebase without sending messages to firebase. I will search around with the ESP.getFreeHeap() function and see if I can find any memory leaks.

Thanks for all the help you've given me!

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Make sure you test long enough and under all possible cases.

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Be careful when you're using Wemos D1 which it's pins assignment are redundant.
Check this.

For variable declaration

Use

 Relay relay1;
 Relay relay2;
 Relay relay3;
 Relay relay4;
 Relay relay5;
 Relay relay6;
 Relay relay7;
 Relay relay8;

 Relay relays[8];

 LedStrip ledStrip;

instead of

struct Relay relay1;
struct Relay relay2;
struct Relay relay3;
struct Relay relay4;
struct Relay relay5;
struct Relay relay6;
struct Relay relay7;
struct Relay relay8;

struct Relay relays[8];

struct LedStrip ledStrip;

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

I was aware of that yes! I heard from a friend of mine it is possible to fix the issue with the pins but I have to search for it. If I cannot find it I'm probably going to use another ESP for the leds and seperate the leds from the relays. Thanks for the notice!

Is declaring variables in such a manner better for heap size? If I want to declare it like you said I should then I should typedef the struct of the relays and ledstrip right?

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Not sure I understand your last paragraph.
It's not relate to heap but for valid syntax which prevent unexpected result when it compiled by compiler.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

Been testing around with ESP.getFreeHeap(). I start around 43528 bytes of free heap. After setting up the firebase I have 28384 bytes free. After making a ton of calls to the firebase with an interval of 2 seconds per call the free heap remains, +-100 bytes off, the same. The moment I make the interval between the calls quicker it starts to be unstable. At 1.5 seconds it crashes 10% of the time and it grows exponentionally after that. At 1 second per call it's around 30% of the time, 500ms it's around 70% of the calls and without interval it crashes 100% of the time.

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

The microcontroller programming is different from PC which you can easily debug.
You need to track by serial print at any check point.

You will find where code stop or device reboot. As in the example sketch, there is no blocking code or delay in the loop which the delay is not the cause of problem unless you will miss the change of data.

The decoded stacks are not show anything relate to the main tasks i.e. setup() and loop() which means it might not cause by program.

For schedule tasks, I recommend the ticker and let the stream to read inside the loop without delay to catch up all data changes.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

Also found something else out. After testing and a lot of crashing it seems that the program crashes right before printing the heap size in the following piece of code:

if (firebaseData.streamAvailable()) {
   Serial.println("\nIncomming data...");
   Serial.println("Heapsize before receiving data: ");
   // <- crash
   Serial.println(system_get_free_heap_size());
   // ...
}

EDIT:
I also made a simpler piece of code with a different ESP8266 I had laying around, it only has the bare basics in it. And with this if a value gets changed within a short interval with another value it also crashes the ESP. I'm considering on just reading out the Firebase database every so often and filter the JSON. This is giving me a headache hahaha.

Code:

FirebaseData firebaseData;

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();

 Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
 Firebase.reconnectWiFi(true);

 if (!Firebase.beginStream(firebaseData, "stream-data")) {
   Serial.println("------------------------------------");
   Serial.println("Can't begin stream connection...");
   Serial.println("REASON: " + firebaseData.errorReason());
   Serial.println("------------------------------------");
   Serial.println();
 }
}

void loop() {
 if (!Firebase.readStream(firebaseData)) {
   Serial.println("Stream error:");
   Serial.println(firebaseData.errorReason());
 }

 if (firebaseData.streamTimeout()) {
   Serial.println("Stream timeout, resume streaming...");
   Serial.println();
 }

 if (firebaseData.streamAvailable()) {
   Serial.println("\nIncomming data...");
   Serial.println(firebaseData.dataType());
   Serial.println(firebaseData.dataPath());
 }
}

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Same stack trace result?
Can you test your sketch with Arduino IDE? and use ESP Exception Decoder from me-no-dev.

The stack trace result might be different.

For the decoder tool from ivan grokhotkov. He is well known expert, works for Espressif and handle a lot of ESP8266 and ESP32 Arduino Core libraries.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

Yes just done it. The Stack trace is way different actually.

Decoded stack:

0x402017aa: FirebaseESP8266::errorToString(int, std::string&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 3704
0x4020c029: Print::write(char const*) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/Print.h line 60
0x40202f24: FirebaseData::errorReason() at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 5040
0x4020c100: Print::println(char const*) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\Print.cpp line 190
0x4020119c: loop() at C:\Users\joshu\Documents\Arduino\FirebaseStreamingWemosD1R2Mini/FirebaseStreamingWemosD1R2Mini.ino line 43
0x4020c7a1: esp_schedule() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 95
0x4020c830: loop_wrapper() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 125```

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Try to comment out firebaseData.errorReason() from your code.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

Did that the moment you posted it. Got a new stack now.

Decoded stack:

0x4021e1ae: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x4020ecc0: malloc(size_t) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1677
0x4021e1ae: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x4021e3ac: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator  const&) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 621
0x4021e4b2: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 481
0x4022a2eb: basic_read at ssl/tls1.c line 1374
0x4021e560: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 687
0x4021e606: std::string::assign(char const*, unsigned int) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 278
0x4021e634: std::string::assign(char const*) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 1134
0x4020c76c: esp_yield() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 91
0x4021e648: std::string::operator=(char const*) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 557
0x40204dcb: FirebaseESP8266::getServerResponse(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 2248
0x40205d5f: ESP8266WiFiSTAClass::status() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 628
0x4021e402: std::basic_string  , std::allocator  >::~basic_string() at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 541
0x40205778: FirebaseESP8266::getServerStreamResponse(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 3063
0x4020bd78: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/HardwareSerial.h line 158
0x4020bd78: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/HardwareSerial.h line 158
0x40205d50: ESP8266WiFiSTAClass::status() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 613
0x4020581b: FirebaseESP8266::readStream(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 1311
0x4020118b: loop() at C:\Users\joshu\Documents\Arduino\FirebaseStreamingWemosD1R2Mini/FirebaseStreamingWemosD1R2Mini.ino line 41
0x4020c78d: esp_schedule() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 95
0x4020c81c: loop_wrapper() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 125

Line 41 in the loop is the line which says:

 if (!Firebase.readStream(firebaseData)) { } 

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Found som improper use of basic string join with progmem chars array in my code that works with Core SDK v2.5.x and can cause error in lower version.

Try to edit file FirebaseESP8266.cpp line 5042 and 5043 from

buff += ESP8266_FIREBASE_STR_132;
buff += ESP8266_FIREBASE_STR_6;

to

char *str = new char[100];
memset(str, 0, 100);
strcpy_P(str, ESP8266_FIREBASE_STR_132);
buff +=str;
memset(str, 0, 100);
strcpy_P(str, ESP8266_FIREBASE_STR_6);
buff +=str;
delete[] str;

Edited: update the correct syntax.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

Alright, done that. It now looks like the following:

if (_firebaseError != "")
    {
        //buff += ESP8266_FIREBASE_STR_132;
        //buff += ESP8266_FIREBASE_STR_6;
		char *str = new char[100];
		memset(str, 0, 100);
		strcpy_P(str, ESP8266_FIREBASE_STR_132);
		buff +=str;
		memset(str, 0, 100);
		strcpy_P(str, ESP8266_FIREBASE_STR_6);
		buff +=str;
		delete[] str;
        buff += _firebaseError;
    }

I compiled the code successfully and uploaded it on the ESP. Once uploaded it throws an occasional (every 10 seconds ish) stack trace.

decoded stack trace:

0x402017aa: FirebaseESP8266::errorToString(int, std::string&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 3704
0x4020c065: Print::write(char const*) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/Print.h line 60
0x40202f27: FirebaseData::errorReason() at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 5040
0x40205da0: ESP8266WiFiSTAClass::status() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 613
0x4020c0f0: Print::println() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\Print.cpp line 178
0x4020119c: loop() at C:\Users\joshu\Documents\Arduino\FirebaseStreamingWemosD1R2Mini/FirebaseStreamingWemosD1R2Mini.ino line 43
0x4020c7dd: esp_schedule() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 95
0x4020c86c: loop_wrapper() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 125

Line 43 points to the:

Serial.println(firebaseData.errorReason());

Also when I send multiple data lines via the stream I get another stack trace, different one though.

Decoded stacktrace:

0x4021e1fe: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x4020ed10: malloc(size_t) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1677
0x4021e1fe: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x4021e3fc: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator  const&) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 621
0x4021e502: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 481
0x4022a33b: basic_read at ssl/tls1.c line 1374
0x4021e5b0: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 687
0x4021e656: std::string::assign(char const*, unsigned int) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 278
0x4021e684: std::string::assign(char const*) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 1134
0x4020c7bc: esp_yield() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 91
0x4021e698: std::string::operator=(char const*) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 557
0x40204e1b: FirebaseESP8266::getServerResponse(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 2248
0x4021e452: std::basic_string  , std::allocator  >::~basic_string() at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 541
0x402057c8: FirebaseESP8266::getServerStreamResponse(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 3063
0x4020bdc8: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/HardwareSerial.h line 158
0x4020bdc8: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/HardwareSerial.h line 158
0x40205da0: ESP8266WiFiSTAClass::status() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 613
0x4020586b: FirebaseESP8266::readStream(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 1311
0x40201188: loop() at C:\Users\joshu\Documents\Arduino\FirebaseStreamingWemosD1R2Mini/FirebaseStreamingWemosD1R2Mini.ino line 41
0x4020c7dd: esp_schedule() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 95
0x4020c86c: loop_wrapper() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 125

Edit:
When I comment:

Serial.println(firebaseData.errorReason());

It stops the occasional stack. But it still gives the error when sending multiple datalines via firebase. But it does print out "Stream error:", with nothing below to it which is logical.

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

At this time you can print firebaseData.httpCode() instead of error reason.

Serial.println(firebaseData.httpCode());

The value of above code described in this header file from line 43 to 91.

What is ESP8266 Arduino Core SDK version you installed (the esp8266 lib and toolchains installed via boards manager)?

Recommend to update to 2.5.x

In platformio type platformio update in console

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

The errorcode I get from using firebaseData.httpCode() is: -4. According to the file you mentioned earlier this means it is the following error: HTTPC_ERROR_NOT_CONNECTED. Which is weird because when I update data on firebase it gets displayed in the monitor, so it should be connected?

The ESP8266 Arduino Core SDK version is: 2.5.2

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

Also right now I get the following stacktrace when updating multiple lines in my firebase database:

0x40227fe8: mem_malloc at core/mem.c line 210
0x4020ed94: malloc(size_t) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1677
0x40220a98: lwip_cyclic_timer at core/timeouts.c line 233
0x40227fe8: mem_malloc at core/mem.c line 210
0x4010014c: millis() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_wiring.cpp line 186
0x4021f3d8: do_memp_malloc_pool at core/memp.c line 254
0x4021f414: memp_malloc at core/memp.c line 356
0x40220a98: lwip_cyclic_timer at core/timeouts.c line 233
0x40220a3d: sys_timeout_abs at core/timeouts.c line 189
0x40220a98: lwip_cyclic_timer at core/timeouts.c line 233
0x40220acb: lwip_cyclic_timer at core/timeouts.c line 261
0x4021f43e: memp_free at core/memp.c line 447
0x40220c40: sys_check_timeouts at core/timeouts.c line 390
0x4020c7fb: loop_task(ETSEvent*) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 133
0x4022e058: bi_subtract at crypto/bigint.c line 331
0x4022e04a: bi_subtract at crypto/bigint.c line 324
0x4022dc92: bi_free at crypto/bigint.c line 219
0x4022dc92: bi_free at crypto/bigint.c line 219
0x40232cd1: SHA256_Final at crypto/sha256.c line 273
0x4022f094: hmac_sha256_v at crypto/hmac.c line 165
0x40232c61: SHA256_Final at crypto/sha256.c line 254
0x4022f094: hmac_sha256_v at crypto/hmac.c line 165
0x40232cd1: SHA256_Final at crypto/sha256.c line 273
0x4022f094: hmac_sha256_v at crypto/hmac.c line 165
0x40234094: add_hmac_digest at ssl/tls1.c line 793
0x4022a83c: basic_read at ssl/tls1.c line 1472
0x40201ad5: FirebaseESP8266::strpos(char const*, char const*, int) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 4669
0x40201ad5: FirebaseESP8266::strpos(char const*, char const*, int) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 4669
0x4020c840: esp_yield() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 91
0x4020c840: esp_yield() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 91
0x4020c922: __yield() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 100
0x40204717: FirebaseESP8266::getServerResponse(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 1958
0x4021e4da: std::basic_string  , std::allocator  >::~basic_string() at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 541
0x402057c4: FirebaseESP8266::getServerStreamResponse(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 3063
0x4020bdc4: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/HardwareSerial.h line 158
0x4020bdc4: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/HardwareSerial.h line 158
0x40205d9c: ESP8266WiFiSTAClass::status() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 613
0x40205867: FirebaseESP8266::readStream(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 1311
0x40201189: loop() at C:\Users\joshu\Documents\Arduino\FirebaseStreamingWemosD1R2Mini/FirebaseStreamingWemosD1R2Mini.ino line 41
0x4020c861: esp_schedule() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 95
0x4020c8f0: loop_wrapper() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 125

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Your original sketch, you use blocking code in loop (many delays for total time about 1.4 seconds) which will block the library to read the stream.

The return http code I was described here.

If your new test sketch remains error with the same http code. You need to check that your device can be access to internet by ping test or make wifi client to do get request to some website.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

Yes alright, but the stack trace I showed you in the comment above is from the sketch via arduino without blocking the stream. Also this is where I get the error code.

Code I used in the arduino IDE with above stack trace:

FirebaseData firebaseData;

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();

  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
  Firebase.reconnectWiFi(true);

  if (!Firebase.beginStream(firebaseData, "stream-data")) {
    Serial.println("------------------------------------");
    Serial.println("Can't begin stream connection...");
    Serial.println("REASON: " + firebaseData.errorReason());
    Serial.println("------------------------------------");
    Serial.println();
  }
}

void loop() {
  if (!Firebase.readStream(firebaseData)) {
    Serial.println("Stream error:");
//    Serial.println(firebaseData.errorReason());
    Serial.println(firebaseData.httpCode());
  }

  if (firebaseData.streamTimeout()) {
    Serial.println("Stream timeout, resume streaming...");
    Serial.println();
  }

  if (firebaseData.streamAvailable()) {
    Serial.println("\nIncomming data...");
    Serial.println(firebaseData.dataType());
    Serial.println(firebaseData.dataPath());
  }
}

Edit:
Also, when I update one value on firebase it does show on the ESP that the value has been changed. This also means that it has internet connection right?

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

With your last basic sketch, how you know from device that the data was changed? Not from firebae console or any app.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

As you can see in the basic sketch code I have the following lines:

if (firebaseData.streamAvailable()) {
    Serial.println("\nIncomming data...");
    Serial.println(firebaseData.dataType());
    Serial.println(firebaseData.dataPath());
  }

When I update the firebase it shows me the type and the path in firebase.

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

And updating multiple lines means update multiple nodes (tree) in Firebase console ?

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

Yes, pardon me. Updating multiple nodes in the firebase console. This gives me the following stack:

0x4021e286: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x4020ed94: malloc(size_t) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1677
0x4021e286: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x4021e484: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator  const&) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 621
0x4021e58a: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 481
0x4022a3c3: basic_read at ssl/tls1.c line 1374
0x4021e638: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 687
0x4021e6de: std::string::assign(char const*, unsigned int) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 278
0x4021e70c: std::string::assign(char const*) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 1134
0x4020c840: esp_yield() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 91
0x4021e720: std::string::operator=(char const*) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 557
0x40204e17: FirebaseESP8266::getServerResponse(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 2248
0x4021e4da: std::basic_string  , std::allocator  >::~basic_string() at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 541
0x402057c4: FirebaseESP8266::getServerStreamResponse(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 3063
0x4020bdc4: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/HardwareSerial.h line 158
0x4020ef78: free(void*) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1764
0x40205d9c: ESP8266WiFiSTAClass::status() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 613
0x40205867: FirebaseESP8266::readStream(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 1311
0x40201189: loop() at C:\Users\joshu\Documents\Arduino\FirebaseStreamingWemosD1R2Mini/FirebaseStreamingWemosD1R2Mini.ino line 42
0x4020c861: esp_schedule() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 95
0x4020c8f0: loop_wrapper() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 125

In which line 42 is:

if (!Firebase.readStream(firebaseData)) { }

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Try this

if (firebaseData.streamAvailable()) {
    Serial.println("\nIncomming data...");
    Serial.println(firebaseData.dataType());
    Serial.println(firebaseData.dataPath());
    Serial.println(firebaseData.payload());
  }

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

That prints the value which I fill in the node on Firebase. But I see after 3 times getting a stream error: -4 the whole connection stops and doesn't reconnect. Tried using the Firebase.setMaxRetry(firebaseData, 10); but that doesn't seem to work.

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Due to I don't know how large of your data structure.

I suspected that the data may be truncated due to this limit. Try to change to lager value as

#define FIREBASE_RESPONSE_SIZE 1000

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

I will try that, thanks. What I'm doing is updating 3 nodes at the same time each of them has an integer value between 0 and 255. (RGB values).

I increased that value to be 1000 and I still get that stack trace..

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

It also seems to happen when I rapidly change a value of a node in my realtime firebase database.

Decoded stack trace:

0x4021e30e: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x4020ee10: malloc(size_t) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1677
0x4021e30e: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x4021e50c: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator  const&) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 621
0x4021e612: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 481
0x4022a44b: basic_read at ssl/tls1.c line 1374
0x4021e6c0: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 687
0x4021e766: std::string::assign(char const*, unsigned int) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 278
0x4021e794: std::string::assign(char const*) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 1134
0x4021e7a8: std::string::operator=(char const*) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 557
0x40204e63: FirebaseESP8266::getServerResponse(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 2248
0x4021e30e: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x4020ee10: malloc(size_t) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1677
0x4021e30e: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x4021e562: std::basic_string  , std::allocator  >::~basic_string() at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h line 541
0x40205810: FirebaseESP8266::getServerStreamResponse(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 3063
0x4020be40: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/HardwareSerial.h line 158
0x4020be40: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/HardwareSerial.h line 158
0x40205e18: ESP8266WiFiSTAClass::status() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 613
0x402058b3: FirebaseESP8266::readStream(FirebaseData&) at C:\Users\joshu\Documents\Arduino\libraries\Firebase_ESP8266_Client\src\FirebaseESP8266.cpp line 1311
0x402011a2: loop() at C:\Users\joshu\Documents\Arduino\FirebaseStreamingWemosD1R2Mini/FirebaseStreamingWemosD1R2Mini.ino line 45
0x4020c8dd: esp_schedule() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 95
0x4020c96c: loop_wrapper() at C:\Users\joshu\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 125

Line 45 is the if (!Firebase.readStream(firebaseData)) { }

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

How can you updating 3 or more nodes at the same time?
Is rapidly change mean you edit value in Firebase console and press enter?

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

I made an android app which is running on my phone which writes data to nodes on firebase. I made a function which writes the RGB values of the selected color to the r, g, b nodes. Also to test out if it was just because I changed 3 at the same time I made a function, which doesnt affect the other function, which writes the RGB value of a selected color as one integer and then write it on a node.

When quickly changing the second function crashes the ESP or when writing 3 values at the same it crashes.

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Now I also get same strange error too (exception (3) error).

May firebase update its response header/payload or relate to ESP8266 core SDK. I will find the root cause and let you know soon.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

Alright, glad that I'm not the only one with this error hahaha. I hope you'll find out the root of the problem soon!

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Now I fix the issues and update the stream callback.
The issues are from improper use of flash string length which cause error in SDK v2.5.2.

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

Ahh alright! Let me know when you fixed the issue! Thanks a lot!

from firebase-esp8266.

JoshNC avatar JoshNC commented on June 4, 2024

New version works via the Arduino IDE, quick last question: Do you know when does the new version update on platform io in VSCode?

from firebase-esp8266.

mobizt avatar mobizt commented on June 4, 2024

Not more than 2 days

from firebase-esp8266.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.