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

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://One Way to Connect Firebase to Google Sheets) …but it did not work

1 Like

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. :slight_smile: 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. :slight_smile:

3 Likes

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

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.

1 Like

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 :pray:.

1 Like

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!

1 Like

Also more work to set up. :slight_smile:

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

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.

3 Likes

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 :face_with_raised_eyebrow: 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.

2 Likes

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

1 Like

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

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

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
//
// 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
#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
        
}

}

1 Like

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.

Thank you master … for the enlightenment

1 Like