Context: I’m trying to develop an app that will tell me when my mailbox has physical mail in it. So I have an Arduino circuit with some sensors attached to it which sends data from the circuit to Firebase. Then, my thunkable app takes information from Firebase to then determine whether a door is open/closed, when this happened, is there mail inside, etc.
Problem: if my Thunkable app is not open, then when data changes in Arduino, it changes accordingly in Firebase as expected. But, when my Thunkable app is open in live test mode (web preview on a Windows or using the Thunkable Live app on an android phone), all of a sudden, whatever data changes are supposed to happen in Firebase from Arduino keep getting overridden to the values they were as soon as the app was opened. It’s like Thunkable won’t let those data points change even though they’re only meant to be read. I’m not using any coding blocks to overwrite those particular values.
For example, this is what my data looks like from Arduino:
Everything underlined in red is the data coming from Arduino. The Thunkable app should only read this data, not modify it. All other data is created by Thunkable and updated there.
Here’s a snippet of the code I used to read data in Thunkable from Firebase, make sense of it, and update other data points in Firebase as well as update labels on the screen in the app to show to the user. For example, I check if “topDoorArduinoStatus” is “open” to then modify the values of “isTopDoorCurrentlyOpen” and “whenTopDoorWasLastOpened”.
Note: I did try using the “when cloud variable Stella Mailbox initializes or changes” block below instead of using a forever loop within the “when Mailbox status screen 2 Opens” block, but then Thunkable would never detect whenever parts of the Stella Mailbox object got modified in Firebase.
Is it possible that in a web preview or Thunkable Live, it’s not able to access your Firebase data for some reason (likely failed authentication)?
Have you done a simple test to see if it can read that data? For example, when screen opens → set label’s text to cloud variable Stella Mailbox/topDoorArduinoStatus (using a pathname like that is a shortcut for using a bunch of “get property” blocks)? Does it show the expected value?
I’ve had problems with spaces in Firebase property names but it sounds like that hasn’t been a problem for you. Just mentioning it because you have “Stella Mailbox” instead of “StellaMailbox”.
I did double-check if spacing was an issue, but it wasn’t (apostrophes are though for Thunkable).
I just came to the realization that the problem was with setting the data. For example, if I use the following block to set one specific property of “Stella Mailbox”, I was expecting it to set “Stella Mailbox/isTopDoorCurrentlyOpen” only. But apparently, it was setting “Stella Mailbox” and all of its properties, including what was coming from Arduino with whatever Thunkable had last read. So that’s why it was overriding what Arduino was sending.
But if I use the following block, then it actually only overwrites “Stella Mailbox/isTopDoorCurrentlyOpen” and none of the other properties within “Stella Mailbox”.