{"id":56442,"date":"2018-04-02T11:04:13","date_gmt":"2018-04-02T11:04:13","guid":{"rendered":"http:\/\/randomnerdtutorials.com\/?p=56442"},"modified":"2024-01-24T11:33:29","modified_gmt":"2024-01-24T11:33:29","slug":"esp32-esp8266-publish-sensor-readings-to-google-sheets","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-esp8266-publish-sensor-readings-to-google-sheets\/","title":{"rendered":"ESP32 Publish Sensor Readings to Google Sheets (ESP8266 Compatible)"},"content":{"rendered":"\n<p>In this tutorial we&#8217;re going to show you how to publish sensor readings to Google Sheets using ESP32 or ESP8266 board. As an example, we&#8217;ll publish temperature, humidity, and pressure readings using the BME280 sensor to a Google Sheets spreadsheet every 30 minutes &#8211; we&#8217;ll be using IFTTT.<\/p>\n\n\n\n<!--more-->\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"674\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/esp8266_google_sheets_thumbnail.jpg?resize=1200%2C674&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-57260\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/esp8266_google_sheets_thumbnail.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/esp8266_google_sheets_thumbnail.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/esp8266_google_sheets_thumbnail.jpg?resize=768%2C431&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/esp8266_google_sheets_thumbnail.jpg?resize=1024%2C575&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclblue\">You can use IFTTT to integrate with Google Sheets, but at the moment we recommend integrating with Google Sheets using a Google Service Account instead. We recommend following this tutorial: <a href=\"https:\/\/randomnerdtutorials.com\/esp32-datalogging-google-sheets\/\" title=\"\">ESP32 Datalogging to Google Sheets (using Google Service Account)<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Project Overview<\/h2>\n\n\n\n<p>The following figure shows an overview of what you&#8217;ll achieve by the end of this project.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"640\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/esp32_google_sheets_project_overview.jpg?resize=750%2C640&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-57685\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/esp32_google_sheets_project_overview.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/esp32_google_sheets_project_overview.jpg?resize=300%2C256&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>First, the ESP connects to your Wi-Fi network;<\/li>\n\n\n\n<li>Then, the BME280 takes the temperature, humidity, and pressure readings;<\/li>\n\n\n\n<li>Your ESP32 or ESP8266 communicates with the IFTTT Webhooks service that publishes the&nbsp;readings to a spreadsheet on Google Sheets that is saved in your Google Drive&#8217;s folder;<\/li>\n\n\n\n<li>After publishing the readings, the ESP goes into deep sleep mode for 30 minutes;<\/li>\n\n\n\n<li>After 30 minutes the ESP wakes up;<\/li>\n\n\n\n<li>After waking up, the ESP connects to Wi-Fi, and the process repeats.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Creating Your IFTTT Account<\/h2>\n\n\n\n<p>For this project we&#8217;ll be using IFTTT to integrate with Google Sheets. So, the first step is creating an account on IFTTT if you don&#8217;t have one. Creating an account on IFTTT is free!<\/p>\n\n\n\n<p>Go the official site:&nbsp;<a href=\"https:\/\/ifttt.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">ifttt.com<\/a>&nbsp;and enter your email to get started.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"353\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/ifttt.jpg?resize=750%2C353&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56609\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/ifttt.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/ifttt.jpg?resize=300%2C141&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Creating an Applet<\/h2>\n\n\n\n<p>Next, you need to create a new applet. Follow the next steps to create a new applet:<\/p>\n\n\n\n<p><strong>1)<\/strong> Go to &#8220;My Applets&#8221;and create a new applet by clicking the &#8220;New Applet&#8221; button.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1045\" height=\"252\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/1_new_applet-1.png?resize=1045%2C252&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56635\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/1_new_applet-1.png?w=1045&amp;quality=100&amp;strip=all&amp;ssl=1 1045w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/1_new_applet-1.png?resize=300%2C72&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/1_new_applet-1.png?resize=768%2C185&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/1_new_applet-1.png?resize=1024%2C247&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1045px) 100vw, 1045px\" \/><\/figure><\/div>\n\n\n<p><strong>2)<\/strong> Click on the &#8220;this&#8221; word that is in a blue color &#8211; as highlighted in the figure below.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"760\" height=\"203\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/2_this.png?resize=760%2C203&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56636\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/2_this.png?w=760&amp;quality=100&amp;strip=all&amp;ssl=1 760w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/2_this.png?resize=300%2C80&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 760px) 100vw, 760px\" \/><\/figure><\/div>\n\n\n<p><br><strong>3)<\/strong> Search for the &#8220;Webhooks&#8221; service and select the Webhooks icon.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"547\" height=\"340\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/3_webhooks.png?resize=547%2C340&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56637\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/3_webhooks.png?w=547&amp;quality=100&amp;strip=all&amp;ssl=1 547w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/3_webhooks.png?resize=300%2C186&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 547px) 100vw, 547px\" \/><\/figure><\/div>\n\n\n<p><strong>4)<\/strong> Choose the &#8220;Receive a web request&#8221; trigger.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"346\" height=\"387\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/4_receive_request.png?resize=346%2C387&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56638\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/4_receive_request.png?w=346&amp;quality=100&amp;strip=all&amp;ssl=1 346w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/4_receive_request.png?resize=268%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 268w\" sizes=\"(max-width: 346px) 100vw, 346px\" \/><\/figure><\/div>\n\n\n<p><strong>5)<\/strong> Give a name to the event. In this case &#8220;<strong>bme280_readings<\/strong>&#8221; as shown in the figure below. Then, click the &#8220;Create trigger&#8221; button.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"489\" height=\"525\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/5_create_trigger.png?resize=489%2C525&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56639\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/5_create_trigger.png?w=489&amp;quality=100&amp;strip=all&amp;ssl=1 489w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/5_create_trigger.png?resize=279%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 279w\" sizes=\"(max-width: 489px) 100vw, 489px\" \/><\/figure><\/div>\n\n\n<p><strong>6)<\/strong> Click the &#8220;that&#8221; word to proceed.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"680\" height=\"104\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/6_that.png?resize=680%2C104&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56640\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/6_that.png?w=680&amp;quality=100&amp;strip=all&amp;ssl=1 680w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/6_that.png?resize=300%2C46&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/figure><\/div>\n\n\n<p><strong>7)<\/strong> Search for the &#8220;Google Sheets&#8221; service, and select the Google Sheets icon.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"548\" height=\"354\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/7_google_sheets.png?resize=548%2C354&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56641\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/7_google_sheets.png?w=548&amp;quality=100&amp;strip=all&amp;ssl=1 548w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/7_google_sheets.png?resize=300%2C194&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 548px) 100vw, 548px\" \/><\/figure><\/div>\n\n\n<p><strong>8)<\/strong> If you haven&#8217;t connected with the Google Sheets service yet, you need to click the &#8220;Connect&#8221; button.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"268\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/connect-google-sheets.jpg?resize=500%2C268&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56655\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/connect-google-sheets.jpg?w=500&amp;quality=100&amp;strip=all&amp;ssl=1 500w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/connect-google-sheets.jpg?resize=300%2C161&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/connect-google-sheets.jpg?resize=280%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 280w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure><\/div>\n\n\n<p><strong>9)<\/strong> Choose the &#8220;Add a row to spreadsheet&#8221; action.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"478\" height=\"342\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/8_select_add_row.png?resize=478%2C342&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56642\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/8_select_add_row.png?w=478&amp;quality=100&amp;strip=all&amp;ssl=1 478w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/8_select_add_row.png?resize=300%2C215&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 478px) 100vw, 478px\" \/><\/figure><\/div>\n\n\n<p><strong>10)<\/strong> Then, complete the action fields. Give the spreadsheet a name, leave the &#8220;Formatted row&#8221; field as default, and then, choose a Google Drive folder path. If you leave this field empty, IFTTT will create a folder called &#8220;IFTTT&#8221; in your Google Drive folder to save the spreadsheet. Finally, click the &#8220;Create action&#8221; button.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"480\" height=\"830\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/9_create_action.png?resize=480%2C830&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56643\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/9_create_action.png?w=480&amp;quality=100&amp;strip=all&amp;ssl=1 480w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/9_create_action.png?resize=173%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 173w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/figure><\/div>\n\n\n<p><strong>11)<\/strong> Your applet should be created after you press the &#8220;Finish&#8221; button.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"342\" height=\"454\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/10_review_and_finish.png?resize=342%2C454&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56644\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/10_review_and_finish.png?w=342&amp;quality=100&amp;strip=all&amp;ssl=1 342w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/10_review_and_finish.png?resize=226%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 226w\" sizes=\"(max-width: 342px) 100vw, 342px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Testing Your Applet<\/h2>\n\n\n\n<p>Before proceeding with the project, it is very important to test your applet first. Follow the next steps to test your applet.<\/p>\n\n\n\n<p><strong>1)<\/strong> Go to the <a href=\"https:\/\/ifttt.com\/maker_webhooks\" target=\"_blank\" rel=\"noreferrer noopener\">Webhooks Service page<\/a>, and click the &#8220;Documentation&#8221; button.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"261\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/1_maker_webhooks.png?resize=602%2C261&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56670\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/1_maker_webhooks.png?w=602&amp;quality=100&amp;strip=all&amp;ssl=1 602w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/1_maker_webhooks.png?resize=300%2C130&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 602px) 100vw, 602px\" \/><\/figure><\/div>\n\n\n<p><strong>2)<\/strong> A page as shown in the following figure will appear. The page shows your unique API key. You shouldn&#8217;t share your unique API key with anyone.<\/p>\n\n\n\n<p>Fill the &#8220;To trigger an Event&#8221; section as shown below &#8211; it is highlighted with red rectangles. Then, click the &#8220;Test it&#8221; button.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"777\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/2_unique_webhooks_test_page.png?resize=1200%2C777&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56671\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/2_unique_webhooks_test_page.png?w=1258&amp;quality=100&amp;strip=all&amp;ssl=1 1258w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/2_unique_webhooks_test_page.png?resize=300%2C194&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/2_unique_webhooks_test_page.png?resize=768%2C498&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/2_unique_webhooks_test_page.png?resize=1024%2C663&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p><strong>3)<\/strong> The event should be successfully triggered, and you&#8217;ll get a green message as shown below saying &#8220;Event has been triggered&#8221;.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"171\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/3_success_event_triggered.png?resize=750%2C171&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56672\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/3_success_event_triggered.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/3_success_event_triggered.png?resize=300%2C68&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p><strong>4)<\/strong> Go to your Google Drive. The IFTTT service should have created a folder called &#8220;IFTTT&#8221; with the &#8220;BME280_Readings&#8221; spreadsheet inside.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"531\" height=\"478\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/5_open_spreadsheet.png?resize=531%2C478&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56674\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/5_open_spreadsheet.png?w=531&amp;quality=100&amp;strip=all&amp;ssl=1 531w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/5_open_spreadsheet.png?resize=300%2C270&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 531px) 100vw, 531px\" \/><\/figure><\/div>\n\n\n<p><strong>5)<\/strong> Open the spreadsheet, and you should see the values you&#8217;ve filled previously to test the applet.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"889\" height=\"452\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/6_success_test.png?resize=889%2C452&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56669\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/6_success_test.png?w=889&amp;quality=100&amp;strip=all&amp;ssl=1 889w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/6_success_test.png?resize=300%2C153&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/6_success_test.png?resize=768%2C390&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 889px) 100vw, 889px\" \/><\/figure><\/div>\n\n\n<p>Continue reading this post to see how to integrate the IFTTT Google Sheets service with your ESP32 or ESP8266.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Parts Required<\/h2>\n\n\n\n<p>For this example we&#8217;ll take sensor readings from the BME280 sensor. Here&#8217;s a list of parts you need to build the circuit for this project:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32 board<\/a> (read <a href=\"https:\/\/makeradvisor.com\/esp32-development-boards-review-comparison\/\" target=\"_blank\" rel=\"noreferrer noopener\">Best ESP32 development boards comparison<\/a>)<\/li>\n\n\n\n<li>Alternative &#8211; <a href=\"https:\/\/makeradvisor.com\/tools\/esp8266-esp-12e-nodemcu-wi-fi-development-board\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP8266<\/a> board (read <a href=\"https:\/\/makeradvisor.com\/best-esp8266-wi-fi-development-board\/\" target=\"_blank\" rel=\"noreferrer noopener\">Best ESP8266 dev boards<\/a>)<\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/bme280-sensor-module\/\" target=\"_blank\" rel=\"noreferrer noopener\">BME280 sensor<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\" rel=\"noreferrer noopener\">Jumper wires<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/mb-102-solderless-breadboard-830-points\/\" target=\"_blank\" rel=\"noreferrer noopener\">Breadboard<\/a><\/li>\n<\/ul>\n\n\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Schematics<\/h2>\n\n\n\n<p>The BME280 sensor we&#8217;re using in this example can communicate with the ESP32\/ESP8266 using I2C communication protocol. So, we&#8217;re going to use the ESP I2C pins.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">BME280 with ESP32<\/h3>\n\n\n\n<p>Follow the next schematic diagram to wire the BME280 sensor if you&#8217;re using an ESP32.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/ESP32-bme280_bb.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"652\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/ESP32-bme280_bb.png?resize=750%2C652&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-56623\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/ESP32-bme280_bb.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/ESP32-bme280_bb.png?resize=300%2C261&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/a><\/figure><\/div>\n\n\n<p><em>(This schematic uses the ESP32 DEVKIT V1 module version with 36 GPIOs \u2013 if you\u2019re using another model, please check the pinout for the board you\u2019re using.)<\/em><\/p>\n\n\n\n<p><strong>Recommended reading:<\/strong> <a href=\"https:\/\/randomnerdtutorials.com\/esp32-bme280-arduino-ide-pressure-temperature-humidity\/\">ESP32 with BME280 Sensor using Arduino IDE (Pressure, Temperature, Humidity)<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">BME280 with ESP8266<\/h3>\n\n\n\n<p>Follow the next schematic diagram if you&#8217;re using an ESP8266 12E.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/bme_280_esp8266_bb.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"753\" height=\"583\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/bme_280_esp8266_bb.png?resize=753%2C583&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-57695\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/bme_280_esp8266_bb.png?w=753&amp;quality=100&amp;strip=all&amp;ssl=1 753w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/bme_280_esp8266_bb.png?resize=300%2C232&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 753px) 100vw, 753px\" \/><\/a><\/figure><\/div>\n\n\n<p class=\"rntbox rntclblue\"><strong>Note: <\/strong> to use <a href=\"https:\/\/randomnerdtutorials.com\/esp8266-deep-sleep-with-arduino-ide\/\">deep sleep with the ESP8266<\/a>, you need to wire D0 (GPIO16) to the RST pin.<\/p>\n\n\n\n<p><strong>Recommended reading:<\/strong> <a href=\"https:\/\/randomnerdtutorials.com\/esp8266-bme280-arduino-ide\/\">ESP8266 with BME280 using Arduino IDE (Pressure, Temperature, Humidity)<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing the BME280 library<\/h2>\n\n\n\n<p>To take readings from the BME280 sensor module we\u2019ll use the&nbsp;<a href=\"https:\/\/github.com\/adafruit\/Adafruit_BME280_Library\" target=\"_blank\" rel=\"noreferrer noopener\">Adafruit_BME280 library<\/a>. Follow the next steps to install the library in your Arduino IDE:<\/p>\n\n\n\n<p>Open your Arduino IDE and go to&nbsp;<strong>Sketch&nbsp;<\/strong>&gt;&nbsp;<strong>Include Library<\/strong>&nbsp;&gt;&nbsp;<strong>Manage Libraries<\/strong>. The Library Manager should open.<\/p>\n\n\n\n<p>Search for \u201c<strong>adafruit bme280<\/strong>&nbsp;\u201d on the Search box and install the library.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"786\" height=\"443\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/install-bme280.png?resize=786%2C443&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing the BME280 library Arduino IDE\" class=\"wp-image-70233\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/install-bme280.png?w=786&amp;quality=100&amp;strip=all&amp;ssl=1 786w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/install-bme280.png?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/install-bme280.png?resize=768%2C433&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Installing the Adafruit_Sensor library<\/h2>\n\n\n\n<p>To use the BME280 library, you also need to install the&nbsp;<a href=\"https:\/\/github.com\/adafruit\/Adafruit_Sensor\" target=\"_blank\" rel=\"noreferrer noopener\">Adafruit_Sensor library<\/a>. Follow the next steps to install the library in your Arduino IDE:<\/p>\n\n\n\n<p>Go to&nbsp;<strong>Sketch&nbsp;<\/strong>&gt;&nbsp;<strong>Include Library<\/strong>&nbsp;&gt;&nbsp;<strong>Manage Libraries<\/strong>&nbsp;and type \u201c<strong>Adafruit Unified Sensor<\/strong>\u201d in the search box. Scroll all the way down to find the library and install it.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/adafruit_unified_sensor_library.png?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing Adafruit Unified Sensor library Arduino IDE\" class=\"wp-image-84295\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/adafruit_unified_sensor_library.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/adafruit_unified_sensor_library.png?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<p>After installing the libraries, restart your Arduino IDE.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code<\/h2>\n\n\n\n<p>There\u2019s an add-on for the Arduino IDE allows you to program the ESP32 using the Arduino IDE and its programming language. Follow one of the next tutorials to prepare your Arduino IDE, if you haven&#8217;t already.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/installing-the-esp32-board-in-arduino-ide-windows-instructions\/\"><strong>Windows<\/strong>&nbsp;instructions \u2013 ESP32 Board in Arduino IDE<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/installing-the-esp32-board-in-arduino-ide-mac-and-linux-instructions\/\"><strong>Mac and Linux<\/strong>&nbsp;instructions \u2013 ESP32 Board in Arduino IDE<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/how-to-install-esp8266-board-arduino-ide\/\"> ESP8266 Board in Arduino IDE<\/a><\/li>\n<\/ul>\n\n\n\n<p>After making sure you have the ESP32 add-on installed, you can copy the following code to your Arduino IDE. <strong>But don\u2019t upload it yet!<\/strong> You need to make a few modifications to make it work for you.<\/p>\n\n\n\n<p class=\"rntbox rntcorange\"><strong>Note: <\/strong> this code works both with the ESP32 and the ESP8266.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n * Rui Santos \n * Complete Project Details http:\/\/randomnerdtutorials.com\n *\/\n \n#ifdef ESP32\n  #include &lt;WiFi.h&gt;\n#else\n  #include &lt;ESP8266WiFi.h&gt;\n#endif\n\n#include &lt;Wire.h&gt;\n#include &lt;Adafruit_Sensor.h&gt;\n#include &lt;Adafruit_BME280.h&gt;\n\n\/\/ Replace with your SSID and Password\nconst char* ssid     = &quot;REPLACE_WITH_YOUR_SSID&quot;;\nconst char* password = &quot;REPLACE_WITH_YOUR_PASSWORD&quot;;\n\n\/\/ Replace with your unique IFTTT URL resource\nconst char* resource = &quot;REPLACE_WITH_YOUR_IFTTT_URL_RESOURCE&quot;;\n\n\/\/ How your resource variable should look like, but with your own API KEY (that API KEY below is just an example):\n\/\/const char* resource = &quot;\/trigger\/bme280_readings\/with\/key\/nAZjOphL3d-ZO4N3k64-1A7gTlNSrxMJdmqy3&quot;;\n\n\/\/ Maker Webhooks IFTTT\nconst char* server = &quot;maker.ifttt.com&quot;;\n\n\/\/ Time to sleep\nuint64_t uS_TO_S_FACTOR = 1000000;  \/\/ Conversion factor for micro seconds to seconds\n\/\/ sleep for 30 minutes = 1800 seconds\nuint64_t TIME_TO_SLEEP = 1800;\n\n\/\/ Uncomment to use BME280 SPI\n\/*#include &lt;SPI.h&gt;\n#define BME_SCK 13\n#define BME_MISO 12\n#define BME_MOSI 11\n#define BME_CS 10*\/\n\n#define SEALEVELPRESSURE_HPA (1013.25)\n\nAdafruit_BME280 bme; \/\/ I2C\n\/\/Adafruit_BME280 bme(BME_CS); \/\/ hardware SPI\n\/\/Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); \/\/ software SPI\n\nvoid setup() {\n  Serial.begin(115200); \n  delay(2000);\n\n  \/\/ initialize BME280 sensor\n  bool status;\n  status = bme.begin(0x76);  \n  if (!status) {\n    Serial.println(&quot;Could not find a valid BME280 sensor, check wiring!&quot;);\n    while (1);\n  }\n\n  initWifi();\n  makeIFTTTRequest();\n    \n  #ifdef ESP32\n    \/\/ enable timer deep sleep\n    esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);    \n    Serial.println(&quot;Going to sleep now&quot;);\n    \/\/ start deep sleep for 3600 seconds (60 minutes)\n    esp_deep_sleep_start();\n  #else\n    \/\/ Deep sleep mode for 3600 seconds (60 minutes)\n    Serial.println(&quot;Going to sleep now&quot;);\n    ESP.deepSleep(TIME_TO_SLEEP * uS_TO_S_FACTOR); \n  #endif\n}\n\nvoid loop() {\n  \/\/ sleeping so wont get here \n}\n\n\/\/ Establish a Wi-Fi connection with your router\nvoid initWifi() {\n  Serial.print(&quot;Connecting to: &quot;); \n  Serial.print(ssid);\n  WiFi.begin(ssid, password);  \n\n  int timeout = 10 * 4; \/\/ 10 seconds\n  while(WiFi.status() != WL_CONNECTED  &amp;&amp; (timeout-- &gt; 0)) {\n    delay(250);\n    Serial.print(&quot;.&quot;);\n  }\n  Serial.println(&quot;&quot;);\n\n  if(WiFi.status() != WL_CONNECTED) {\n     Serial.println(&quot;Failed to connect, going back to sleep&quot;);\n  }\n\n  Serial.print(&quot;WiFi connected in: &quot;); \n  Serial.print(millis());\n  Serial.print(&quot;, IP address: &quot;); \n  Serial.println(WiFi.localIP());\n}\n\n\/\/ Make an HTTP request to the IFTTT web service\nvoid makeIFTTTRequest() {\n  Serial.print(&quot;Connecting to &quot;); \n  Serial.print(server);\n  \n  WiFiClient client;\n  int retries = 5;\n  while(!!!client.connect(server, 80) &amp;&amp; (retries-- &gt; 0)) {\n    Serial.print(&quot;.&quot;);\n  }\n  Serial.println();\n  if(!!!client.connected()) {\n    Serial.println(&quot;Failed to connect...&quot;);\n  }\n  \n  Serial.print(&quot;Request resource: &quot;); \n  Serial.println(resource);\n\n  \/\/ Temperature in Celsius\n  String jsonObject = String(&quot;{\\&quot;value1\\&quot;:\\&quot;&quot;) + bme.readTemperature() + &quot;\\&quot;,\\&quot;value2\\&quot;:\\&quot;&quot; + (bme.readPressure()\/100.0F)\n                      + &quot;\\&quot;,\\&quot;value3\\&quot;:\\&quot;&quot; + bme.readHumidity() + &quot;\\&quot;}&quot;;\n                      \n  \/\/ Comment the previous line and uncomment the next line to publish temperature readings in Fahrenheit                    \n  \/*String jsonObject = String(&quot;{\\&quot;value1\\&quot;:\\&quot;&quot;) + (1.8 * bme.readTemperature() + 32) + &quot;\\&quot;,\\&quot;value2\\&quot;:\\&quot;&quot; \n                      + (bme.readPressure()\/100.0F) + &quot;\\&quot;,\\&quot;value3\\&quot;:\\&quot;&quot; + bme.readHumidity() + &quot;\\&quot;}&quot;;*\/\n                      \n  client.println(String(&quot;POST &quot;) + resource + &quot; HTTP\/1.1&quot;);\n  client.println(String(&quot;Host: &quot;) + server); \n  client.println(&quot;Connection: close\\r\\nContent-Type: application\/json&quot;);\n  client.print(&quot;Content-Length: &quot;);\n  client.println(jsonObject.length());\n  client.println();\n  client.println(jsonObject);\n        \n  int timeout = 5 * 10; \/\/ 5 seconds             \n  while(!!!client.available() &amp;&amp; (timeout-- &gt; 0)){\n    delay(100);\n  }\n  if(!!!client.available()) {\n    Serial.println(&quot;No response...&quot;);\n  }\n  while(client.available()){\n    Serial.write(client.read());\n  }\n  \n  Serial.println(&quot;\\nclosing connection&quot;);\n  client.stop(); \n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP32_ESP8266_BME280_Google_Sheets.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Including your SSID and password<\/h3>\n\n\n\n<p>The first thing you need to modify in the code is writing your network credentials: the SSID and password on the following lines:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Replace with your SSID and Password\nconst char* ssid = \"REPLACE_WITH_YOUR_SSID\";\nconst char* password = \"REPLACE_WITH_YOUR_PASSWORD\";<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Including your unique IFTTT URL resource<\/h3>\n\n\n\n<p>Then, you need to write your unique IFTTT URL resource. Go back to &#8220;Testing your Applet&#8221; section bullet 2) to get your unique IFTTT URL resource.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Replace with your unique IFTTT URL resource\nconst char* resource = \"REPLACE_WITH_YOUR_IFTTT_URL_RESOURCE\";<\/code><\/pre>\n\n\n\n<p>In my case, my resource is:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/trigger\/bme280_readings\/with\/key\/nAZjOphL3d-ZO4N3k64-1A7gTlNSrxMJdmqy3<\/code><\/pre>\n\n\n\n<p>So, that line in the code looks as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char* resource = \"\/trigger\/bme280_readings\/with\/key\/nAZjOphL3d-ZO4N3k64-1A7gTlNSrxMJdmqy3\";<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Setting the sleep time<\/h3>\n\n\n\n<p>In this example we&#8217;ve set the sleep time to 30 minutes. This means that every 30 minutes the ESP wakes up, takes the readings, and publishes in your Google Sheets spreadsheet. The sleep time is set in the <span class=\"rnthl rntliteral\">TIME_TO_SLEEP<\/span> variable in seconds:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ sleep for 30 minutes = 1800 seconds\nuint64_t TIME_TO_SLEEP = 1800;<\/code><\/pre>\n\n\n\n<p>If you want to change the sleep time, you need to change the <span class=\"rnthl rntliteral\">TIME_TO_SLEEP<\/span> variable. Note that you should enter the sleep time in the <span class=\"rnthl rntliteral\">TIME_TO_SLEEP<\/span> variable in seconds.<\/p>\n\n\n\n<p class=\"rntbox rntcred\"><strong>Warning: <\/strong> be careful setting the sleep time. If you set a very short period, you may exceed the limit of requests imposed the IFTTT service.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sending the BME280 readings<\/h3>\n\n\n\n<p>The BME280 sensor readings are sent using the <span class=\"rnthl rntliteral\">jsonObject<\/span> variable as shown in the following line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>String jsonObject = String(\"{\\\"value1\\\":\\\"\") + bme.readTemperature() + \"\\\",\\\"value2\\\":\\\"\" + (bme.readPressure()\/100.0F) + \"\\\",\\\"value3\\\":\\\"\" + bme.readHumidity() + \"\\\"}\";<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Publish temperature in Fahrenheit<\/h3>\n\n\n\n<p>In order to publish the temperature in Fahrenheit, you need to comment and uncomment the code like this:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Temperature in Celsius\n\/*String jsonObject = String(\"{\\\"value1\\\":\\\"\") + bme.readTemperature() + \"\\\",\\\"value2\\\":\\\"\" + (bme.readPressure()\/100.0F) + \"\\\",\\\"value3\\\":\\\"\" + bme.readHumidity() + \"\\\"}\";*\/\n\n\/\/ Comment the previous line and uncomment the next line to publish temperature readings in Fahrenheit \nString jsonObject = String(\"{\\\"value1\\\":\\\"\") + (1.8 * bme.readTemperature() + 32) + \"\\\",\\\"value2\\\":\\\"\" + (bme.readPressure()\/100.0F) + \"\\\",\\\"value3\\\":\\\"\" + bme.readHumidity() + \"\\\"}\";<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Demonstration<\/h2>\n\n\n\n<p>After making all the necessary changes. Upload the code to your ESP32 or ESP8266. Make sure you select the right board and COM port.<\/p>\n\n\n\n<p>Every 30 minutes, the ESP32 or ESP8266 wakes up to take sensor readings and publishes the readings in a spreadsheet on Google Sheets.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"956\" height=\"598\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/google_sheets_readings.png?resize=956%2C598&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-57722\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/google_sheets_readings.png?w=956&amp;quality=100&amp;strip=all&amp;ssl=1 956w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/google_sheets_readings.png?resize=300%2C188&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/04\/google_sheets_readings.png?resize=768%2C480&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 956px) 100vw, 956px\" \/><\/figure><\/div>\n\n\n<p>The ESP32 chip has a built-in clock, so the readings are very accurate and it publishes to the spreadsheet every 30 minutes. On the other hand, the ESP8266 publishes new readings approximately every 28 to 29 minutes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this post we&#8217;ve shown you how to publish your sensor readings with your ESP32 or ESP8266 to a spreadsheet on Google Sheets using the IFTTT platform. As an example, we&#8217;ve published readings from the BME280 sensor. We&#8217;ve also used the ESP deep sleep capabilities to save power. This way, the ESP is awake only when we need to take readings. You should be able to take this project example and apply it to your own projects.<\/p>\n\n\n\n<p>Please note that this method has some limitations: first, it uses a third party service, and second, you need to be careful with the amount of requests you make in one day. However, this method works very well and it is easy to implement.<\/p>\n\n\n\n<p>If you like ESP32 and you want to learn more, make sure you check our course exclusively dedicated to the ESP32: <strong><a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\" target=\"_blank\" rel=\"noreferrer noopener\">Learn ESP32 with Arduino IDE<\/a><\/strong>.<\/p>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we&#8217;re going to show you how to publish sensor readings to Google Sheets using ESP32 or ESP8266 board. As an example, we&#8217;ll publish temperature, humidity, and pressure &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP32 Publish Sensor Readings to Google Sheets (ESP8266 Compatible)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-publish-sensor-readings-to-google-sheets\/#more-56442\" aria-label=\"Read more about ESP32 Publish Sensor Readings to Google Sheets (ESP8266 Compatible)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":57260,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[276,281,299,214,265,240,264],"tags":[],"class_list":["post-56442","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32","category-esp32-project","category-0-esp32","category-esp8266","category-esp8266-project","category-esp8266-projects","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/03\/esp8266_google_sheets_thumbnail.jpg?fit=1280%2C719&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/56442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=56442"}],"version-history":[{"count":3,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/56442\/revisions"}],"predecessor-version":[{"id":146286,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/56442\/revisions\/146286"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/57260"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=56442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=56442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=56442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}