1

I am new to the Google Cloud. I have a topic in Pub/Sub and have an IoT device that is sending data to it. How can I then send this data to Firebase Realtime DataBase? I have been looking for a while, but could not find a tutorial showing how this can be achieved.

SaTa
  • 2,422
  • 2
  • 14
  • 26

1 Answers1

6

You'll need to have code somewhere that listen to the PubSub topic and then writes to the database. A common way to do this these days is to use Cloud Functions, which saves you from having to set up your own server. For a good explanation of this, see the Firebase documentation for triggering Cloud Functions from PubSub.

Then in that Cloud Function you'll need to write the data to the Realtime Database. For an example of writing to the database in a Cloud Function, see Cloud Functions for Firebase - write to database when a new user created

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thanks, this was really helpful. It gave me a good overview. I followed the instructions on the two links and it worked. One things that throw me off a bit and took sometime was that cloud functions are per project and cannot be triggered with Pub/Sub of another project. Right? – SaTa Mar 22 '20 at 18:35
  • Yeah, the only cross-project Cloud Functions I know of are HTTPS. – Frank van Puffelen Mar 22 '20 at 19:26