App Inventor working with Firebase database

Android App for Aquarium data stored in Firebase Database – app created with MIT APP Inventor
Overall “idea”
The app will open showing the most recent tank data (SHOW BUTTON)
The app will allow new values entered and stored (Enter & Update Button)
The Firebase will receive values from APP and/or Arduino sensors on aquarium (have this part working)
Button on app will show graph of test values (Graph Button).
Data to be captured in database can be temperature, pH, chemical tests such as Calcium ppm, iodine etc.

Questions:

  1. What is the “best” or “most efficient” firebase design.
    a. Current – Key/Tag – Date/Time/Parameter example YYYYMMDDHHMMSSXXX Year, Month,Day, Hour, Minute, Second, 3 character parameter name.
    b. Value – 99999.999, some parameters can be in the thousands and others are three point decimals. All are positive values and numeric
  2. Any tutorials or examples that show similar data logging. My current test project is just a list of labels and then text boxes. The Update button is giving me an error “Previous value was empty”
  3. I am thinking of manually entering a set of data so all parameters have an entry to initialize the database.

Show your current blocks and firebase console data.

Do you only want to graph one element at a time, or show all elements in one graph?

image
I enter 1.025 in the Salinity box on in the APP, press Update
But the database shows "Salinity" "True", not 1.025

In time I am hoping to graph all the Salinity values on a graph
All the Calcium values on a different graph

Use Textbox.text

Numbers only is a property.

Firebase_design_v1

This is what I am thinking the firebase database will look like
What I do not understand is what is ProjectBucket?
How do I code on App Inventor to step to the first level "Calcium" and then create a tag of YYMMDDHHMM

I have been trying to understand the layout parts of the app.
The top of the app label - Three Tenths Data the background is not showing across the full width of the app

Set Label Width to Fill Parent

I do not have any blocks that have a call Clock1......

The Clock is in the Sensors Drawer.

You wanted time stamps as tags, right?

yes, I am thinking time stamps will keep things unique.

Use systemTime, this provides the date/time in milliseconds.

1 Like

fixed this question

TIMAI2 - I should use systemTime instead of .now? What I see from systemTime is that it returns mills since 1970? What I do not see how it returns the value?

You can convert it to human readable date/time using clock blocks

Thank you. Why is this better than using call Clock1.now? Easy enough change. Thank you

image
The code using systemtime stores the data in a subtag tree vs the YYMMDDHHSS format building the unique tag.

Did we forget to mention that the slash (/) character used in date formatting has a side effect in Firebase tags of creating subtrees?

Though it has a beneficial side effect of making your key/value trees short, unordered and bushy for performance, it interferes with any attempts to grab multi-day ranges .

What looks good to the eye does not work best behind the scenes in a database.

ABG thank you. That makes sense.
In times, I hope to be able to graph the data and "unordered and bushy" tags seem like they would be difficult and much more effort.

I am working now on a simple task of refreshing the last values on the app and reading back last value even from a saved key has been challenging. is there a book or manual that would be more efficient than my try,fail,try, fail, try search google, try, fail approach.?