Firebase + Wemos D1 min

Hi!

I am a newbie to arduino and programming.
I need some help with my project. I am sending distance sensor data to a website called firebase (like thingspeak, https://firebase.google.com/) and I want to use this data to control a motor on another device. In both scenarios I am using a Wemos D1 mini ( microcontroller using Arduino IDE with ESP8266 Wifi chip). I have problems in receive the data from firebase.
Here is a helping manual that doesn’t help me as a programming starter, maybe somebody can help me with this riddle? Retrieving Data  |  Firebase Realtime Database

Here is a part of my sending code:

void loop() {

digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
//Calculate the distance (in cm) based on the speed of sound.
float distance = float (duration/58.2);
Serial.println(distance);
Serial.print ( " cm");

StaticJsonBuffer<200> jsonBuffer;
JsonObject& data = jsonBuffer.createObject();
data[“dis”] = distance;

digitalWrite(echoPin, HIGH);

String name = Firebase.push(“DISTANCE”, data);

if (Firebase.failed()) {
Serial.print(“pushing /DISTANCE failed:”);
Serial.println(Firebase.error());
return;
}
Serial.print(“pushed: /DISTANCE/”);
Serial.println(name);
delay(200);
digitalWrite(echoPin, LOW);
delay(200);

}

Any help is appreciated a lot!

have problems in receive the data from firebase.

So, you posted the code that works to send data to firebase, but not the code that doesn't work. Didn't really want help, I guess.

Sorry you are wright the second part didn’t got copied…

Here I just don’t know about the right commands for getting the data. If anyone could help me with this, it would be great
https://firebase.google.com/docs/database/admin/retrieve-data

void loop() {

StaticJsonBuffer<200> jsonBuffer;
JsonObject& data = jsonBuffer.createObject();
data[“dis”] = distance;

String distance = Firebase.get(“DISTANCE”, data)
servoAngle = (106./7.) * distance + 37; //Calculate Servo Angle from targetDistance
//for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(servoAngle); // write servoAngle to the servo __ tell servo to go to position in variable ‘pos’
Serial.println(servoAngle);
delay(150); // waits 15ms for the servo to reach the position
return;

}

StaticJsonBuffer<200> jsonBuffer;
JsonObject& data = jsonBuffer.createObject();
data["dis"] = distance;

Why are you setting the value of the dis node to some nonsense value?

Why do you have a JSON buffer or object at all?

What, EXACTLY, does Firebase.get() return? What, exactly, does it put in the array that is the second argument?

Okay, I was trying to say that I don't know how to implement the code for retreiving data.
the Firebase.get actually doesn't exist. I had this thing working on thingspeak and was hoping to get anywhere with it but I don't.

the help part in firebase shows me this example but I can't make it work with my sketch
this is the help code

public static class Post {

public String author;
public String title;

public Post(String author, String title) {
// ...
}

}

// Get a reference to our posts
final FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference ref = database.getReference("server/saving-data/fireblog/posts");

// Attach a listener to read the data at our posts reference
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Post post = dataSnapshot.getValue(Post.class);
System.out.println(post);
}

@Override
public void onCancelled(DatabaseError databaseError) {
System.out.println("The read failed: " + databaseError.getCode());
}
});