Big lag when sending BLE received data and storing in firebase

Hi, I am trying to send data to a phone via ble and then send that to a real-time Firebase server. There is quite a bit of lag in displaying the values (from the esp32) on my application but when I remove the storevalue block (to send data to the firebase), there is no lag and the values are displayed in real-time. So it sounds like my problem is that storing the value in Firebase is causing the lag. This is initially how I did it:

Then I thought that maybe storing the value straight into the firebase in the StringReceived block might be causing an issue so I resorted to removing it and putting it in a clock block to send the values periodically:

This however did not work no matter the clock interval I used. Is there a better way that I could do this? Could it possibly be that my phone's hardware doesn't have enough processing power to receive via ble and store to the firebase fast enough? Please help :sob:

I haven't used Firebase in a while, so I had to confirm this on the MIT server.
image

Firebase_ditto.aia (1.9 KB)

This is a simple app with a Send button.
When the Send button is clicked, it sends whatever is in the textbox to Firebase.
When Firebase detects that data was changed, and it was the same tag I used , it updates the Label with what changed. (the new value).

So I am guessing this can be used as a feedback mechanism to let you know that your save to Firebase completed, and that it's okay to send the next item to Firebase.

Now let's discuss your situation, where data arrived from BLE faster than Firebase can accept.

You can use a list as a queue for the incoming BLE data, as it waits to be send to Firebase.

When BLE data arrives, add it to the end of the list.

If the list length is exactly 1, you have just started the queue and it's okay to send to Firebase from item 1, otherwise let the new data stand on the queue.

When the data changed event signals, item 1 was stored okay, so remove item 1 and check if the list is empty.

If the list is not empty, send the new item 1 to Firebase.

This technique does not use a Clock. It uses the DataChanged event, which automatically keeps up with the speed of Firebase's updates. This way, no tuning is needed for speed.

P.S. You also need
component_event
to report any errors.