WiFi101 library fails connecting to https google docs server

Hi everyone!

I am trying to do HTTP POST to a google form online so that I can store sensor values in 40ms intervals.

However, I am stuck at the first step of connecting to docs.google.com The reason from similar posts I googled on the net seems to be secure https that google uses. I thought WiFiSSLClient or connectSSL should handle SSL connections on MKR1000 with WiFi101 library. But I just get failure after attempting client.connect()line in my code.

I have updated firmware and passed the example FirmwareVersion test. I can connect to www.google.com but has no luck with WiFiSSLClient example. My own code is long and the problem is really in client.connect() line with server "https://docs.google.com"

My initial goal was to save online data in a spreadsheet every 40ms. I decided to do this without third part clouds like pushingBox or thingSpeak because they have a limit on number or interval of sending data.

I appreciate any help very much. Had posted previously here but got no response.

Looking forward for any ideas :) Thanks!

Hi @monamomeni,

Have you flashed the root certificate for docs.google.com using the WiFi 1010 Firmware updater?

Hi sandeepmistry,

Thanks a lot for your comment, I had done it before and kind of though it won't work. It must be before I updated the firmware to 19.5.4 version. Anyway, it connects and writes into the form I had created on Google. I can't believe it! :)

The only thing that seems strange is that I have less than 25 samples in each second. Do you have any idea of the time for sending 12Bytes over wifi SSLClient? Here's the main piece of my code and this is executed in a loop, after I read data:

String data = "";
  data+= String (red_buffer[count]);
  data+= String (green_buffer[count]);
  data+= String (ir_buffer[count]);
  data+= String (amb1_buffer[count]);

  Serial.print("starting to connect to server..");
  if (client.connectSSL(server, 443)) {
    while (client.available()) {
      char c = client.read();
    client.print("POST /forms/d/e/1FAIpQLSeY52upbcW2Tcwdi5eusdi1_5GoMBMejc8pN8lreg5asrkAPA/formResponse?");
    client.println(" HTTP/1.1");
    client.println("Host: docs.google.com");
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.println("Connection: close");
    client.print("Content-Length: ");

is it possible to only run client.connect(server, 443) once, to save time?

Thanks, Mona

An awful lot depends on your connection speeds, ping rates, hops, and a few more factors. The best you can do is approximate the sketch time itself and then add the overheads for network travel to that.

Without a FULL sketch and knowing what is connected to the MKR it is just a guessing game.

You could also concatenate data into a longer string to send more data at one time. Arduinos are quite adept at that function but it does in itself carry an overhead.

Hello and thanks a lot ballscrewbob for your answer.

I measured the time and it seems that the Wifi transmission on Google form can take anything between 0.5-2seconds. As you said, there are lots of factors in between and it’s not a good idea to rely on https for recording all samples with 40ms update rate. I’ve decided to use google form for final results of further processing where a more relaxed time frame (e.g. every minute) is possible.

I will still have many data arrived while it is sending over http, but since it’s every 1 minute, I think it is possible to buffer the arriving data and avoid missing.

BTW, how can I send a batch of data to http? I use a format like:


to write values in fields of an online form.


Must it be an "online" form ?

I ask as sending directly to a spreadsheet or database on a local computer is actually quite fast and the computer can be used to then send to an online form.

That would mitigate any delays and pre-format the data. There are quite a few options for that approach where a lot of information is needed in bulk and at speed.

I use thingspeak myself as I find the 16 second limit acceptable for my particular uses. However you can also use the ability to add strings together until they reach a set limit eg. 255 characters and then send the whole string using a similar approach to yours.


data1=string ("field1="+analogValue0+",");
data2=string ("field2="+analogValue1+",");
data2=string ("field3="+analogValue2+",");

string =string+ data1+data2+data3
if length string >=nn then send to spreadsheet

You would end up with something like "field1=nn,field2=nn,field3=nn,field1=nn,field2=nn,field3=nn"

You can then simply use the spreadsheet to split and insert the correct fields into the correct rows or columns.

BTW there is a section of the forum more dedicated to data transfers etc with some exceptional advice and hints. Much more experience than I can offer.