Code Monkey home page Code Monkey logo

esp8266's Introduction

Hi, Welcome to my Github profile page.

esp8266's People

Contributors

electronicsguy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp8266's Issues

Need a bit more details to get this set and running

@electronicsguy Thank you for sharing this great work!

I managed to run the sample. On standard ESP8266 2.3.0 core , it works a bit fragile* (an UPDATE1 see below) and tricky in regards of connectivity from/to google.
Could you please explain in more details:

  1. What is the exact role of Fingerprint (UPDATE2: I found the details, just they can be more clear that it is optional and because of Google updating, it cannot be used as fixed string) ?

  2. What best permissions for publishing and sharing levels need to be configured on Google online Calendar , Spreadsheet and Script respectively - I needed to set everything to be exposed maximally to Internet (less security) to run the push and pull of the sample - is this necessary or only certain access is enough?

*UPDATE1: after using the newest dev. core 2.4.x of ESP8266 as per esp8266/Arduino#3330 , the example runs much more stable and smooth: at least several hours with no reboots or connections drop!

Exception 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores

I have some code that reads a Google calendar and it works great except every so often I get this & the Arduino (D1 Mini) restarts & carries on.

Exception 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
PC: 0x4020d30e
EXCVADDR: 0x00000004

Decoding stack results
0x4021a186: more_comps at crypto/bigint.c line 1072
0x4021a380: alloc at crypto/bigint.c line 1106
0x40100980: realloc at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/umm_malloc/umm_malloc.c line 1720
0x4021a699: regular_multiply at crypto/bigint.c line 822
0x4020583c: optimistic_yield(uint32_t) at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/core_esp8266_main.cpp line 111
0x4021b1d3: bi_barrett at crypto/bigint.c line 1289
0x4021b428: bi_mod_power at crypto/bigint.c line 1414
0x4021a22c: trim at crypto/bigint.c line 1197
0x4021c5b1: RSA_encrypt at crypto/rsa.c line 254
0x402172ac: send_client_key_xchg at ssl/tls1_clnt.c line 409
0x40217741: do_clnt_handshake at ssl/tls1_clnt.c line 123
0x40210519: pbuf_free_LWIP2 at core/pbuf.c line 777
0x402057fc: __yield() at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/core_esp8266_main.cpp line 96
0x402170b4: basic_read at ssl/tls1.c line 1607
0x40217490: do_client_connect at ssl/tls1_clnt.c line 168
0x401007ac: malloc at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/umm_malloc/umm_malloc.c line 1668
0x40203f58: SSLContext::_delete_shared_SSL(SSL_*) at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/WiFiClientSecure.cpp line 115
0x4021721c: ssl_read at ssl/tls1.c line 314
0x40204739: SSLContext::connect(ClientContext*, char const*, unsigned int) at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/WiFiClientSecure.cpp line 146
0x40205784: esp_yield() at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/core_esp8266_main.cpp line 87
0x4020136f: delay at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/core_esp8266_wiring.c line 51
0x40204987: WiFiClientSecure::_connectSSL(char const*) at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/WiFiClientSecure.cpp line 350
0x40204a2d: WiFiClientSecure::connect(char const*, unsigned short) at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/WiFiClientSecure.cpp line 518
0x40202a60: HTTPSRedirect::printRedir() at /var/folders/7l/nw1xs8yd2sl9sxb25k0xz8_m0000gn/T/arduino_build_917635/sketch/HTTPSRedirect.cpp line 94
0x40202b18: HTTPSRedirect::GET(String const&, char const*, bool const&) at /var/folders/7l/nw1xs8yd2sl9sxb25k0xz8_m0000gn/T/arduino_build_917635/sketch/HTTPSRedirect.cpp line 374
0x40204a2d: WiFiClientSecure::connect(char const*, unsigned short) at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/WiFiClientSecure.cpp line 518
0x40202b3a: HTTPSRedirect::GET(String const&, char const*) at /var/folders/7l/nw1xs8yd2sl9sxb25k0xz8_m0000gn/T/arduino_build_917635/sketch/HTTPSRedirect.cpp line 348
0x40202cd0: getCalendar() at /Users/stu/Documents/Arduino/bin days/bin_day/bin_day.ino line 71
0x40205784: esp_yield() at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/core_esp8266_main.cpp line 87
0x4020137a: delay at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/core_esp8266_wiring.c line 54
0x40202f3d: loop() at /Users/stu/Documents/Arduino/bin days/bin_day/bin_day.ino line 153
0x402057a5: esp_schedule() at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/core_esp8266_main.cpp line 91
0x402057d0: loop_wrapper() at /Users/stu/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/core_esp8266_main.cpp line 121

I'm quite new to Arduino's & the last C++ I did was at college, 20+ years ago, so it doesn't make much sense, but it looks like it's trying to allocate some memory when it's decrypting the payload maybe?

The full code, minus sensitive stuff, is here https://github.com/Stubbs/bin_days

esp32

I noticed that you do mention the esp32 in the readme.md. Because of several other reasons I need to step from esp8266 to esp32 and was very close to completing the "job" until I noticed that it doesn't work on my new esp32. Now I found in a closed issue you say it does not work on esp32 yet.
Is there any news on that, or, could you advice some other way to get this working on an esp32?
I have a google calendar to control my central heating system (as a thermostat) and need to read my script-output from google to get the google calendar data into my esp...

Ram usage - client connect

I have a fairly large project implemented with a nodeMCU. Now I want to log some data to a google spreadsheet using the library.

I'm having some trouble with the heap memory after calling "client->connect("script.google.com", 443)".
My device has about 17kB free at the moment of this call but apparently this is not enough and I get an memory exception and the device restarts...

With a simple sketch I'm able to use the library with no problems, but the connect call always consume about 18~19kB of free heap. Is this a known issue and how to avoid that?

Redirection Url Encoding?

Hi I am running into an issue, when i connect to google script i get redirection and the location header has the redirect url which is correct(check with postman) all fine till here, but when the redirection url is hit it gives me another redirect....
A little bit of debugging got me to a point where the redirect url was having an '&' char which has to be url encoded to '&amp' which is not happening..
So the question is is url encoding handled in the lower layers?

Details: ESP32 with fork of your lib from https://github.com/SensorsIot/Reminder-with-Google-Calender/tree/master/ReminderV2

Google replies 404

Hi,
first of all I want to say thank you - I think the code works ;)

But there is an issue - all requests are aborted by google (Error 404 (Not Found))

I found out if you take instead of script.google.com - www.script.google.com the connection works. If i take the url without the www at the beginning the connection doesn't work.

Do you have an idea what the problem could be?
Thank you for your help

error

Internet Connection Lost Handling

Hello,
taking inspiration to your GoogleDocs.ino I have written this code in order to launch a google script:

void loop() {
  static int error_count = 0;
  static int connect_count = 0;
  const unsigned int MAX_CONNECT = 20;
  static bool flag = false;
  String payload;
  String response;

  if (!flag) {
    client = new HTTPSRedirect(HTTPS_PORT);
    Serial.println("Client object created!");
    flag = true;
  }

  if (client != nullptr) {
    if (!client->connected()) {
      client->connect(HOST, HTTPS_PORT);
    }
  }
  else {
    Serial.println("Error creating client object!");
    error_count = 5;
  }

  if (connect_count > MAX_CONNECT) {
    Serial.println("Reset client object following MAX_CONNECT iteration");
    connect_count = 0;
    flag = false;
    delete client;
    return;
  }

  Serial.println("Google Script Launch");
 
    if (client->GET(URL, HOST)) {
      ++connect_count;
      payload = client->getResponseBody();
      Serial.print("HTTP Response: ");
      Serial.println(payload);
    }
    else {
      ++error_count;
      Serial.print("Error-count while connecting: ");
      Serial.println(error_count);
    }

my problem is that in case the internet connection is lost the client->GET(URL, HOST) dosn't return 0 and program is stuck.
The same happens with your GoogleDocs.ino example.
Switching on debug options of your library, when internet connection is lost, the program is stuck at this level:

Chunk Size: 0
GET Data from cell 'A1':
GET /macros/s/AKfycbzYw5G-oxvnwHpAJfDsS0PWNrO0KTBMiCW78lHUcEO6ZnFHvSw/exec?read HTTP/1.1
Host: script.google.com
User-Agent: ESP8266

The only workaround I found to handle internet connection lost is to repeat client->connect(HOST, HTTPS_PORT); at each cycle and handle the error at this level.

my background is Mechanical Engineering, no C++ programmig skills... please be patient if it is a stupid question.

Thank you

pass in spreadsheet id?

It seems to me that we could improve the google script by passing in the spreadsheet id.

Instead of putting this at the top of the script...
var SS = SpreadsheetApp.openById('1KAU0mzowlWnIuYE0_nVzv-iywkebTjM4nKtrlA-z70F');
var sheet = SS.getSheetByName('Sheet1');

Move it down to line 63 like this:
if (parsedData !== undefined){
var SS = SpreadsheetApp.openById(parsedData.spreadsheet_id);
var sheet = SS.getSheetByName(parsedData.sheet_name);

Then in the .ino file have both the GscriptId and a spreadsheet_id. Finally add the spreadsheet_id to the payload.

Seems like the benefit to this is you could have a generic googlescript file. I haven't tested this idea yet.

Core Version incompatibility

Hello, thanks for your library.
Since I try to compile the example I have several problems with a class that doesnt (error mssg: 'class EspClass' has no member named 'getFreeContStack') exist in the last core version 2.5.2 of ESP8266. So has to be downloaded to 2.5.0. Just to publish it in the documentation and save time for the rest of the users.
With ESP32 I have not get to compile yet and I tried with all available core releases.
Regards

Date and Time in Spreadsheet

Hi, Could you please add Date and Time into the gscript whenever a new row of data is appemded? I know it is possible to get time on the esp8266 over NTP request and send it to google sheets but for low energy applications it is better to not make this request every time the esp8266 wakes up.

Connection to re-directed URL failed ..

Hello ! .. I have a question .. I am trying to use the new version of this library and it is giving me the following error "Connection to re-directed URL failed!" ..

I had already used another previous version a while ago and had no problems ..

But today trying to use it again with the new version gives me that error ..

This is all implemented and I log the data to the spreadsheet, but can not see the contents of cell A1 and neither the calendar information .. "Error! Not connected to host."

I am using PlatformIO .. and the library of expressif8266 stage version ..

I also tried Arduino IDE and the library of esp8266 2.5.0 beta 3 and I do not care ...

Some help ? Any more information that may happen to you?

From already thank you very much !

Arduino Nano Communication with ESP8266-1

I am using arduino nano board with ESP8266-1 wifi module .. and i am getting error "fatal error: ESP8266WiFi.h: No such file or directory" .
This project is running with node MUC ESP8266 module but i want to run this project with nano with ESP8266-1 module as shown in your video .. my aim is to read arduino nano three ADC value and upload over google sheet .

i have problem with WiFiClientSecure :(

hi
i am thanks for your help to peaple for publishin your good project
in this code i want give data from google Sheet and send data in telegram bot,
i use this project to give data from google sheet:
https://github.com/lorol/Googlesheet_DHT_simple
and use this project for recive and send data from telegram robat:
https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot
i use esp8266
i merge two above project but i cant compile because i give error , because two project use WiFiClientSecure.h library , and same client :(

i changed the client name , and code ha been compiled, but in serial monitor , program crashed
i changed "HTTPSRedirect* client= nullptr;" to "HTTPSRedirect* test= nullptr;" and change every client in the code to test,
i also change below code, in the next change

WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);

to :

WiFiClientSecure test;
UniversalTelegramBot bot(BOTtoken, test);

and you can see my Serial monitor in both time:

Starting ...
Connecting to hooshmandsazan3
.

WiFi connected

Exception (29):
epc1=0x4000e1cc epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000204 depc=0x00000000

ctx: cont 
sp: 3fff0fd0 end: 3fff18e0 offset: 01a0

>>>stack>>>
3fff1170:  00410000 3fffb59c 3fffb75c 40224e3f  
3fff1180:  3fffb63c 3fffb87c 00000081 40225aa1  

i add Serial.println() in the code for debugging
this is my code:

#include <ESP8266WiFi.h>
#include <ArduinoJson.h>
#include "HTTPSRedirect.h"




//======================From Telegram===============================
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>

#define BOTtoken "339475786:AAH7IjXu51xPom_sMx8IRnvQbcTD5FfO2Wc"  // your Bot Token (Get from Botfather)
WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);

int Bot_mtbs = 1000; //mean time between scan messages
long Bot_lasttime;   //last time messages' scan has been done
bool Start = false;

const int ledPin = 2;
int ledStatus = 0;

void handleNewMessages(int numNewMessages) {
  //Serial.println(F("handleNewMessages"));
  //Serial.println(String(numNewMessages));

  for (int i=0; i<numNewMessages; i++) {
    String chat_id = String(bot.messages[i].chat_id);
    String text = bot.messages[i].text;

    String from_name = bot.messages[i].from_name;
    if (from_name == "") from_name = "Guest";

    if (text == "/ledon") {
      digitalWrite(ledPin, HIGH);   // turn the LED on (HIGH is the voltage level)
      ledStatus = 1;
      bot.sendMessage(chat_id, "Led is ON", "");
    }

    if (text == "/ledoff") {
      ledStatus = 0;
      digitalWrite(ledPin, LOW);    // turn the LED off (LOW is the voltage level)
      bot.sendMessage(chat_id, "Led is OFF", "");
    }

    if (text == "/status") {
      if(ledStatus){
        bot.sendMessage(chat_id, "Led is ON", "");
      } else {
        bot.sendMessage(chat_id, "Led is OFF", "");
      }
    }

    if (text == "/start") {
      String welcome = "Welcome to Universal Arduino Telegram Bot library, " + from_name + ".\n";
      welcome += "This is Flash Led Bot example.\n\n";
      welcome += "/ledon : to switch the Led ON\n";
      welcome += "/ledoff : to switch the Led OFF\n";
      welcome += "/status : Returns current status of LED\n";
      bot.sendMessage(chat_id, welcome, "Markdown");
    }
  }
}
//***************************************************************************




#define WRITE_INTERVAL_MINITES 1

#define MAX_CONNECT 200 //reuse 2 times same clent
#define MAX_ERROR 100 //restart everything

const char *ssid =  "sajjad";
const char *pass =  "1q2w3e4r5t6y";

const char* host = "script.google.com";
const int httpsPort = 443;

int seconds = (WRITE_INTERVAL_MINITES * 60) - 20; // schedule first sending to TS in 20 sec after start

char *GScriptId = "AKfycbxRzkMt87iyiyU9EDY6REoRDpl5C9oHdjVyCSF6A4QN7jkNMGHD";   // Put your  GScriptId   here

// Access to Google Spreadsheet
String url = String("/macros/s/") + GScriptId + "/exec?";


HTTPSRedirect* test = nullptr;


float hum;
float tem;

void setup() {
  Serial.begin(115200);
  Serial.println();
  delay(200);
  Serial.println(F("Starting ..."));

  delay(200);
 
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.mode(WIFI_STA);
  if (WiFi.status() != WL_CONNECTED) WiFi.begin(ssid, pass);
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(500); 
    Serial.println(F("."));
  }
  Serial.println("");
  Serial.println("WiFi connected");
  pinMode(ledPin, OUTPUT); // initialize digital ledPin as an output.
  delay(10);
  digitalWrite(ledPin, LOW); // initialize pin as off
}

void loop() {
  Serial.println("1");
  
  //==============================From telegram=========================================
  if (millis() > Bot_lasttime + Bot_mtbs)  {
    Serial.println("2");
    int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
    
    while(numNewMessages) {
      Serial.println("3");
      Serial.println("got response");
      handleNewMessages(numNewMessages);
      numNewMessages = bot.getUpdates(bot.last_message_received + 1);
    }
    Serial.println("4");
    Bot_lasttime = millis();
  }
  //***********************************************************************
  Serial.println("5");
  static int error_count = 0;
  static int connect_count = 0;
  static bool flag = false;

  if (!flag){
    Serial.println("6");
    test = new HTTPSRedirect(httpsPort);
    flag = true;
    test->setPrintResponseBody(true); // or false and use String getResponseBody();
    Serial.println("6a");
    test->setContentTypeHeader("application/json");  
    Serial.println("6b");
    if (!test->connected()) test->connect(host, httpsPort);
    Serial.println("6c");
    ++connect_count;
    Serial.println("6d");
  }

   // 30 sec after writing 
  

    if (test != nullptr){
      Serial.println("7");
      if (!test->connected()){
        test->connect(host, httpsPort);
      }
    }
    else{
      Serial.println(F("Error2 creating client object!"));
      error_count = -10;
      Serial.println("7a");
    }
    Serial.println("7b");
    Serial.println(F("========================="));
    if (test->GET(url + String("readrow=last"), host)){
      Serial.println("8");
      DynamicJsonBuffer jsonBuffer;
      JsonObject& json = jsonBuffer.parseObject(test->getResponseBody());
      //json.printTo(Serial);
      String Timestamp = json["values"][0];
      int MaxT0        = json["values"][1];
      int minT0        = json["values"][2];
      String Con0      = json["values"][3];
      int Hu0          = json["values"][4];
      String WS0       = json["values"][5];
      String WD0       = json["values"][6];

      int MaxT1        = json["values"][7];
      int minT1        = json["values"][8];
      String Con1      = json["values"][9];
      int Hu1          = json["values"][10];
      String WS1       = json["values"][11];
      String WD1       = json["values"][12];

      int MaxT2        = json["values"][13];
      int minT2        = json["values"][14];
      String Con2      = json["values"][15];
      int Hu2          = json["values"][16];
      String WS2       = json["values"][17];
      String WD2       = json["values"][18];

      int MaxT3        = json["values"][19];
      int minT3        = json["values"][20];
      String Con3      = json["values"][21];
      int Hu3          = json["values"][22];
      String WS3       = json["values"][23];
      String WD3       = json["values"][24];
      
      float TEMP       = json["values"][25];
      float Hu         = json["values"][26];
      
      Serial.println(Timestamp);
      Serial.println(MaxT0);
      Serial.println(minT0);
      Serial.println(Con0);
      Serial.println(Hu0);
      Serial.println(WS0);
      Serial.println(WD0);

      Serial.println("");
      Serial.println(MaxT1);
      Serial.println(minT1);
      Serial.println(Con1);
      Serial.println(Hu1);
      Serial.println(WS1);
      Serial.println(WD1);

      Serial.println("");
      Serial.println(MaxT2);
      Serial.println(minT2);
      Serial.println(Con2);
      Serial.println(Hu2);
      Serial.println(WS2);
      Serial.println(WD2);

      Serial.println("");
      Serial.println(MaxT3);
      Serial.println(minT3);
      Serial.println(Con3);
      Serial.println(Hu3);
      Serial.println(WS3);
      Serial.println(WD3);

      Serial.println("");
      Serial.println(TEMP);
      Serial.println(Hu);      
      ++connect_count;
    } else {
      Serial.println("9");
      ++error_count;
      Serial.println(F("GET Last row val failed!"));
      seconds = 10; // stage again in 10 sec
    }


   if (error_count > MAX_ERROR){
    Serial.println("10");
     Serial.println(F("Errors > MAX_ERROR...")); 
     //delete client;
     //client = nullptr;
     //connect_count = -1;
     //error_count = 0;
     //flag = false;
     ESP.restart(); 
   }

   if (connect_count > MAX_CONNECT){
      Serial.println("11");
      Serial.println(F("Connects > MAX_CONNECT... rebuild"));
      connect_count = -1;
      flag = false;
      delete test;
     
      //return;  //where?
   }
   
   seconds++;
   delay(1000); //1 sec loop
}

when the code arive to "6b" program go to hang,
when arive to :
if (!test->connected()) test->connect(host, httpsPort);
this is my output:

Starting ...
Connecting to sajjad
.
.
.
.
.
.
.
.

WiFi connected
1
2
4
5
6
6a
6b

Exception (29):
epc1=0x4000dfd9 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont 
sp: 3fff1000 end: 3fff1850 offset: 01a0

>>>stack>>>
3fff11a0:  3fff073c 000011c9 000011c9 4022ab8c  
3fff11b0:  3fff1584 00000012 00000003 00000000  

Hardware

Hardware: NodeMcu Lua WIFI Board Based on ESP8266 CP2102 Module (ESP-12E)

Description

Problem description

Settings in IDE

Module: Adafruit HUZZAH esp8266
Flash Size: 4MB(3MB SPIFFS)
CPU Frequency: 80Mhz
Upload Using: SERIAL 115200

please help me please :(

How to save A1 in variable???

hi,
i want to save A1 that read from sheet in the variable
EX:
String S1=A1(that read from sheet...)

Serial.println(F("GET Data from cell 'A1':"));
if (client->GET(url3, host)){
++connect_count;
}

Error code 302 with arduino espressif8266 staging version

Hi!
I use esp8266-12E board with platformio 3.5.1
All work fine. Config file for my project is like this:

[env:esp12e]
platform = espressif8266
board = esp12e
framework = arduino
board_f_cpu = 80000000L
build_flags = -Wl,-Teagle.flash.4m1m.ld
upload_speed = 230400

I want switch to staging version of arduino esp8266 so i change line for platform to this:

platform = https://github.com/platformio/platform-espressif8266.git#feature/stage

Everything compile fine, no error, esp boot normally but i got code error 302 (Moved Temporarily).
Something is even more strange. In my code i make two request for google script. First request work ok, but second give me error.
I have no idea what can be.

This is the important part of the code

if(client->GET(url_checkstatus, host)){
		String res = client->getResponseBody();
		StaticJsonBuffer<200> jsonBuffer;
  		JsonObject& root = jsonBuffer.parseObject(res);
  		if (root.success()) {
  			execute_something();
  			if(o){
  				delay(1000);
  				if(client->GET(url_checkprogram, host)){
  					res = client->getResponseBody();
  					StaticJsonBuffer<200> jsonBuffer;
  					JsonObject& root = jsonBuffer.parseObject(res);
  					if (root.success()) {
  				               execute_something();
  					}else{
  						#ifdef DEBUG
  						Serial.println("Json error in function: getProgram");
  						#endif
  					}
  				}else{
  					#ifdef DEBUG
  					Serial.println("Error make request for: getProgram" + +client->getReasonPhrase(););
  					#endif
  				}
  			}
  		}else{
  			#ifdef DEBUG
  			Serial.println("Json error in function: getStatus");
  			#endif
  		}		
}else{
		#ifdef DEBUG
		Serial.println("Error make request for: getStatus");
		#endif
}

Compilation error from ANir's water sensor project

Hello, Sujay! I am trying to get code from ANir's water sensor project to compile but am getting an error:

exit status 1
no matching function for call to 'HTTPSRedirect::printRedir(String&, const char*&, const char*&)'

I see in the HTTPSRedirect.h library the following printRedir() function:
bool printRedir(void);

...the code, however, calls for (String, char, char) arguments.

Am I doing something wrong here, or has there been an update to the library that needs a corresponding update to ANir's code?

...to post a bunch of variable at a time

Hello!

First I would like to thank you for this project and all of your efforts for it, that's really really great. Thank You!
And then:
I would like to post for example 10x6 or more variables at a time, Because when i measure with the ESP it's not in range to get connected to the internet. However i store the measurements on an SD card and when i get home and get connected to the internet i would like to upload the last measures to the spradsheet.
(Each measure takes 5 variable and a timestamp for the record of measure. So it will need 6 variable per measures but fist i tried only just five...)
I started to read about the codes, libraries and the doGet method, and modify the codes.
Frist i made it to send 5 string variables and then the google script not updated the sheet. After run a debug on the google scripteditor, it said something is wrong with the date variable (on the google script side). I modified it and everything works properly.
"I changed:
var dateTime = new Date();
to:
var dateTime = Utilities.formatDate(new Date(), โ€œGMT+2โ€, โ€œyyyy-MM-ddโ€™ โ€˜HH:mm Eโ€);
(I use GMT+2 because Iโ€™m in Europe,may You need change it based on Your location.)"

Okay, so there is 5 different variable and it works.
For the bunch of variables i obscured about to solve it.
With my basic common sense I write 25 variable into the sending url and accordingly the variables in googlescript, and it looks really ugly.
And also the ESP8266 freezed 4 times of 5 posts.
So this 25 variable in one url is not a good way to start...

I would like to get some help how to send a bunch of measures to my spreadsheet.
I think if i send one after one the measurements will costs much time and the fear of some error each time during upload to the spreadsheet.

Thanks a lot
Philip

Here is the modified code for 5 variables:
The code in googlescript:
https://pastebin.com/fmVaxCnL
Code snippet for ESP8266 in Arduino
https://pastebin.com/00kAuZ6K

And here is for 25 variables:
Code snippet for ESP8266 in Arduino
https://pastebin.com/4Uvv7kYi
The code in googlescript:
https://pastebin.com/pr6062Vy

How to get new fingerprint?

Hello Sujay,

I am trying to use your library to post data to google spreedsheet. But I am getting the following error.

Connecting to script.google.com
Connection Status: 1
Certificate mis-match

Please, let us know how to get a new matching fingerprint.

Regards,
Awais

ESP8266 Stops Working if I don't provide Wifi during specifc step

To test the WiFi connection I'm sharing the WiFi of my cellphone.

If I stop the WiFi sharing during the command below, the ESP8266 stops working. It only works if I do a hardware reset.

If I don't stop the WiFi it works normally.

if(client->POST(urlCal, host, payload))
{ RetornoPost = client->getResponseBody(); }

  • HTTPS Redirect (Version 2.0)
  • ESP8266 library version 2.4.2

Does anyone know why ESP8266 stops working?

Exception 29, probable memory problem when doing a basic example

Hi guys,
I'm facing problem using this nice library...
My test is terribly simple, just making a get to google script API. I can make only one call and the second crashes. I tracked the heap space and it seems not correctly released prior to the second call...
Any idea ?
Could it be linked to the Wificlient secure underlying library ?
Tks
denis

Heap at start 42080
Connecting to script.google.com
Heap 25760
{"result":"success","events":[{"title":"Anniv David","start":1532469600000,"end":1532556000000},{"title":"Anniv Didier","start":1533938400000,"end":1534024800000},{"title":"Anniv Estele","start":1533938400000,"end":1534024800000},{"title":"Anniv Valerie","start":1534370400000,"end":1534456800000}]}
Connecting to script.google.com
Heap 8064
{"result":"success","events":[{"title":"Anniv David","start":1532469600000,"end":1532556000000},{"title":"Anniv Didier","start":1533938400000,"end":1534024800000},{"title":"Anniv Estele","start":1533938400000,"end":1534024800000},{"title":"Anniv Valerie","start":1534370400000,"end":1534456800000}]}
Connecting to script.google.com

Exception (29):
epc1=0x4021617b epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000006 depc=0x00000000

getLastRow issue

Hello,

Well thanks for all job of the community and special for electronicsguy

I follow all the steps of the README, add a calendar in the drive.

I have a message when the ESP8266 execute this code:

client->POST(url2, host, payload)

in

Serial.println("POST append memory data to spreadsheet:");
payload = payload_base + """ + ESP.getFreeHeap() + "," + ESP.getFreeContStack() + ""}";
if(client->POST(url2, host, payload)){
;
}
else{
++error_count;
DPRINT("Error-count while connecting: ");
DPRINTLN(error_count);
}

Message in the serial:

<!DOCTYPE html><html><head><link rel="shortcut icon" href="//ssl.gstatic.com/docs/script/images/favicon.ico"><title>Error</title><style type="text/css">body {background-color: #fff; margin: 0; padding: 0;}.errorMessage {font-family: Arial,sans-serif; font-size: 12pt; font-weight: bold; line-height: 150%; padding-top: 25px;}</style></head><body style="margin:20px"><div><img alt="Google Apps Script" src="//ssl.gstatic.com/docs/script/images/logo.png"></div><div style="text-align:center;font-family:monospace;margin:50px auto 0;max-width:600px">TypeError: No se puede llamar al mรฉtodo &quot;getLastRow&quot; de null. (lรญnea 74, archivo &quot;Cรณdigo&quot;, proyecto &quot;copy&quot;)</div></body></html>

(have google account and arduino IDE in spanish)

Tell that can't call method in line 74 of .gs
A problem with getLastRow:

function doPost(e) {

var parsedData;
var result = {};

try {
parsedData = JSON.parse(e.postData.contents);
}
catch(f){
return ContentService.createTextOutput("Error in parsing request body: " + f.message);
}

if (parsedData !== undefined){
// Common items first
// data format: 0 = display value(literal), 1 = object value
var flag = parsedData.format;

if (flag === undefined){
  flag = 0;
}

switch (parsedData.command) {
  case "appendRow":
     var tmp = SS.getSheetByName(parsedData.sheet_name);
     var nextFreeRow = tmp.getLastRow() + 1;        <------------------------ LINE 74
     var dataArr = parsedData.values.split(",");
     
     tmp.appendRow(dataArr);
     
     str = "Success";
     SpreadsheetApp.flush();
     break;     
   
   
}

return ContentService.createTextOutput(str);

} // endif (parsedData !== undefined)

else{
return ContentService.createTextOutput("Error! Request body empty or in incorrect format.");
}

}

Finally, the doPost function....

I really don't know what s happen here. The sheet looks like this.
sin titulo

Something is wrong and don't know.
what do you think?

ESP32 Not working

Awesome code. Was able to get everything up and running on ESP8266, but have had zero luck with ESP32. Has anyone had success that would be willing to post their sketch? I replaced the include ESP8266WiFi.h with WiFi.h, the compile first complains at there being no client->verify...if I comment that code out, my void loop() basically seems to hang....thought or ideas?

Multiple cell reading

I've been combing the google docs, but can't seem to get the correct code to be able to read multiple cells with the nodeMCU. For example, I'd like to read cells A10, C10 and D15.

client.printRedir

Hello,

Wonderful library to post data to Google Sheets, but following method to put data is more clear to me how it works:
http://embedded-lab.com/blog/post-data-google-sheets-using-esp8266/

I don't understand the following call in the above program:
client.printRedir(urlFinal, host, googleRedirHost);

Your printRedir is a void, how are these arguments are passed and processed? It does not work.
I searched in the history if you might changed this, but I can't find the right answer.

Sorry I ask you, but have not found the answer somewhere else how this works and what this function does.
I was thinking it is splitted now and printRedir is just for putting debug output,
To put the data has to be done with another function?

Thanks is advance

Connection to re-directed URL failed! - _redirHost: script.googleusercontent.com

Hi:

Thanks for the excellent work on the HTTPS with redirect library. I am unable to get a simple example to work when redirecting to script.googleusercontent.com. Am suspecting the something has changed on the Google side but I am not getting enough debug information to understand what the problem is. I am hoping you have seen this before and can help.

My output is:


Free heap: 38120

Connecting to wifi: Raker
......
WiFi connected
IP address: 
192.168.86.76
Connecting to script.google.com

GET: To host: script.google.com with url: /macros/s/AKfycbz8KJ-a4OYMjXhZXsxQOmfazq3aYqK7zRq0nmCvMVWNKQiGoig/exec
=========================
GET /macros/s/AKfycbz8KJ-a4OYMjXhZXsxQOmfazq3aYqK7zRq0nmCvMVWNKQiGoig/exec HTTP/1.1
Host: script.google.com
User-Agent: ESP8266



Status code: 302
Reason phrase: Moved Temporarily
_redirHost: script.googleusercontent.com
_redirUrl: /macros/echo?user_content_key=A2K8SyhRJVt-u0QMZUFihMMrY_qlk76bjDjAPsjBTou1y7sPT4ZXVE3pFQFRDNIfmjrgtX8My9ZSY10nvBZBKFkf2D-CVQetm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnOVljp8mS3kEa2FoOegHt6kv1mgV-1PxrV4_cEt9oXVAHc0gNdal2pujvWSqncGR8dveWPraiRQB&lib=Mm1_qotei4b8Ku2zl9ZtU8xxIoJWoTElh

Connection to re-directed URL failed!

GET: Fetch Google Calendar Data:
================================


If I take the redirect host and url and combine them to get:

https://script.googleusercontent.com/macros/echo?user_content_key=WoLbL9_qluslH-nlwIBY_9r_RvlbUBI3HB6_57KRYTYKN0R9A7ai52cSR5Bvp7-N1XVc3n7I7WPL5ICon8jmH4KLBeTS6s6Em5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnOVljp8mS3kEa2FoOegHt6kv1mgV-1PxrV4_cEt9oXVAHc0gNdal2pujvWSqncGR8Z-hMl8NVc9aIA_rwgebdRAVRVku1w4JtQ&lib=Mm1_qotei4b8Ku2zl9ZtU8xxIoJWoTElh

and then paste that into a browser window it works and I get back the expected results. Therefore I don't think the problem is with the generated url or with my google app script. According to your documentation is seems like something may have changed in Dec 2018. Could this be related to that?

The test script is a simplified version of your script. Here is the script.

/*  HTTPS on ESP8266 with follow redirects, chunked encoding support
 *  Version 3.0
 *  Author: Sujay Phadke
 *  Github: @electronicsguy
 *  Copyright (C) 2018 Sujay Phadke <[email protected]>
 *  All rights reserved.
 *
 *  Example Arduino program
 */

#include <ESP8266WiFi.h>
#include "HTTPSRedirect.h"
#include "DebugMacros.h"

// Fill ssid and password with your network credentials
const char* ssid = "xxxxx";
const char* password = "xxxxx";

const char* host = "script.google.com";
// Replace with your own script id to make server side changes
const char *GScriptId = "AKfycbz8KJ-a4OYMjXhZXsxQOmfazq3aYqK7zRq0nmCvMVWNKQiGoig";

const int httpsPort = 443;

// echo | openssl s_client -connect script.google.com:443 |& openssl x509 -fingerprint -noout
const char* fingerprint = "";
//const uint8_t fingerprint[20] = {};

// Read from Google Calendar
String url = String("/macros/s/") + GScriptId + "/exec";

HTTPSRedirect* client = nullptr;
// used to store the values of free stack and heap
// before the HTTPSRedirect object is instantiated
// so that they can be written to Google sheets
// upon instantiation
unsigned int free_heap_before = 0;

void setup() {
  Serial.begin(115200);
  Serial.flush();
  
  free_heap_before = ESP.getFreeHeap();
  Serial.printf("Free heap: %u\n", free_heap_before);
  
  Serial.println();
  Serial.print("Connecting to wifi: ");
  Serial.println(ssid);
  // flush() is needed to print the above (connecting...) message reliably, 
  // in case the wireless connection doesn't go through
  Serial.flush();

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  // Use HTTPSRedirect class to create a new TLS connection
  client = new HTTPSRedirect(httpsPort);
//  client->setInsecure();
  client->setPrintResponseBody(true);
  client->setContentTypeHeader("application/json");
  
  Serial.print("Connecting to ");
  Serial.println(host);

  // Try to connect for a maximum of 5 times
  bool flag = false;
  for (int i=0; i<5; i++){
    int retval = client->connect(host, httpsPort);
    if (retval == 1) {
       flag = true;
       break;
    }
    else
      Serial.println("Connection failed. Retrying...");
  }

  if (!flag){
    Serial.print("Could not connect to server: ");
    Serial.println(host);
    Serial.println("Exiting...");
    return;
  }

/*  
  if (client->setFingerprint(fingerprint)) {
    Serial.println("Certificate match.");
  } else {
    Serial.println("Certificate mis-match");
  }
*/ 

  Serial.printf("\nGET: To host: %s with url: ", host);
  Serial.println(url);
  Serial.println("=========================");

  // fetch calendar data
  client->GET(url, host);

  Serial.println("\nGET: Fetch Google Calendar Data:");
  Serial.println("================================");

  int statusCode = client->getStatusCode();
  String statusPhrase = client->getReasonPhrase();
  Serial.printf("\nGET: Status code: %s with phrase: ", statusCode);
  Serial.println(statusPhrase);
  Serial.println("=========================");

  String response = client->getResponseBody();
  Serial.printf("\nGET: Response is: ");
  Serial.println(response);
  Serial.println("=========================");
  
 
  Serial.printf("Free heap: %u\n", ESP.getFreeHeap());

  // delete HTTPSRedirect object
  delete client;
  client = nullptr;
}

void loop() {
  delay(5000);
  Serial.println("In loop waiting");
}


BTW - the google app script returns the titles of currently due calendar events. If there are no active calendar events then nothing will be returned. Therefore If you get this to work but don't get any response data that could be OK.

Thanks for your help. Please let me know if you need anymore information.

Bob

ESP32 Compatibility

Is the ESP32 compatible yet, because the README states:

A library for seamless data logging, communication and control for Internet of Things (focus: ESP8266, ESP32)

I've tried using the library with my ESP32, but it just freezes up when connecting.

Need Simple arduino code to post data

I am not a programmer and your example has too much code that is not easily understood by beginners like me.

I have spent a few days trying to get it to work, but all get posted to my sheet is 'undefined' 'undefined'

I would like to request that you post a simple ino file for arduino/esp etc. for just posting some data to a sheet.

by not including reading A1 or the calendar, the bits necessary to use your library will be more obvious to the beginner.

void GetData(){
// put your data gathering here. remember to use global variables
// this random is to generate numbers to fill the cells. add your sensor and remove these lines
data1 =random(99) ; // generate a random number no higher than 98
data2 = random(200)*.7 ; // generates a floating point value with decimal places
data3 = random(1000); // just a 3rd value to give something to post

openssl command

this is super minor...
I don't know if this is specific to a mac's command line, but when I run this:

echo | openssl s_client -connect script.google.com:443 | openssl x509 -fingerprint -noout

I get an error:
-bash: syntax error near unexpected token `&'

removing the & fixes it.
echo | openssl s_client -connect script.google.com:443 | openssl x509 -fingerprint -noout

spreadsheet id

Very interesting code. I do have a question though.
You say in Code.gs: // doPost needs the spreadsheet ID, it has no concept of "active spreadsheet".
Does that mean one needs to keep changing the val of 'ss' in the Code.gs script for every other document one wants to use?

Cannot make a simple example work. Please help.

Hi,

I have made the simple example I could make

#include <ESP8266WiFi.h>
#include "HTTPSRedirect.h"
#include "DebugMacros.h"


// Fill ssid and password with your network credentials
const char* ssid = "xxxxx";
const char* password = "xxxxx";

const char* host = "script.google.com";

const char *GScriptId = "AKfycbykOQiFIrtU73UJF1A3ZGvjpXPsqS6k7j6O74OeESVObV7jIJg";
const int httpsPort = 443;

// echo | openssl s_client -connect script.google.com:443 |& openssl x509 -fingerprint -noout
const char* fingerprint = "B4:80:F7:C2:CF:C8:50:E2:5B:9B:E9:F0:E2:02:DD:C8:BD:C2:89:9A";

// Write to Google Spreadsheet
String url = String("/macros/s/") + GScriptId + "/exec?pressure=1021.79";

HTTPSRedirect* client = nullptr;


void setup() {
  Serial.begin(115200);
  Serial.flush();
  
  Serial.println();
  Serial.print("Connecting to wifi: ");
  Serial.println(ssid);
  // flush() is needed to print the above (connecting...) message reliably, 
  // in case the wireless connection doesn't go through
  Serial.flush();

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  // Use HTTPSRedirect class to create a new TLS connection
  client = new HTTPSRedirect(httpsPort);
  client->setPrintResponseBody(true);
  client->setContentTypeHeader("application/json");
  
  Serial.print("Connecting to ");
  Serial.println(host);

  // Try to connect for a maximum of 5 times
  bool flag = false;
  for (int i=0; i<5; i++){
    int retval = client->connect(host, httpsPort);
    if (retval == 1) {
       flag = true;
       break;
    }
    else
      Serial.println("Connection failed. Retrying...");
  }

  if (!flag){
    Serial.print("Could not connect to server: ");
    Serial.println(host);
    Serial.println("Exiting...");
    return;
  }
  
  if (client->verify(fingerprint, host)) {
    Serial.println("Certificate match.");
  } else {
    Serial.println("Certificate mis-match");
  }

  Serial.print("url : ");
  Serial.println(url);
  Serial.println("\nGET: Write into cell 'A1'");
  Serial.println("=========================");

  // fetch spreadsheet data
  client->GET(url, host);

  Serial.println("=========END===========");
}

void loop(){}

But it does not work ( although the https request on the browser is fine).
Here is the output with the debug on .

.......
WiFi connected
IP address: 
192.168.1.169
Connecting to script.google.com
Certificate match.
url : /macros/s/AKfycbykOQiFIrtU73UJF1A3ZGvjpXPsqS6k7j6O74OeESVObV7jIJg/exec?pressure=1021.79

GET: Write into cell 'A1'
=========================
GET /macros/s/AKfycbykOQiFIrtU73UJF1A3ZGvjpXPsqS6k7j6O74OeESVObV7jIJg/exec?pressure=1021.79 HTTP/1.1
Host: script.google.com
User-Agent: ESP8266



Status code: 302
Reason phrase: Moved Temporarily
_redirHost: accounts.google.com
_redirUrl: /ServiceLogin?service=wise&passive=1209600&continue=https://script.google.com/macros/s/AKfycbykOQiFIrtU73UJF1A3ZGvjpXPsqS6k7j6O74OeESVObV7jIJg/exec?pressure%3D1021.79&followup=https://script.google.com/macros/s/AKfycbykOQiFIrtU73UJF1A3ZGvjpXPsqS6k7j6O74OeESVObV7jIJg/exec?pressure%3D1021.79
GET /ServiceLogin?service=wise&passive=1209600&continue=https://script.google.com/macros/s/AKfycbykOQiFIrtU73UJF1A3ZGvjpXPsqS6k7j6O74OeESVObV7jIJg/exec?pressure%3D1021.79&followup=https://script.google.com/macros/s/AKfycbykOQiFIrtU73UJF1A3ZGvjpXPsqS6k7j6O74OeESVObV7jIJg/exec?pressure%3D102 HTTP/1.1
Host: accounts.google.com
User-Agent: ESP8266



Status code: 200
Reason phrase: OK
Content-Type: text/html; charset=UTF-8
X-Frame-Options: DENY
Link: <https://www.google.com/intl/en/drive/>; rel="canonical"
x-auto-login: realm=com.google&args=service%3Dwise%26continue%3Dhttps%253A%252F%252Fscript.google.com%252Fmacros%252Fs%252FAKfycbykOQiFIrtU73UJF1A3ZGvjpXPsqS6k7j6O74OeESVObV7jIJg%252Fexec%253Fpressure%253D1021.79
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Date: Sat, 31 Mar 2018 16:22:06 GMT
Transfer-Encoding: chunked
Strict-Transport-Security: max-age=31536000; includeSubDomains
Content-Security-Policy: script-src 'report-sample' 'nonce-Uy4VJd/ANGabRt569cMJ7eBKSNU' 'unsafe-inline' 'strict-dynamic' https: http: 'unsafe-eval';object-src 'none';base-uri 'self';report-uri /cspreport
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Server: GSE
Set-Cookie: GAPS=1:OaMch1F_KGCyPaMsvQUMWvG1TdVaCQ:JCn2fEx-dHDK54QL;Path=/;Expires=Mon, 30-Mar-2020 16:22:06 GMT;Secure;HttpOnly;Priority=HIGH
Alt-Svc: hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35"

Chunk Size: 28678

<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8">
... 

then tons of HTML

Please help .

Compiler errors in Arduino IDE

I'm sorry to bug you with this but I've tried everything I can think of and I'm hoping you can identify this issue. I'm following your example code to update a sheet on Google sheets. I've eliminated all the syntax and other errors but the IDE now spews a number of indecipherable errors which don't point to specific lines of code. Any help would be greatly appreciated. Here's what the IDE says when I try to compile.

`Arduino: 1.8.5 (Mac OS X), Board: "WeMos D1 R2 & mini, 80 MHz, 921600, 4M (3M SPIFFS)"

Archiving built core (caching) in: /var/folders/8_/rhmmnn_11rd96djn56cfzfvc0000gp/T/arduino_cache_313632/core/core_esp8266_esp8266_d1_mini_CpuFrequency_80,UploadSpeed_921600,FlashSize_4M3M_f150fc25ecfbf09e988720431431691c.a
sketch/ESP-temperature-logger.ino.cpp.o:(.text.setup+0x38): undefined reference to HTTPSRedirect::setPrintResponseBody(bool)' sketch/ESP-temperature-logger.ino.cpp.o:(.text.setup+0x3c): undefined reference to HTTPSRedirect::setContentTypeHeader(char const*)'
sketch/ESP-temperature-logger.ino.cpp.o:(.text.setup+0x40): undefined reference to HTTPSRedirect::POST(String const&, char const*, String const&, bool const&)' sketch/ESP-temperature-logger.ino.cpp.o: In function setup':
/Users/atatistcheff/Documents/Arduino/ESP-temperature-logger/ESP-temperature-logger.ino:92: undefined reference to HTTPSRedirect::setPrintResponseBody(bool)' sketch/ESP-temperature-logger.ino.cpp.o: In function HardwareSerial::begin(unsigned long)':
/Users/atatistcheff/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/cores/esp8266/HardwareSerial.h:75: undefined reference to HTTPSRedirect::setContentTypeHeader(char const*)' sketch/ESP-temperature-logger.ino.cpp.o: In function setup':
/Users/atatistcheff/Documents/Arduino/ESP-temperature-logger/ESP-temperature-logger.ino:112: undefined reference to HTTPSRedirect::POST(String const&, char const*, String const&, bool const&)' /Users/atatistcheff/Documents/Arduino/ESP-temperature-logger/ESP-temperature-logger.ino:130: undefined reference to HTTPSRedirect::setPrintResponseBody(bool)'
/Users/atatistcheff/Documents/Arduino/ESP-temperature-logger/ESP-temperature-logger.ino:131: undefined reference to HTTPSRedirect::setContentTypeHeader(char const*)' sketch/ESP-temperature-logger.ino.cpp.o: In function postData(String, float)':
/Users/atatistcheff/Documents/Arduino/ESP-temperature-logger/ESP-temperature-logger.ino:172: undefined reference to `HTTPSRedirect::POST(String const&, char const*, String const&, bool const&)'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board WeMos D1 R2 & mini.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
`

401 error trying to connect to sheets

I downloaded and compiled the redirection Library, and a working version of Sujays Spreadsheet, Downloaded and ran an exe version of openssl and obtained security fingerprint from google I'm running on windows7. Created a Google Calander named Test Rest API. When I compile and run the unmodifiable sheet the program works flawlessly .
When I create a modifiable copy of the spreadsheet, publish the Googlescript as a Web app, transfer the script key to the source file, compiled and run, I get a 401 error whenever doing a client host.
subsequent debugging of the script I get a TypeError on the doGet function. The other 4 functions work fine and no erros and yest the sheets was cleared ( not before I made a copy of a copy)
I have tried opening my own spreadsheet and using Sujay's script but same issues.
So I'm thinking there might be an issue with the script.
image

Any input would be appreciated.

printRedir

Hello,

I would like to praise this work, but have not yet been able to make it work.

I am confused with HTTPSRedirect::printRedir, which gives me error in compilation with the latest version.
Looking to the code, I see

bool HTTPSRedirect::printRedir(void)

and actually, I have an error when in my code I write

client.printRedir(url, host, googleRedirHost);

as it is proposed in some examples. Searching on the Web, I see that there was another version with

bool HTTPSRedirect::printRedir(const char* url, const char* host, const char* redirHost)

This library gives no errors, but still does not work with my code. What are the dirrerences in the versions, and which order should I use to post data from an ESP8266 to a googel sheet.
I ave verified that when I put in my browser "https://script.google.com"+url,
I fill the proper google sheet file, but I hnot yet been able to do it from the ESP8266.

Thanks for any hint.

When using static ip it cant connect to host.

When I try to set a static ip to esp it can't connect to host site which is script.google.com.
If I put
IPAddress ip(192, 168, 1, 230);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
WiFi.config(ip, gateway, subnet);
before
WiFiMulti.addAP(ssid, password);
it never connects to host(but it connects to wifi) and gets stuck at
while(!client->connected()){ client->connect(host, 443); delay(500); }
and I'm using WiFiMulti, maybe it is the problem.

GoogleDocs.ino does not compile

Hi,
first of all I would like to thank you for this great library.

I have updated the esp8266 library to the latest version (2.4.2) and your example does not compile anymore. This is the error I get:

Arduino: 1.8.7 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, 4M (3M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

Build options changed, rebuilding all
sketch\GoogleDocs.ino.cpp.o:(.text.setup+0x10): undefined reference to `g_cont'

collect2.exe: error: ld returned 1 exit status

It seems that in the latest library was changed some flag of the compiler but I am not to solve the issue.

Thank you very much for your support.

Doesn't connect to scripts.google.com when setting an IO pin as output.

FINAL EDIT:
I thought of deleting my original text, since it got a bit messy. But thought why not leave it for context if needed.

Summarized, I had the following problem:

  • GoogleDocs example works out of the box, still not sure how exactly though.

  • First, I tried slimming it down to my minimal needs (posting 1 value to a sheet when a function is called). When that still worked, I copied it all over to my existing (also working) program that controls the GPIOs running a PLC like loop. Suddenly, it would not connect to the host anymore. Retries for 5 times and then continues (without success).
    Then, I tried it the other way around. Copying my existing program to the working HTTPS Redirect program. Same issue.

  • Then, I tried adding parts of code and testing it, step by step. I found out that without the pinMode part, it would connect. And with it, it wouldn't. After fiddling around, replacing the pin variable names by actual GPIO numbers, it started working (connecting to host) with all pinModes set.

  • Then, when I added my void(loop), again it would not connect anymore at setup. Commenting out a part of it solved it. And after uncommenting it right afterwards, it still worked.

  • So now it basically does what I need it to do and works perfectly. I just have no idea how and why it didn't want to connect before. Specifically how setting the pinModes interfered with the connection before (and doesnt anymore). And how stuff in my void(loop) could have effected connecting to the host in void(setup).

Current (working) code: https://pastebin.com/pXZv68VK
Previous code that didnt connect with pinModes set: https://pastebin.com/tswDwZJD
Thanks in advance for your input. As said before, the part below is the same, but less structured. Just for reference.

_________________________________________________-

Hi, Nice work!

I have the thing working by itself. The weird thing is that when I implemented it into my own code, it would keep trying to (re)connect to the script.google.com host at setup().

I traced it back to the pinModes.

` // Pinmodes
pinMode(scale_serial_tx_pin, OUTPUT);

pinMode(scale_serial_rx_pin, INPUT);

//pinMode(cw1_speedA_pin, OUTPUT);

//pinMode(cw2_speedA_pin, OUTPUT);

//pinMode(cw1_motorDIR_pin, OUTPUT);

//pinMode(cw2_motorDIR_pin, OUTPUT);

pinMode(sensor1_pin, INPUT);

pinMode(sensor2_pin, INPUT);`

When I uncomment one of those four, the esp8266 just keeps trying to reconnect without success at setup(). Any idea what could be the case? The pins are GPIO 0, 2, 4 and 12.

Whole code:
https://pastebin.com/tswDwZJD

Any idea what could be the case? Thanks in advance!

Marko

EDIT: The more I tinker with it, the more confused I get. I got past the pinModes by using the actual GPIO numbers: pinMode(0, OUTPUT).

But now the same thing happens with another part of code.

In my void loop(), there are 4 functions:
readInputs();
checkStep();
Actions();
writeOutputs();

it works like this:
readInputs();
//checkStep();
//Actions();
//writeOutputs();

it does not work like this:
readInputs();
checkStep();
//Actions();
//writeOutputs();

The thing I dont get. This is in the void loop(). But i'm already failing at setup().

Asking for phantom library?

I'm very new to this, but when I try to use this library, I get a compile error stating that <WiFiSecureClient.h> is missing. I was confused because I didn't call for that library, but now see that it's #include in the <HTTPSredirect.h> library. I can't locate this library, and am not sure what to do.

Here is the error I receive:
In file included from C:\Arduino\libraries\HTTPSRedirect/HTTPSRedirect.h:7:0, from Waste_Pump_scanner_esp8266_v1.ino.ino:3: C:\Arduino\libraries\HTTPSRedirect/WiFiClientSecure.h:25:24: fatal error: WiFiClient.h: No such file or directory #include "WiFiClient.h" ^ compilation terminated.

document has moved temporarily

My main issue is that I get 4 or 5 posts, even though the document has moved. But then I get no more posts to the sheet until I reset the ESP. The certicicate always mismatches, but it will log some data anyway.
I have an "update sheet" script that I can run from laptop and it updates just fine.
Here is some output from serial port...
thanks in advance...

Connecting to wifi:
Merja2015
.... IP address:
192.168.1.23
Connecting to script.google.com
Connection Status: 1
Certificate mis-match
tag =__SRMS0Temp = 0 HUM= 0 WaterPress= 1807 WaterHtFt= 1.00
262

<TITLE>Moved Temporarily</TITLE>

Moved Temporarily

The document has moved

HTTPSRedirect: Unable to retrieve Google App Scripts / invalid SSL record after redirect

I'm trying to access a Google Apps Script via the HTTPSRedirect-functions from an ESP32-devboard. I use the functions shown in the example file, so there shouldn't be the problem.

The first step works well:

WiFi connected
IP address: 
192.168.xyz.103
Connecting to script.google.com
[V][ssl_client.cpp:52] start_ssl_client(): Free heap before TLS 152552
[V][ssl_client.cpp:54] start_ssl_client(): Starting socket
[V][ssl_client.cpp:90] start_ssl_client(): Seeding the random number generator
[V][ssl_client.cpp:99] start_ssl_client(): Setting up the SSL/TLS structure...
[I][ssl_client.cpp:123] start_ssl_client(): WARNING: Use certificates for a more secure communication!
[V][ssl_client.cpp:147] start_ssl_client(): Setting hostname for TLS session...
[V][ssl_client.cpp:162] start_ssl_client(): Performing the SSL/TLS handshake...
[V][ssl_client.cpp:181] start_ssl_client(): Verifying peer X.509 certificate...
[V][ssl_client.cpp:190] start_ssl_client(): Certificate verified.
[V][ssl_client.cpp:205] start_ssl_client(): Free heap after TLS 109444
Connected!
GET /macros/s/JKaksz762j[...]/exec HTTP/1.1
Host: script.google.com
User-Agent: ESP8266

[V][ssl_client.cpp:244] send_ssl_data(): Writing HTTP request...
Status code: 302
Reason phrase: Moved Temporarily
_redirHost: script.googleusercontent.com
_redirUrl: /macros/echo?user_content_key=4ahZa[...]&lib=MqdDz[...]

But the connection to the redirected target fails and the whole application hangs:

[V][ssl_client.cpp:52] start_ssl_client(): Free heap before TLS 105140
[V][ssl_client.cpp:54] start_ssl_client(): Starting socket
[V][ssl_client.cpp:90] start_ssl_client(): Seeding the random number generator
[V][ssl_client.cpp:99] start_ssl_client(): Setting up the SSL/TLS structure...
[I][ssl_client.cpp:123] start_ssl_client(): WARNING: Use certificates for a more secure communication!
[V][ssl_client.cpp:147] start_ssl_client(): Setting hostname for TLS session...
[V][ssl_client.cpp:162] start_ssl_client(): Performing the SSL/TLS handshake...
[V][ssl_client.cpp:181] start_ssl_client(): Verifying peer X.509 certificate...
[V][ssl_client.cpp:190] start_ssl_client(): Certificate verified.
[V][ssl_client.cpp:205] start_ssl_client(): Free heap after TLS 68504
GET /macros/echo?user_content_key=4ahZa[...]&lib=MqdDz[...] HTTP/1.1
Host: script.googleusercontent.com
User-Agent: ESP8266

[V][ssl_client.cpp:244] send_ssl_data(): Writing HTTP request...
[E][ssl_client.cpp:32] handle_error(): SSL - An invalid SSL record was received
[E][ssl_client.cpp:34] handle_error(): MbedTLS message code: -29184
[V][ssl_client.cpp:213] stop_ssl_socket(): Cleaning SSL connection.
[V][ssl_client.cpp:213] stop_ssl_socket(): Cleaning SSL connection.

Is this a general problem, or am I the only one with this behavior?

Question: Using HTTPSRedirect

Hello Sujay,

Thank you in advance for making HTTPSRedirect. It has helped me immensely with my projects when I need to interface with Google Sheets. I was wondering if it is possible to use this library with a Arduino Uno using an Ethernet 2 (W5500) shield? I love using ESP8266 devices but have an application where I need to use an Ethernet connection but still require the use of the HTTPSRedirect functionality.

Regards,

Aaron

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.