Save Arduino data to spreadsheets

We'll show you how to make your Arduino add rows of data to a Google spreadsheet. You can use this to log data from sensors connected to your Arduino, like temperature readings over time, or other instances where your Arduino is receiving information you'd like to record.

This sketch uses our Google > Sheets > AppendValues Choreo.

Get Set Up

1Make sure you have a Temboo account. If you don't already have one, you can register for a free account here.

2Since this sketch uses a Google spreadsheet, you'll also need a Google account.

3Login to Google's Developer Console, and create a new Project if you haven't done so already.

4Under the API Manager section, select Library and make sure you've enabled API Access for the Google Sheets API.

5Select Credentials in the API Manager section, and create a new Client ID specifying Web application for the Application Type.

6When configuring the Consent Screen, make sure you fill out the Email Address and Product Name fields.

7Save the Consent Screen details and specify the callback URL below as the Authorized Redirect URI. Make sure to replace ACCOUNT_NAME with your Temboo account name.

8Run the Google > OAuth > InitializeOAuth Choreo, specifying the Client ID from the app you registered at Google and the following Scope:

Google OAuth Inputs

The InitializeOAuth choreo will return an authorization URL and a callback ID (required for the FinalizeOAuth step).

9Open a new web browser, navigate to the authorization URL returned by the InitializeOAuth Choreo, and click "Accept" to grant the app access to your Google account.

Google OAuth Accept

10Run the Google > OAuth > FinalizeOAuth Choreo, specifying the callback ID returned earlier by the InitializeOAuth Choreo. This process will return a Refresh Token which can be used along with the Client ID and Client Secret to authenticate with Google.

11Create a Google Spreadsheet. When viewing your spreadsheet, you'll see a spreadsheet ID in your browser's URL bar. Copy this ID because you'll need it when running the AppendValues Choreo. In the example below, the highlighted part is the Spreadsheet ID.

Google Spreadsheet

Auto-Generate the Sketch

12Go to the Google > Sheets > AppendValues in our Library.

13Turn on IoT Mode and make sure that you've added details about the shield that your Arduino board is using to connect to the internet.

14Test out the Choreo from our website and confirm that your Google Spreadsheet was updated successfully.

Google Spreadsheets Inputs

Testing the AppendValues Choreo from our website

15When you've confirmed that the Choreo runs successfully, you can copy the auto-generated Arduino code from the Code section and paste it into your Arduino IDE.

16The auto-generated sketch references the TembooAccount.h header file, which contains your Temboo account information and internet shield details. You'll find the code for this file beneath your generated sketch. Create a new tab in the Arduino IDE called TembooAccount.h and copy in the header file information.

Run The Sketch

17With both files in place you are ready to upload the sketch and start adding data to your spreadsheet. Time to get logging!

Extending The Sketch

You'll notice that your sketch always sends the same value to your spreadsheet. Of course, it's far more interesting to send dynamic values i.e., sensor values. Here's an example of what you need to do to make that happen.

18Add the follow line of code to your setup() method so that you're reading the value on pin A0:

pinMode(A0, INPUT);

19Next, replace the line of code that currently adds data to your spreadsheet with the following three lines so that your sketch reads the value on pin A0 and adds it to the spreadsheet instead:

String sensorValue = String(analogRead(A0));
String ValuesValue = "[[\"" + sensorValue + "\"]]";
AppendValuesChoreo.addInput("Values", ValuesValue);

20That's it! Now your sketch should be generating dynamic values and adding them to your Google Spreadsheet.

What's Next?

Now that you've mastered working with Google Spreadsheets, why not check out the rest of the 2000+ Choreos in our Library and get inspired for your next project.

Need Help?

We're always happy to help. Just email us at, and we'll answer your questions.