# Firebase values reverting back to original values after Arduino input

**URL:** https://community.thunkable.com/t/firebase-values-reverting-back-to-original-values-after-arduino-input/1691582
**Category:** Questions about Thunkable X
**Tags:** firebase, beginner, cloud-variable
**Created:** [January 24, 2022, 3:40pm UTC](https://community.thunkable.com/t/firebase-values-reverting-back-to-original-values-after-arduino-input/1691582 "2022-01-24T15:40:18Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![hiddenlight](https://avatars.discourse-cdn.com/v4/letter/h/53a042/32.png) [@hiddenlight](https://community.thunkable.com/u/hiddenlight)
#### Post date: [January 24, 2022, 3:40pm UTC](https://community.thunkable.com/t/firebase-values-reverting-back-to-original-values-after-arduino-input/1691582/1 "2022-01-24T15:40:18Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/c/5c24092e82462bc80cb5f1d26827a55c74e23d8f.png)

This data gets sent to the “Stella Mailbox” key in Firebase:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/0/c0a018669f67772aba50aace2b4d3a56252f305b.png)  
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”.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/6/f6de27476d4a3cf3829adb74f7bb753ec634db33.png)

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.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [January 24, 2022, 6:11pm UTC](https://community.thunkable.com/t/firebase-values-reverting-back-to-original-values-after-arduino-input/1691582/2 "2022-01-24T18:11:42Z")

</div>

> [@hiddenlight](#):
>
> 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.

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”.

---

<div class="post-metadata">

### Author: ![hiddenlight](https://avatars.discourse-cdn.com/v4/letter/h/53a042/32.png) [@hiddenlight](https://community.thunkable.com/u/hiddenlight)
#### Post date: [January 24, 2022, 6:31pm UTC](https://community.thunkable.com/t/firebase-values-reverting-back-to-original-values-after-arduino-input/1691582/3 "2022-01-24T18:31:42Z")

</div>

@tatiang Thanks for responding!

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.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/0/3030172616a04f0828841821ee7ce0a3188a89ca.png)

But if I use the following block, then it actually only overwrites “Stella Mailbox/isTopDoorCurrentlyOpen” and none of the other properties within “Stella Mailbox”.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/1/71d5b253be98ebaef6a90257aa252c1c797edb78.png)

Because the Thunkable documentation said the following, I assumed those two blocks worked the same way, but apparently not.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/9/c96805d65ce7f2029c6f60c39c3917caf6bff526.png)

Gosh I spent so many hours trying to figure this out.

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [January 24, 2022, 9:42pm UTC](https://community.thunkable.com/t/firebase-values-reverting-back-to-original-values-after-arduino-input/1691582/4 "2022-01-24T21:42:48Z")

</div>

Sorry! We are continuing to fix these types of confusing issues! Glad you got it figured out! Thanks for the assist here @tatiang

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [January 25, 2022, 10:21am UTC](https://community.thunkable.com/t/firebase-values-reverting-back-to-original-values-after-arduino-input/1691582/5 "2022-01-25T10:21:19Z")

</div>

They are working the same way. Your code is another proof that they work the same way.

The first example you try to set the value using the `object` blocks not the `cloud variables`. This is the reason you are getting different outcome.

To use the `cloud variables` just use the `set variable` block in the `variables` drawer not the `set property` in the `object` drawer.

Hope this clarifies the confusion.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)
#### Post date: [April 25, 2022, 10:21am UTC](https://community.thunkable.com/t/firebase-values-reverting-back-to-original-values-after-arduino-input/1691582/6 "2022-04-25T10:21:56Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
