• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Firebase acces time

Q&A Forum › Category: ESP32 › Firebase acces time
0 Vote Up Vote Down
Cezary Mikowski asked 3 years ago

Thank you for this guide (Firebase).It saved me plenty of time (two afternoons instead of days to create own project).
Based on Firebase guide I created own project with six temperature sensors saved to DB every 30s. The goal is even shorter tim up to 2s. When there is not to many records in DB (I estimate up to one hundred, but not confirmed by a test)) all is OK. The problem is after opening web app after 2-3 days (3*24*60*20=8640 records). There is a few minutes (2-10min) lag on Android device. Much shorter on PC web browser, but also 30-60s. What could be a reason? Sometimes I also observed gradual change in Last Update field (time was step by step increased). After this initial lag further controll seems to be OK. Also there is not mentioned startup lag after data delete.
1. Is it any way to speed up this? May be change search DB process?
2. If not may be a way to automatically clear older records (having only a few hundreds in DB)?
Regards,
Cezary.

Question Tags: Android, Firebase, time
4 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
If you have a lot of records on the database and try to load them all at once, the browser will lag and may even crash.
Are you displaying all records on the web browser or only the latest?
We have this project that has a delete button to delete database records and also shows how to load only 100 readings at a time:

  • https://randomnerdtutorials.com/esp32-esp8266-firebase-gauges-charts/

I hope this helps.
Regards,
Sara

0 Vote Up Vote Down
Cezary Mikowski answered 3 years ago

Hi Sara,

What is a reason of browser crash you mentioned?

My project is based on your eBook https://randomnerdtutorials.com/firebase-esp32-esp8266-ebook/ so there is delete button on the site. But first all data are deleted, second it must be done manually.
Finally, I need only last few hours be displayed. Assuming 4 hours it is now 480 records but current project, based on eBook, displays only 30 last readings on the charts.
It is any way to design Firebase RTDB to automatically delete records (based on time or its quantity)?
Also delete oldest records by ESP32 device during saving fresh data seems work for me. Could it be done? How should I modify ESP code?
Last option (not as ideal as two previous) is a modification of delete button action to delete not all records but sustain some of them. How web page code could be modified to get this?
Regards,
Cezary.

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
 
There is not an easy way to delete entries automatically.
Here are some options: https://stackoverflow.com/questions/32004582/delete-firebase-data-older-than-2-hours
You can change your javascript to delete data when the client connects.
 
You can also make requests on the ESP32 to delete data.

  • https://github.com/mobizt/Firebase-ESP-Client#delete-data

You can filter the data before deleting it so that you only delete the oldest entries:

  • https://github.com/mobizt/Firebase-ESP-Client#filtering-data

 
I don’t have anything specific written for that at the moment, but I think the links for the documentation I shared should help.
 
Regards,
Sara
 

0 Vote Up Vote Down
Cezary Mikowski answered 3 years ago

Thank you for your help. I will try.
Regards,
Cezary.

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.