# How to save data from Realtime Database to Google Spreadsheet (or other place)

**URL:** <https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988>\
**Category:** Questions about Thunkable X\
**Tags:** firebase, database, design, spreadsheets\
**Created:** [July 15, 2021, 4:34pm UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988 "2021-07-15T16:34:04Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![laura.quraishk5](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/laura.quraishk5/32/110804_2.png) [@laura.quraishk5](https://community.thunkable.com/u/laura.quraishk5)\
**Post date:** [July 15, 2021, 4:34pm UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988/1 "2021-07-15T16:34:04Z")

</div>

Hi Thunkable community,

I am working on a stress-reducing app for a graduate research project. I want my users to track their stress levels from 0-10, stress triggers, and stress reactions daily.

I am a tech newbie, but after doing a deep-dive of Darren’s videos I figured out how to save the stress info from my Thunkable APP to the Realtime Database in Firebase.

My problem is that my data keeps over-writing itself, only the newest entry will save.

My goal is to automatically save my data from Realtime Database to a google spreadsheet so I can analyze the data with statistics.

Does anyone know how to do this? **OR** Does anyone recommend a better way to save data from Realtime Database to a different place?

I tried following these instructions, [[One Way to Connect Firebase to Google Sheets](https://www.lido.app/post/connect-firebase-to-google-sheets)]([https://One](https://One) Way to Connect Firebase to Google Sheets) …but it did not work

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [July 15, 2021, 5:00pm UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988/2 "2021-07-15T17:00:43Z")

</div>

First: Just to make sure you know: Right now Thunkable’s purple data source blocks (that you’d use to write anything to Google Sheets out of Thunkable) are broken. Firebase connections are fine. I’m hoping a fix is coming since a whole lot of apps are broken, but no one has yet offered a timeline. It doesn’t sound like that’s what you’re doing, but I wanted to make sure you didn’t end up trying to debug some perfectly fine code that’s broken because of a bug on Thunkable’s side that you cannot fix.

I haven’t used the method you link. Perhaps someone on the forums has and can help - otherwise, you might have better luck asking for help with that piece on a firebase forum. (Be sure to provide more details about “it did not work”.) [Aside: the source of that advice wants to sell you a commercial product that prevents you from needing that advice. That always makes me a little suspicious.]

Alternately, I’d be glad to help you figure out how to get your data not to overwrite itself in Firebase. That might be the simplest solution. 🙂 If you posted your data structure (screenshot from Firebase) and the blocks that are causing the overwriting, I’m guessing it’s not a hard fix. 🙂

---

<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:** [July 15, 2021, 5:40pm UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988/3 "2021-07-15T17:40:57Z")

</div>

I worked in a project in which RTDB (Realtime DB) is the main database and is required to synchronize with Google sheet

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

I can help you with that but it all depends on the structure of your data in RTDB and how you want to show it in Google sheet.

---

<div class="post-metadata">

**Author:** ![laura.quraishk5](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/laura.quraishk5/32/110804_2.png) [@laura.quraishk5](https://community.thunkable.com/u/laura.quraishk5)\
**Post date:** [July 16, 2021, 5:44pm UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988/4 "2021-07-16T17:44:17Z")

</div>

Hi Muneer. Thank you for the reply and for posting your blocks.

Using your blocks as a guide, I will try it on my project this weekend and let you know if I get stuck.

I really appreciate your help 🙏.

---

<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:** [July 16, 2021, 9:07pm UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988/5 "2021-07-16T21:07:25Z")

</div>

dont move data between sources. use one or the other, anything else will decrease app performance and increase overhead consumption of resources.

why do you feel that you can’t do this from your thinkable app or do you mean that you want to build something like a web dashboard to view your info?

orr you could take the road less traveled around here and learn to work the API connector!

> [@\[Solved\] Google oAuth using Web API](https://community.thunkable.com/t/solved-google-oauth-using-web-api/327756/10):
>
> Here is the working project… [https://x.thunkable.com/copy/8f9209b8af7ecad132a27d0eb4253bc3](https://x.thunkable.com/copy/8f9209b8af7ecad132a27d0eb4253bc3) To use it you will need to go to [https://console.developers.google.com/apis/credentials](https://console.developers.google.com/apis/credentials) and create both an API key and a OAuth 2.0 client ID which is authorized for a web application. You’ll also need a spreadsheet ID and a sheet name (the default is “Sheet1”). To be honest, I don’t remember which steps were important versus those which led me in the wrong direction since there is more bad advice out t…

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [July 16, 2021, 9:27pm UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988/6 "2021-07-16T21:27:11Z")

</div>

> [@jared](#):
>
> use one or the other, anything else will decrease app performance and increase overhead consumption of resources.

Also more work to set up. 🙂

The offer to help you figure out your firebase data model so that it isn’t overwriting still stands. 🙂

Alternately, you could use firebase for the login and then post user logs to Google Sheets, if the data structure for that makes sense and you’re more comfortable using spreadsheet data.

---

<div class="post-metadata">

**Author:** ![laura.quraishk5](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/laura.quraishk5/32/110804_2.png) [@laura.quraishk5](https://community.thunkable.com/u/laura.quraishk5)\
**Post date:** [July 16, 2021, 10:27pm UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988/7 "2021-07-16T22:27:34Z")

</div>

Whew! It has been a journey today. Thanks for your support.

Jared: thanks for the info. I tried Cathy’s suggestion first, deleted the blocks. Attempted Muneer’s advice but could not locate the blocks and deleted the partial attempt. How is the functionality when using Realtime Database (for the login) and Airtable (for the data collection) at the same?

Hi Cathy! Suddenly my Realtime Database starting saving stress entries, but I am still suspicious of it 🤨 I was successful in getting Airtable to work and save my data. I agree that the spreadsheet format would be much better for collecting research variables.

---

<div class="post-metadata">

**Author:** ![uj-ulongjep](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/uj-ulongjep/32/119596_2.png) [@uj-ulongjep](https://community.thunkable.com/u/uj-ulongjep)\
**Post date:** [December 11, 2021, 10:07am UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988/8 "2021-12-11T10:07:18Z")

</div>

please help…  
block to turn off 4 lights (IoT)  
Thunkable =\> Firebase =\> NodeMcu =\> 4 Channel Relay

---

<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:** [December 11, 2021, 10:43am UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988/9 "2021-12-11T10:43:34Z")

</div>

> [@uj-ulongjep](#):
>
> block to turn off 4 lights (IoT)

Can you be more specific here?  
Please provide enough details to allow other members to respond to you.

---

<div class="post-metadata">

**Author:** ![uj-ulongjep](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/uj-ulongjep/32/119596_2.png) [@uj-ulongjep](https://community.thunkable.com/u/uj-ulongjep)\
**Post date:** [December 11, 2021, 10:53am UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988/10 "2021-12-11T10:53:04Z")

</div>

this is my block

I want to make Iot  
4 lights can be turned off and on via Thunkable

schematic using NodeMcu + Relay 4 Channel

 ![tanya thunkable](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/b/dbf7947a657f10368b1a1eb6635dde72e3af1dff.png)

this is the script on the arduino IDE

//  
// Copyright 2015 Google Inc.  
//  
// Licensed under the Apache License, Version 2.0 (“License”);  
// You may not use this file except in accordance with the License.  
// You can obtain a copy of the License at  
//  
// [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)  
//  
// Unless required by applicable law or agreed in writing, the software  
// distributed under the License distributed on an “AS IS” BASIS,  
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.  
// See Licenses for specific languages ​​that govern permissions and  
// limitations under the License.  
//

// FirebaseDemo\_ESP8266 is an example that demonstrates various functions  
// from the FirebaseArduino API.

#include \<ESP8266WiFi.h\>  
#include \<FirebaseArduino.h\>

// Set this to run the example.  
#define FIREBASE\_HOST “[etgindriespnothdemcu-default-rtdb.firebaseio.com](http://etgindriespnothdemcu-default-rtdb.firebaseio.com)”  
#define FIREBASE\_AUTH “xS4yb5u76rujwMSnZMYn1Wpfh1ncrHBl5EZsKOn5wo7UuH”  
#define WIFI\_SSID “Ngo Bunga Negeri”  
#specify WIFI\_PASSWORD “sendhhninmode”

unset() {  
Serial.begin(9600);

// connect to wifi.  
pinMode(D1, OUTPUT);  
pinMode(D2,OUTPUT);  
pinMode(D3,OUTPUT);  
pinMode(D4,OUTPUT);

WiFi.begin(WIFI\_SSID, WIFI\_PASSWORD);  
Serial.print(“connect”);  
while (WiFi.status() != WL\_CONNECTED) {  
Serial.print(".");  
delay (500);

}  
Serial.println();  
Serial.print("connected: ");  
Serial.println(WiFi.localIP());

Firebase.begin(FIREBASE\_HOST, FIREBASE\_AUTH);  
firebase.set(“L1”,0); // by default lamp1 is on  
Firebase.set(“L2”,0);  
firebase.set(“L3”,0);  
firebase.set(“L4”,0);  
}

int a = 0;  
int b = 0;  
intc = 0;  
int d = 0;

empty circle() {  
// set value  
a=Firebase.getInt(“L1”);  
b=Firebase.getInt(“L2”);  
c=Firebase.getInt(“L3”);  
d=Firebase.getInt(“L4”);  
// handle error

//For Lamp 1  
if (a==0) {  
Serial.print(“Lamp 1 Off”);  
digitalWrite(D1,HIGH);  
Serial.println();  
// return;  
delay (1000);

}  
if not{  
Serial.print(“Lamp 1 On”);  
digitalWrite(D1,LOW);  
Serial.println();

```
}

```

// update value  
//For Lamp 2  
if (b==0) {  
Serial.print(“Light 2 Off”);  
digitalWrite(D2,HIGH);  
Serial.println();  
//return;  
delay (1000);

}  
if not{  
Serial.print(“Lamp 2 On”);  
digitalWrite(D2,LOW);  
Serial.println();  
}

//For Lamp 3  
if (c==0) {  
Serial.print(“Light 3 Off”);  
digitalWrite(D3,HIGH);  
Serial.println();  
// return;  
delay (1000);  
}  
if not{  
Serial.print(“Lamp 3 On”);  
digitalWrite(D3,LOW);  
Serial.println();  
}  
// update value

//For Lamp 4  
if (d==0) {  
Serial.print(“Light 4 Off”);  
digitalWrite(D4,HIGH);  
Serial.println();  
// return;  
delay (1000);  
}  
if not{  
Serial.print(“Light 4 Off”);  
digitalWrite(D4,LOW);  
Serial.println();  
delay (1000);  
return;

```
 //update value
        
}

```

}

---

<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:** [December 11, 2021, 11:10am UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988/11 "2021-12-11T11:10:53Z")

</div>

First of all,  
I never worked with Arduino BT device connected to Firebase and therefore I am just giving you what I noticed.

1 - The script that of the BT is expecting **integers** for `L1, L2, L3, L4` but you are supplying **text**.

2 - The script is resetting all values to **0** whenever it starts which means you have to first run it and keep it in a loop then change the settings from your app.

All the other commands in the script are library specific and I wouldn’t have enough knowledge about it to comment.

---

<div class="post-metadata">

**Author:** ![uj-ulongjep](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/uj-ulongjep/32/119596_2.png) [@uj-ulongjep](https://community.thunkable.com/u/uj-ulongjep)\
**Post date:** [December 11, 2021, 12:27pm UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988/12 "2021-12-11T12:27:31Z")

</div>

Thank you master … for the enlightenment

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:19pm UTC](https://community.thunkable.com/t/how-to-save-data-from-realtime-database-to-google-spreadsheet-or-other-place/1397988/13 "2024-11-08T13:19:45Z")

</div>


