---
title: "Use Google Sheets API from Pico LTE"
description: "Use the Google Sheets API from the Pico LTE over the cellular connection: create a spreadsheet, add data and rows, delete and read data."
url: "https://docs.sixfab.com/cellular/pico-lte/micropython-sdk/google-sheets-api/"
last_updated: "2026-10-12"
---

# Use Google Sheets API from Pico LTE

Use the Google Sheets API from the Pico LTE over the cellular connection: create a spreadsheet, add data and rows, delete and read data.

These examples use the Google Sheets API from the Pico LTE over the cellular connection: create a spreadsheet, add data and rows, delete data and read it. They need a Google Cloud project with the Sheets API, OAuth credentials, an API key and a refresh token.

## Before you begin

**Required**

**Hardware**

- **Sixfab Pico LTE or Pico LTE 2**: Registered and active in Sixfab Connect, connected to the computer with the micro USB cable.

**Software**

- **Thonny with MicroPython and the Pico LTE SDK**: Set up as in the [quickstart](https://docs.sixfab.com/cellular/pico-lte/quickstart/).
- **config.json**: In the root of the board: [Prepare the configuration file](https://docs.sixfab.com/cellular/pico-lte/micropython-sdk/configuration-file/).
- **Google account**: For the Google Cloud Console and Google Sheets.

## Set up Google Sheets API

1. **Create project.**

   Sign in to the [Google Cloud Console](https://console.cloud.google.com/) and create a project with a name.

   ![Google Cloud Select a project dialog with the New Project button highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_1.webp)

   ![Google Cloud new project form with project name My Project and the Create button](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_2.png)

2. **Enable Google Sheets API.**

   Select the project, open **APIs & Services**, click **ENABLE APIS AND SERVICES**, search for **Google Sheets API** and enable it.

   ![Google Cloud navigation menu with My Project selected and APIs & Services highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_3.webp)

   ![APIs & Services page with Enabled APIs & services and Enable APIs and Services highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_4.png)

   ![Google Sheets API product details page with the Enable button highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_5.png)

3. **Configure consent screen.**

   Click **Create Credentials**, select **Google Sheets API** and **User data**, and continue.

   ![Google Sheets API page with the Create Credentials button highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_6.png)

   ![Credential Type step with Google Sheets API and User data selected and Next highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_7.png)

   Fill in the app information, with your Gmail address in both email fields, and click **SAVE AND CONTINUE**.

   ![OAuth Consent Screen form with app name, support email and developer email fields marked](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_8.png)

4. **Add scopes.**

   Click **ADD OR REMOVE SCOPES**, search for `spreadsheets`, tick the scope and click **UPDATE**. Do the same for `drive`, then click **SAVE AND CONTINUE**.

   ![OAuth Scopes step with the Add or Remove Scopes button highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_9.png)

   ![Scope filter for spreadsheets with the googleapis.com/auth/spreadsheets value highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_10.webp)

   ![Update selected scopes with the Google Sheets spreadsheets scope checkbox and Update button](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_11.png)

   ![Scope filter for drive with the googleapis.com/auth/drive value highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_12.png)

   ![Update selected scopes with the auth/drive scope checkbox and Update button highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_13.png)

5. **Create OAuth client.**

   Select **Web application**, name the client and add `http://localhost` and `https://developers.google.com/oauthplayground` to **Authorized redirect URIs**, then create it.

   ![OAuth Client ID form for a web application with OAuth Playground and localhost redirect URIs](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_14.png)

   Download the client information: the file holds the client ID and the client secret.

   ![Your Credentials step with the Download button and Done highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_15.png)

6. **Publish app.**

   In **Enabled APIs & services**, click **PUBLISH APP**, then **CONFIRM**.

   ![OAuth consent screen page for MyApp with the Publish App button highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_16.png)

7. **Create API key.**

   Under **Credentials**, create an API key and keep it.

   ![Credentials page with Create Credentials menu open and API key option highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_17_-_1.png)

   ![Google Cloud API key created dialog with the redacted key and copy button](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_17.png)

## Get refresh token

1. **Open OAuth 2.0 Playground.**

   Open [developers.google.com/oauthplayground](https://developers.google.com/oauthplayground), open the settings and enter your client ID and client secret. The client secret is also in **Credentials → OAuth 2.0 Client IDs**: click the client name, then see **Client secrets** under **Additional information**.

   ![OAuth 2.0 Playground settings with Use your own OAuth credentials checked and Client ID and secret fields](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_18.webp)

2. **Authorize Sheets scope.**

   Select `https://spreadsheets.google.com/feeds/` in the list on the left and click **Authorize APIs**.

   ![OAuth 2.0 Playground with the Spreadsheets v3 feeds scope selected and the Authorize APIs button](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_19.png)

   Choose your account, then click **Advanced** and **Go to MyApp (unsafe)**, then **Continue**.

   ![Google hasn't verified this app warning with the Go to MyApp (unsafe) link highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_20.webp)

   ![Sign in with Google consent screen asking for Google Sheets access, with Continue button](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_21.png)

3. **Exchange code for tokens.**

   Click **Exchange authorization code for tokens**: a refresh token appears without it too, but the exchange gives a new one. Keep the refresh token.

   ![OAuth 2.0 Playground Step 2 with the Exchange authorization code for tokens button highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_22.png)

   ![OAuth 2.0 Playground Step 2 showing filled Refresh token and Access token fields](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google_Sheets_API_Usage_with_Pico_LTE_-_23.png)

## Prepare spreadsheet

Every example except Create Sheet works on an existing spreadsheet. Create one in [Google Sheets](https://docs.google.com/spreadsheets/), or with Create Sheet below. The spreadsheet ID is in its URL, `https://docs.google.com/spreadsheets/d/[SPREADSHEET_ID]`; add or rename a sheet with the buttons at the bottom: the examples name the sheet.

![Google Sheets start page with the Blank new spreadsheet option highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Create-Spreadsheet-1.png)

![New Google spreadsheet with the spreadsheet ID in the URL, add sheet and sheet menu buttons marked](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Create-Spreadsheet-2.png)

## Run examples

The scripts are in the `examples/google_sheets` folder of the [SDK repository](https://github.com/sixfab/pico_lte_micropython-sdk). In `config.json`, set the values you saved:

```json
{
    "google_sheets": {
        "api_key": "[API_KEY]",
        "spreadsheetId": "[SPREADSHEET_ID]",
        "client_id": "[CLIENT_ID]",
        "client_secret": "[CLIENT_SECRET]",
        "refresh_token": "[REFRESH_TOKEN]"
    }
}
```

Open the script in Thonny, set the parameters of its function and click **Run**.

**Create sheet**

`create_sheet.py` creates a spreadsheet; `spreadsheetId` is not needed in `config.json`: the function writes the new spreadsheet’s ID there itself.

| Parameter | Type | Use |
| --- | --- | --- |
| `sheets` | list, default None | Names of the sheets of the new spreadsheet; up to 5 are recommended. |

![Thonny running create_sheet.py on Pico LTE with Sheet1 and Sheet2, shell showing status 0](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Create-Sheet-1.png)

The new spreadsheet is in your [Google Sheets](https://docs.google.com/spreadsheets/u/0/), with its sheets.

![Google Sheets home with the new Untitled spreadsheet highlighted in the Today list](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Create-Sheet-2.png)

![New Google spreadsheet with Sheet1 and Sheet2 tabs highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Create-Sheet-3.png)

**Add data**

`add_data.py` writes values to a range of cells.

| Parameter | Type | Use |
| --- | --- | --- |
| `sheet` | str, default None | Name of the target sheet. |
| `data` | list, default None | Values to write, as a two-dimensional list. |
| `data_range` | str, required | Target cell range, in [A1 notation](https://developers.google.com/sheets/api/guides/concepts#cell). |

![Thonny running add_data.py with data_range A1:C2, shell showing updatedCells 6](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Add-Data-1.png)

![Google Sheet with values 1 2 3 and 4 5 6 in cells A1:C2](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Add-Data-2.png)

**Add row**

`add_row.py` appends rows after the last row of the sheet.

| Parameter | Type | Use |
| --- | --- | --- |
| `sheet` | str, default None | Name of the target sheet. |
| `data` | list, default None | Values of the rows, as a two-dimensional list. |

![Thonny running add_row.py appending row 1, 2, 3, 4 to Sheet1, shell showing range A3:D3](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Add-Row-1.png)

![Google Sheet with new row 3 containing 1, 2, 3, 4 highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Add-Row-2.png)

**Delete data**

`delete_data.py` clears a range of cells. Put some data in the sheet first.

![Google Sheet with test values 1 to 8 in cells A1:D2 highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Delete-Data-1.png)

| Parameter | Type | Use |
| --- | --- | --- |
| `sheet` | str, default None | Name of the target sheet. |
| `data_range` | str, default None | Cell range to clear, in [A1 notation](https://developers.google.com/sheets/api/guides/concepts#cell); without it, the whole sheet. |

![Thonny running delete_data.py with data_range A1:B2, shell showing clearedRange Sheet1!A1:B2](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Delete-Data-2.png)

![Google Sheet with cells A1:B2 cleared, leaving 3, 4, 7, 8 in columns C and D](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Delete-Data-3.png)

**Get data**

`get_data.py` reads a range of cells and prints it in the shell. Put some data in the sheet first.

![Google Sheet with test values 1 to 8 in cells A1:D2 highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Get-Data-1.png)

| Parameter | Type | Use |
| --- | --- | --- |
| `sheet` | str, default None | Name of the target sheet. |
| `data_range` | str, default None | Cell range to read, in [A1 notation](https://developers.google.com/sheets/api/guides/concepts#cell); without it, the whole sheet. |

![Thonny running get_data.py for range A1:D2, shell printing values 1 to 8](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Google-Sheets-API-Usage-with-Pico-LTE-Get-Data-2.png)

If `sheet` is not given, the functions read it from a `sheet` key in the `google_sheets` section of `config.json`.
