Communicating with google sheets via the esp8266, sending strings question

Hello,
I’m working on a project that will provide some attendance info to a spreadsheet on the google. Right now I’m working on updating that sheet. I’ve followed some online tutorials and have it working almost perfectly. The issue is that the code only sends floats and I would like to send a string. I’m not too familiar with how the libraries I’m using work and have thus far been unsuccessful in my attempts. Here’s the working code:

#include "TRIGGER_WIFI.h"               /*Includes ESP8266WiFi.h and WiFiClientSecure.h, just have these two libraries downloaded before*/
#include "TRIGGER_GOOGLESHEETS.h"       /*Library file for Google Sheets, has to be used after Wi-Fi Client Secure declaration, here everything is in Trigger_WIFI.h, so using it after Trigger_WIFI.h*/ 

/**********Google Sheets Definations***********/
char column_name_in_sheets[ ][20] = {"value1","value2","value3"};                        /*1. The Total no of column depends on how many value you have created in Script of Sheets;2. It has to be in order as per the rows decided in google sheets*/
String Sheets_GAS_ID = "...";                                         /*This is the Sheets GAS ID, you need to look for your sheets id*/
int No_of_Parameters = 3;                                                                /*Here No_of_Parameters decides how many parameters you want to send it to Google Sheets at once, change it according to your needs*/
/*********************************************/

void setup() 
{
  Serial.begin(9600);
  while (!Serial);

  WIFI_Connect("...","...");                                                     /*Provide you Wi-Fi SSID and password to connect to Wi-Fi*/
  Google_Sheets_Init(column_name_in_sheets, Sheets_GAS_ID, No_of_Parameters );         /*Sets the column name for Google Sheets, the GAS ID, and the No of Parameter we want to send*/        
}

void loop() 
{
  float a = 1, b = 2, c = 3;                           /*Demo values that has to be sent to google sheets, you can use sensor values*/
  client.setInsecure();
  Data_to_Sheets(No_of_Parameters,  "sean",  a, b);         /*1. This function accepts multiple float parameter, here No_of_Parameters decides how many parameters you want to send to Google Sheets; 2. The values sent should be in order as per the column in Google Sheets*/

  Serial.println();
  delay(10000);                                       /*10 Sec Delay, Here 10 second delay is just used so that we can see the data pushed to sheets one by one
                                                        There is nothing like a minimum delay between two data push*/
}

I’d like those floats (a,b,c) to be Strings (last name, first name, etc). Any ideas? Thanks in advance!

Also, here’s the library TRIGGER_GOOGLESHEETS code:

#ifndef __TRIGGER_GOOGLESHEETS_H__
#define __TRIGGER_GOOGLESHEETS_H__

#include <stdarg.h>
#include <string.h>


void sheets_initialization();
void Send_Data();
void Google_Sheets_Init(char array_2d[10][20], String sheets_gas_id, int param_size);

String url;

char column_name[ ][20]={"temperature","humidity"};;

double random_values[100];

void float_to_string();
const char* host = "script.google.com";
const int httpsPort = 443;

char Sensor_Values[10][10];
const char* fingerprint = "46 B2 C3 44 9C 59 09 8B 01 B6 F8 BD 4C FB 00 74 91 2F EF F6";
String GAS_ID;
int Count;

void Google_Sheets_Init(char test[ ][20], String sheets_gas_id, int param_size)
{
	GAS_ID = sheets_gas_id;
	Count = param_size;
	
	for (int i = 0; i < Count; i++)
    {
	 for (int j = 0; j < 20; j++)
     {
		column_name[i][j] = test[i][j];
     }
    }
	
	#ifdef Debug_Serial_Mon
	   for(int i=0;i<Count;i++)
	   {
			Serial.print("column_name= ");
			Serial.println(column_name[i]);
	   }
   #endif
	
}

void Data_to_Sheets(int num, ...)
{
	va_list lst;
	va_start(lst,num);
	
	for(int i=0;i<num;i++)
	{
		random_values[i]= va_arg(lst,double);
	}
	va_end(lst);	
	
	float_to_string();
	Send_Data();
}

void float_to_string()
{
  for(int j=0;j<Count;j++)
  {
    sprintf(Sensor_Values[j],"%.02f",random_values[j]);
	#ifdef Debug_Serial_Mon
		Serial.print("Sensor Values : ");
		Serial.println(Sensor_Values[j]);
	#endif
  }
}
void Send_Data()
{
	sheets_initialization();
    
	String url = "/macros/s/" + GAS_ID + "/exec?";
	int i=0;
	while(i!=Count)
	{
		if(i==0)
		{
		  url = url+column_name[i]+"="+Sensor_Values[i];
		  i++;
		}
		if(i==Count)
		  break;
		url = url+"&"+column_name[i]+"="+Sensor_Values[i];
		i++;    
	}
  
  Serial.print("requesting URL: ");
  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
         "Host: " + host + "\r\n" +
         "User-Agent: BuildFailureDetectorESP8266\r\n" +
         "Connection: close\r\n\r\n");

  #ifdef Debug_Serial_Mon
  Serial.println("request sent");
  #endif
  while (client.connected()) 
  {
	  String line = client.readStringUntil('\n');
	  if (line == "\r") 
	  {
		#ifdef Debug_Serial_Mon  
		Serial.println("headers received");
		#endif
		break;
	  }
  }
  String line = client.readStringUntil('\n');
  
  if (line.startsWith("{\"state\":\"success\"")) 
  {
	#ifdef Debug_Serial_Mon
	Serial.println("esp8266/Arduino CI successfull!");
	#endif
  } 
  else 
  {
	#ifdef Debug_Serial_Mon  
	Serial.println("esp8266/Arduino CI has failed");
	#endif
  }
  
  #ifdef Debug_Serial_Mon
	  Serial.println("reply was:");
	  Serial.println("==========");
	  Serial.println(line);
	  Serial.println("==========");
	  Serial.println("closing connection");
  #endif
	
}
void sheets_initialization()
{
	client.setInsecure(); 
  
  #ifdef Debug_Serial_Mon
	  Serial.print("connecting to ");
	  Serial.println(host);
  #endif
  
  if (!client.connect(host, httpsPort)) 
  {
    #ifdef Debug_Serial_Mon
	Serial.println("connection failed");
	#endif
    return;
  }

  if (client.verify(fingerprint, host)) 
  {
	#ifdef Debug_Serial_Mon
	Serial.println("certificate matches");
	#endif
  } 
  else 
  {
    #ifdef Debug_Serial_Mon
	Serial.println("certificate doesn't match");
	#endif
  }
	
}
#endif

Working code?

Data_to_Sheets is supposed to be called with an integer as its first parameter, and floats for the remaining parameters.
It looks like you changed the working code.

Hi! Thanks for your reply.
If you're referring to the "sean" in the call, then yes, I did try that without success.

I can get the code to push floats to the spreadsheet, but I'm having little luck pushing a string.

Show the original working code!

.

Ok. If you insist.
The only difference is that the "sean" is replaced withe the variable 'a'.

#include "TRIGGER_WIFI.h"               /*Includes ESP8266WiFi.h and WiFiClientSecure.h, just have these two libraries downloaded before*/
#include "TRIGGER_GOOGLESHEETS.h"       /*Library file for Google Sheets, has to be used after Wi-Fi Client Secure declaration, here everything is in Trigger_WIFI.h, so using it after Trigger_WIFI.h*/ 

/**********Google Sheets Definations***********/
char column_name_in_sheets[ ][20] = {"value1","value2","value3"};                        /*1. The Total no of column depends on how many value you have created in Script of Sheets;2. It has to be in order as per the rows decided in google sheets*/
String Sheets_GAS_ID = "...";                                         /*This is the Sheets GAS ID, you need to look for your sheets id*/
int No_of_Parameters = 3;                                                                /*Here No_of_Parameters decides how many parameters you want to send it to Google Sheets at once, change it according to your needs*/
/*********************************************/

void setup() 
{
  Serial.begin(9600);
  while (!Serial);

  WIFI_Connect("...","...");                                                     /*Provide you Wi-Fi SSID and password to connect to Wi-Fi*/
  Google_Sheets_Init(column_name_in_sheets, Sheets_GAS_ID, No_of_Parameters );         /*Sets the column name for Google Sheets, the GAS ID, and the No of Parameter we want to send*/        
}

void loop() 
{
  float a = 1, b = 2, c = 3;                           /*Demo values that has to be sent to google sheets, you can use sensor values*/
  client.setInsecure();
  Data_to_Sheets(No_of_Parameters,  a, b, c);         /*1. This function accepts multiple float parameter, here No_of_Parameters decides how many parameters you want to send to Google Sheets; 2. The values sent should be in order as per the column in Google Sheets*/

  Serial.println();
  delay(1000);                                       /*10 Sec Delay, Here 10 second delay is just used so that we can see the data pushed to sheets one by one
                                                        There is nothing like a minimum delay between two data push*/
}
void upload_Data(){
    float a = 1, b = 2, c = 3;                           /*Demo values that has to be sent to google sheets, you can use sensor values*/
  client.setInsecure();
  Data_to_Sheets(No_of_Parameters,  a, b, c);         /*1. This function accepts multiple float parameter, here No_of_Parameters decides how many parameters you want to send to Google Sheets; 2. The values sent should be in order as per the column in Google Sheets*/

  Serial.println();
  delay(1000);  
  
}

try changing
char Sensor_Values[3][10];
to
char Sensor_Values[3][10];
Sensor_Values[0]=“abc”;
Sensor_Values[1]=“def”;
Sensor_Values[2]=“12345”;

In loop( )
replace
Data_to_sheets(No_of_Parameters, a, b, c );
with
Send_Data();

.