I have sent my DHT sensor data from my NodeMCU to Firebase with the following code.
void loop() {
if(timeSinceLastRead > 2000) {
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
timeSinceLastRead = 0;
return;
}
float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h, false);
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(f);
Serial.print(" *F\t");
Serial.print("Heat index: ");
Serial.print(hic);
Serial.print(" *C ");
Serial.print(hif);
Serial.println(" *F");
Firebase.setFloat("Temp",t);
Firebase.setFloat("Humidity",h);
Firebase.setFloat("HeatIndex",hic);
timeSinceLastRead = 0;
}
delay(100);
timeSinceLastRead += 100;
}
It has successfully sent the data to Firebase but in the following structure.
Field-Root
|_ HeatIndex: <value>
|_ Humidity : <value>
|_ Temp : <value>
But, I have two more user-defined ID parameters which I want to sent to Firebase and I need the following structure.
Field-Root
|_ ID1
|_ ID2
|_ HeatIndex: <value>
|_ Humidity : <value>
|_ Temp : <value>
But, I am not getting the hierarchical structure which I need where instead I am getting the old structure. How do I get that?