Newbie question about storing sensor data to Firebase.

263 views
Skip to first unread message

Ethan Milton

unread,
Jun 6, 2023, 4:20:31 PM6/6/23
to Firebase Google Group
Hello Firebase Team! (And everyone else? Not sure how these google groups work.)
I'm working on a research project where I'm trying to read numerical values from a group of sensors and store that data in a webserver for machine learning purposes. We're writing in Android Studio, so Firebase was the first place I ran into. It seems like it might be what we're looking for, but I'm getting caught up in the various links and things to learn and I'm getting a little confused about some basic questions:

1. The goal is to write a list of data to the cloud, keeping all of it logged. (As opposed to rewriting the same values over and over again.) This is possible yes? (I'm fairly sure it is, just checking.)
2. What's the best way to store a long list of data like this? We're thinking, with the writes-per-day quote of holding a batch of the data from a given session (30 seconds) and then writing all the data at once. Is this possible?
3. Should we upload it as an array? (It seems firebase doesn't exactly have arrays, but it can convert between them more or less). Is there a more dynamic way of adding to a list of data? (At the end of the day, it will still be separated into segments. Any given list will only be around 3000 datapoints long.)

Most of the online help I'm running into is for data such as users and contact info, rather than something as abundant as primitive numerical values from a sensor. Is Firebase really suitable for an application such as this? 
Thanks for all the help.

Warm regards,
Ethan

Jesse Jones

unread,
Jun 13, 2023, 1:34:55 AM6/13/23
to Firebase Google Group
Ethan,

You most certainly could store your information using firebase. Figuring out the data structure is the creative part here. It sounds like a relational database would be more suitable for your needs, but it wouldn't be impossible to do in a document database.

There are a few different ways you can go about doing this, but the "Best Way" may not be immediately obvious and may require some playing around to get your desired (and optimized) results. 

A simple structure I can think of would be something like the following:
/Devices/{uid}/date/data

OR

/Devices/{uid}
/Logs/date/{uid}/data

From there you could store the data per interval, or you could update a single entry to include all data for the set. All document data in firebase are stored in Json format: Structure Your Data

It was confusing for me too at first, even with having plenty of experience in the relational word. It's worth learning either way. Just figure out if your needs meet the features of firebase.

Cheers,
- Jesse

Arthur Thompson

unread,
Jun 16, 2023, 7:09:58 PM6/16/23
to fireba...@googlegroups.com
Hi Ethan,

Adding to what Jesse said, you could also consider Firestore which does support arrays (see datatypes). There is also a similar set of docs to help you design your structure in Firestore.

Both Firebase No-SQL databases (Realtime Database and Firestore) should do the trick for this use case. You may prefer RTDB for ultra low latency and Firestore if querying and types (like arrays) are really important.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/f5ecef46-ac4d-490d-a6aa-db3f774d1e78n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages