How do you make an Arduino receive data through firebase? - firebase

I've worked with firebase and arduino's before but never together. I need to know how to make an arduino uno receive data through firebase, however I do not need it to send data. I have no idea how to do this, or if it is even possible. I've looked at various articles of an arduino sending data to firebase, but never receiving data.

If you thinking to connect Arduino with Firebase you will need a backend. You can use Firebase Admin SDK to create a backend.
This is a sample code for a backend.
For more Information refer the Documentation

Most likely your Arduino saves data to the Firebase Database through the REST API. If that is the case, it can also listen for data through the REST API.
There are several libraries that wrap this REST API to make is easier to use with Arduino. Instead of recommending one of those (which is off-topic on Stack Overflow), I recommend you try them and see what works best for you.

Related

How to use Firebase (or Firestore) as an intermediary between a desktop app and an external API endpoint?

I have a desktop app that will be distributed to users, and part of its code (which the user might be able to access) has to perform an API call to a third-party web service. However, this requires the API keys to be embedded into the source code, which causes some obvious security issues.
The main solution I've found while researching on the subject is to have a backend server between the user and the third-party API endpoint. So, I've been looking into Firebase for a while and it seems that this solution can be implemented using Firestore and Cloud Functions.
But, I wasn't able to find any clear examples that achieve something like this, and since I have no previous experience with Firebase or just backend programming in general, I would like to know if I'm on the right track and get more details about how to get it done, or if there are better alternatives for solving this issue. Any input is appreciated, thx.
You can use the firebase cloud functions as you mentioned. Your desktop application will be communicating with the cloud function - simple API call. Here you can find examples how to implement and deploy functions and test it locally https://firebase.google.com/docs/functions/get-started. Your cloud function will hold the API keys (it is backend so it will be secure if you dont expose it explicitly. Also the backend to backend communication is considered as secure). Finally, this cloud function will call the third party service and return some data back to the desktop app if needed. So you are on the right track, that is how the design should look like. If you need some help with cloud functions, you can also contact me directly.

Communication between Firestore and ESP32

I am doing a project to identify people via RFID in ESP32. When performing the identification, the ESP must consult the data referring to the identified RFID TAG and display the related data on a display (name, city, date of birth).
However, I am not able to understand how I carry out this communication between ESP and Firestore. Can anyone help me?
Thanks!
The intended method of talking to the Google Cloud from an ESP32 is through the IoT Core. Note that this will not get you a direct connection to the Firestore - you'd have to write some cloud side code to translate MQTT messages into database queries and responses. This shouldn't be very difficult, though.
Otherwise you can send HTTPS queries directly to the Firebase REST API. Read the Google documentation for that.
If you are using ESP-IDF framework for your development you can use this ESP-IDF component to communicate with Firestore (this component uses Firestore REST API via HTTPS):
https://github.com/kaizoku-oh/firestore.git
Here is also an example using RFID and Firestore components that you can change according to your needs:
https://github.com/kaizoku-oh/firestore-rfid-node.git

How do I send data from Pub/Sub to Google Cloud Firestore?

I'm setting up a dataflow in Google Cloud Platform. I have retrieved data from IoT devices and sent to Pub/Sub, and I now want to store in Firestore. I am using Firebase for my web app where data should be displayed etc.
I realise this should be a simple task, but am still not finding too much information about it (probably too straight forward). Have looked at using Cloud Functions to retrieve from Pub/Sub and add to Firestore, which ought to work (although I got stuck at credentials), but is there an easier way that I am missing?
Your thinking on using Cloud Functions as the recipient of a PubSub message coming from Cloud IoT Core and in that Cloud Function performing an insert into Firestore is exactly correct.
Here is an example showing just that:
https://blog.usejournal.com/build-a-weather-station-with-google-cloud-iot-cloud-firestore-mongoose-os-android-jetpack-350556d7a
If we Google search using "gcp pubsub firestore" we will find many others.
If you use this technique and run into puzzles/problems, don't hesitate to raise new questions (but first search and see if they have been raised before). In your new questions, please be as detailed as possible. There are many samples available for all sorts of related areas. Have a study of these.

Can Arduino Uno send data to Cloud Firestore?

I need information on how to connect and send data to firestore from an Arduino Board and an ESP2866 module. I've only found tutorials using Firebase realtime, the ones I found using Firestore are using the NodeMCU board.
I have a Vue.js application reading some fields from a Firestore db, which should recieve information from the arduino with some attached sensors. From what I've seen my options are changing to firebase realtime or changing to NodeMCU( not possible ). I some direction to follow, on how to use firestore with arduino or just change the db.
One way to do it is to have an online server, after that it becomes very easy. Send your Arduino data to the server and then write the data to Cloud Firestore.
To find how to write data into Firestore, refer this documentation: https://firebase.google.com/docs/firestore/manage-data/add-data and chose the integration for your server. Firestore supports most of the popular server integrations like Node.js, GO, PHP, Python etc.
As answered by #doublejosh, refer to this documentation: firebase-extended
I had quick success using firebase-arduino for the real-time database rather than Firestore. Since Arduino projects are generally hobby, this should probably work well enough.

Is it safe & possible to do almost everything on the cloud side with firebase?

I am using Firebase for my new project. This will be used on both Android and IOS. As you can guess I don't want to write the same code over and over again for both OS.
I am considering to code most of the work with Javascript on the cloud functions. In order to do that I need to use HTTP Requests to call my functions since firebase doesn't support any other way to call cloud functions.
There is two question in my head about this.
Is this possible and does it makes sense?
Since I've been using HTTP Requests all the time isn't that make my app open to listening with tools like Wireshark etc if there are multiple users on the same network? (I know Firebase now supports SSL but do I have to but a domain and license for that?)
What is the best way to do it in an engineer's perspective?
You can certainly move more of your app logic into Cloud Functions. But it's not really true that the only way to invoke a Cloud Function is via HTTP. You can also push data into your database to invoke a database trigger. I gave a talk on this at Google I/O yesterday about how I made a game with all the logic in Cloud Functions. You can watch it here.

Resources