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?
Hi.
What do you mean?
Do you get the same result and timestamp twice?
Regards
Sara
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?
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());