• 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 web app is duplicating records in the table

Q&A Forum › Category: ESP32 › Firebase web app is duplicating records in the table
0 Vote Up Vote Down
Marcos Silva asked 1 year ago

HI Sara & Rui
I did a project using your ebooks with lora radio frequency communication and firebase application and I was successful in receiving data on the web. But, when I click on the “More Results…” button, the records are duplicated. Cloning only happens in the web app.
Can you help me?

Question Tags: Firebase aplication
4 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Hi.
What do you mean?
Do you get the same result and timestamp twice?
Regards
Sara

0 Vote Up Vote Down
Marcos Silva answered 1 year ago

Hi Sara,
Exactly. I receives the same record with the same hour, minutes and seconds. In the Firebase console and in the Arduino serial, the records are correct, they are not duplicating. I think it may be a problem with the index.js or index.html file. Do you have any tips?

0 Vote Up Vote Down
Marcos Silva answered 1 year ago

Hi again!
To read the data from the LoRa package I used this function
void getLoRaData() {
// Read packet
while (LoRa.available()) {
String LoRaData = LoRa.readString();
// LoRaData format: readingID/temperature&soilMoisture#batterylevel
// String example: 1/27.43&654#95.34
Serial.print(LoRaData);

// Get captura, temperature and humidity
int pos1 = LoRaData.indexOf(‘/’);
int pos2 = LoRaData.indexOf(‘&’);
int pos3 = LoRaData.indexOf(‘#’);
int pos4 = LoRaData.indexOf(‘$’);
int pos5 = LoRaData.indexOf(‘@’);
int pos6 = LoRaData.indexOf(‘*’);

//Decode readed packet
captures = LoRaData.substring(0, pos1);
temperature = LoRaData.substring(pos1 +1, pos2);
humidity = LoRaData.substring(pos2 +1, pos3);
light = LoRaData.substring(pos3 +1, pos4);
btsensor = LoRaData.substring(pos4 +1, pos5);
btmotor = LoRaData.substring(pos5 +1, pos6);
plsolar = LoRaData.substring(pos6 +1, LoRaData.length());
}
//Get RSSI
sinals = LoRa.packetRssi();
Serial.print(“Sinals: “);
Serial.print(sinals);
}
and to send new reading to database, eu i used this funtion
void loop(){

// Check if there are LoRa packets available
int packetSize = LoRa.parsePacket();
if (Firebase.ready() && packetSize) {
Serial.print(“LoRa packet received: “);
getLoRaData();

//Send new readings to database
json.set(capturesPath.c_str(), captures);
json.set(tempPath.c_str(), temperature);
json.set(humPath.c_str(), humidity);
json.set(lightPath.c_str(), light);
json.set(btmotorPath.c_str(), btmotor);
json.set(btsensorPath.c_str(), btsensor);
json.set(plsolarPath.c_str(), plsolar);
json.set(sinaisPath.c_str(), String(sinals));
json.set(timePath, “timestamp”);

Serial.printf(“Set json… %s\n”, Firebase.RTDB.pushJSON(&fbdo, sensorPath.c_str(), &json) ? “ok” : fbdo.errorReason().c_str());

0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Hi.
In that case it seems a problem with the Javascript or with the HTML.
Probably the javascript is creating duplicates on the table.
Regards
Sara

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

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 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.