# ESP32 not connecting to Google Sheets

**URL:** <https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210>\
**Category:** General Guidance\
**Created:** [June 24, 2023, 11:25am UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210 "2023-06-24T11:25:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![krishna\_agarwal](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/krishna_agarwal/32/977090_2.png) [@krishna\_agarwal](https://forum.arduino.cc/u/krishna_agarwal)\
**Post date:** [June 24, 2023, 11:25am UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/1 "2023-06-24T11:25:17Z")

</div>

Hi Community  
Currently I am working on ESP32 and trying to build a simple project to connect to google sheets via script editor and post the ESP32 device ID and I am trying from last 5 hours but again and again getting failed after multiple attempts for searching and hit and try I am finally here to seek help

Here is my code

```arduino
#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid = " ****";
const char* password = "***";
String GOOGLE_SCRIPT_ID = "***";

const int sendInterval = 5000;

void setup() {
  Serial.begin(115200);
  delay(10);
  
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  Serial.print("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("OK");
}

void loop() {
  // Store the device ID in a variable
  String deviceID = "ESP32 ID: " + String((uint32_t)(ESP.getEfuseMac() >> 32), HEX) + String((uint32_t)ESP.getEfuseMac(), HEX);

  // Print the device ID variable
  Serial.println(deviceID);
  
  String param = "deviceID=" + deviceID; // Removed unnecessary function call

  Serial.println(param);
  write_to_google_sheet(param);
  
  delay(sendInterval);
}

void write_to_google_sheet(String params) {
  HTTPClient http;
  String url = "https://script.google.com/macros/s/" + GOOGLE_SCRIPT_ID + "/exec?" + params;
  
  Serial.println("Posting GPS data to Google Sheet");
  http.begin(url.c_str());
  http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
  int httpCode = http.GET();
  Serial.print("HTTP Status Code: ");
  Serial.println(httpCode);
  
  String payload;
  if (httpCode > 0) {
    payload = http.getString();
    Serial.println("Payload: " + payload);
  }
  
  http.end();
}

```

And here is my google script code

```arduino
var ss = SpreadsheetApp.openById(***');
var sheet = ss.getSheetByName('Sheet1');

function doGet(e) {
  if (e.parameter.deviceID === undefined) {
    return ContentService.createTextOutput("Received data is undefined");
  }
  
  var deviceID = e.parameter.deviceID;
  var dateTime = new Date();
  var nextRow = sheet.getLastRow() + 1;
  
  sheet.getRange("A" + nextRow).setValue(deviceID);
  
  return ContentService.createTextOutput("Status Updated in Google Sheet");
}

function doPost(e) {
  var val = e.parameter.value;
  
  if (val !== undefined){
    var range = sheet.getRange('A2');
    range.setValue(val);
  }
}

```

I have hidden some personal information with \*\*\*\*

Any help will be great Appreciable. Please guide me how to do the same and if possible please provide the code

Thanks & Regards  
Krishna :}

---

<div class="post-metadata">

**Author:** ![krishna\_agarwal](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/krishna_agarwal/32/977090_2.png) [@krishna\_agarwal](https://forum.arduino.cc/u/krishna_agarwal)\
**Post date:** [June 24, 2023, 12:00pm UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/2 "2023-06-24T12:00:31Z")

</div>

Can anyone Please help with the same I am eagerly waiting

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [June 24, 2023, 1:54pm UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/3 "2023-06-24T13:54:29Z")

</div>

You do have debugging Serial.print to serial monitor. What do they show?

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [June 24, 2023, 3:44pm UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/4 "2023-06-24T15:44:29Z")

</div>

Hi,  
Can I suggest you edit your subject to.

ESP32 not connecting to Google Sheets.

That way you may get some Google Sheet experts to read this thread.

Tom... 😃 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![krishna\_agarwal](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/krishna_agarwal/32/977090_2.png) [@krishna\_agarwal](https://forum.arduino.cc/u/krishna_agarwal)\
**Post date:** [June 25, 2023, 11:31am UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/5 "2023-06-25T11:31:33Z")

</div>

Yes I do and it is showing "Status Updated in Google Sheet" but as soon as I open the sheet nothing is being posted

---

<div class="post-metadata">

**Author:** ![krishna\_agarwal](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/krishna_agarwal/32/977090_2.png) [@krishna\_agarwal](https://forum.arduino.cc/u/krishna_agarwal)\
**Post date:** [June 25, 2023, 11:32am UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/6 "2023-06-25T11:32:04Z")

</div>

Thanks for the suggestion

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [June 25, 2023, 11:59am UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/7 "2023-06-25T11:59:25Z")

</div>

Okey. The ESP sent dat and makes rhe debug serial.print. Is there any acknowledge that the data was received properly?

---

<div class="post-metadata">

**Author:** ![krishna\_agarwal](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/krishna_agarwal/32/977090_2.png) [@krishna\_agarwal](https://forum.arduino.cc/u/krishna_agarwal)\
**Post date:** [June 26, 2023, 9:06am UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/8 "2023-06-26T09:06:14Z")

</div>

Yes in the code I have written to push data and print "Status Updated in Google Sheet" and I am receiving the same but nothing is being displayed I have already done posting ldr sensor data to google sheets and its easily worked out but when I change the code for getting the device id nothing is being posted also without pushing the data I directly tried to fetch device ID in serial monitor that too work can anyone please help me in the code I am really stuck 🤧

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [June 26, 2023, 9:35am UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/9 "2023-06-26T09:35:48Z")

</div>

Regarding the technical details I've got no knowledge. Good that You managed to push ldr data to G S. Getting device ID needs more studying.  
I'm sure a knowing helper will pop up.

---

<div class="post-metadata">

**Author:** ![krishna\_agarwal](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/krishna_agarwal/32/977090_2.png) [@krishna\_agarwal](https://forum.arduino.cc/u/krishna_agarwal)\
**Post date:** [June 27, 2023, 6:58am UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/10 "2023-06-27T06:58:01Z")

</div>

Thanks for the appreciation I will surely wait for any help and I am dam sure in this big community anyone will surely help me out of this

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [June 27, 2023, 9:58am UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/11 "2023-06-27T09:58:14Z")

</div>

What do You think about reply #4?

---

<div class="post-metadata">

**Author:** ![krishna\_agarwal](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/krishna_agarwal/32/977090_2.png) [@krishna\_agarwal](https://forum.arduino.cc/u/krishna_agarwal)\
**Post date:** [June 27, 2023, 1:38pm UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/12 "2023-06-27T13:38:02Z")

</div>

Hi there actually on the same day I have updated the title but haven't checked that and today I have seen that it is not been updated 🙁

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [June 27, 2023, 1:57pm UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/13 "2023-06-27T13:57:12Z")

</div>

Hit it again! Strange things sometimes happen.  
Make sure You don't create a duplicate question.

---

<div class="post-metadata">

**Author:** ![krishna\_agarwal](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/krishna_agarwal/32/977090_2.png) [@krishna\_agarwal](https://forum.arduino.cc/u/krishna_agarwal)\
**Post date:** [June 27, 2023, 2:17pm UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/14 "2023-06-27T14:17:16Z")

</div>

> [@Railroader](#):
>
> Make sure You don't create a duplicate question.

For Sure I will never do that to waste anyone presious time

> [@Railroader](#):
>
> Hit it again! Strange things sometimes happen.

Can you please confirm is it updated or not?

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [June 27, 2023, 3:12pm UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/15 "2023-06-27T15:12:47Z")

</div>

It's changed.

---

<div class="post-metadata">

**Author:** ![krishna\_agarwal](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/krishna_agarwal/32/977090_2.png) [@krishna\_agarwal](https://forum.arduino.cc/u/krishna_agarwal)\
**Post date:** [June 27, 2023, 4:00pm UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/16 "2023-06-27T16:00:37Z")

</div>

Thanks for the information hope someone will help me out in this

---

<div class="post-metadata">

**Author:** ![krishna\_agarwal](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/krishna_agarwal/32/977090_2.png) [@krishna\_agarwal](https://forum.arduino.cc/u/krishna_agarwal)\
**Post date:** [June 30, 2023, 8:07am UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/17 "2023-06-30T08:07:46Z")

</div>

Can anyone please response to it

---

<div class="post-metadata">

**Author:** ![krishna\_agarwal](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/krishna_agarwal/32/977090_2.png) [@krishna\_agarwal](https://forum.arduino.cc/u/krishna_agarwal)\
**Post date:** [August 14, 2023, 12:57pm UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/18 "2023-08-14T12:57:24Z")

</div>

Hi Members

Any Information regarding the same?

---

<div class="post-metadata">

**Author:** ![flaviomsouza](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/flaviomsouza/32/815206_2.png) [@flaviomsouza](https://forum.arduino.cc/u/flaviomsouza)\
**Post date:** [December 22, 2023, 10:42pm UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/20 "2023-12-22T22:42:45Z")

</div>

Trying this [Tutorial](https://iotdesignpro.com/articles/esp32-data-logging-to-google-sheets-with-google-scripts), works fine here.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 19, 2024, 10:43pm UTC](https://forum.arduino.cc/t/esp32-not-connecting-to-google-sheets/1141210/21 "2024-06-19T22:43:05Z")

</div>

Closed on June 19, 2024, 10:43pm UTC

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