I am still new but learning a ton. I am stuck on a problem here and cannot get this to function properly.
a little background: I'm building a temp control device using a relay and a dht11. This is for a home curing chamber so i can make my own salami!
I have everything working except for the functionality to post the sensor readings to a Google spreadsheet. i can post static text but not the dynamic sensor readings. here is my code for doing the posting, can you take a look and tell me what I'm missing? I think it is an issue with the sensor values not being defined as dynamic but I don't know.
thanks!
and f and h variables are defined with float values to be the readings in the correct format from the sensor.
// Set Choreo inputs
String ClientSecretValue = "deleted for privacy, but is correct";
AppendRowChoreo.addInput("ClientSecret", ClientSecretValue);
String RefreshTokenValue = "deleted for privacy, but is correct";
AppendRowChoreo.addInput("RefreshToken", RefreshTokenValue);
String SheetNameValue = "Sheet1";
AppendRowChoreo.addInput("SheetName", SheetNameValue);
String sensorValue = "f,h";
AppendRowChoreo.addInput("RowData", sensorValue);
String SpreadsheetTitleValue = "Curing Chamber";
AppendRowChoreo.addInput("SpreadsheetTitle", SpreadsheetTitleValue);
String ClientIDValue = "deleted for privacy, but is correct";
AppendRowChoreo.addInput("ClientID", ClientIDValue);
Although I never followed through with the issue once upon a time I this exact problem. I think your best bet is Using the command sprintf() for sending the string. I had problems posting dynamic time with my RTC and i had fixed with code simular to this.
sprintf(MessageBodyTotal, "Current time is : %02d:%02d:%02d \n ", hour(), minute(), second());
This may not seem useful but i do suggest looking up more sprintf() pages for a better explanation on it's utility.
The addInput function only takes character arrays or String variables as its inputs. Since analogRead returns an integer, we need to turn it into a String. To do this, we type cast analogRead's return value to a String (you can also do String(analogRead(A0))). If you are wanting to send the values stored in the variables f and h, you can do something like this:
int f = digitalRead(2);
int h = digitalRead(4);
String sensorValue = String(f) +"," + String(h);
This will produce your comma separated values in your sensorValue String.
If you have any questions, feel free to contact us at Contact | Temboo - we're always happy to help.