From Google Sheets to ThingSpeak

Hi everybody!
This is the problem. I have a Tilt Hydrometer (https://tilthydrometer.com). The Tilt send the data to a Google Sheet. Then, I need to take that data and put it in a ThingSpeak channel. I'm a beginner in ThingSpeak, And I really need the help with this. Any idea?

 Accepted Answer

Vinod
Vinod on 26 Jun 2020
You can set up a MATLAB analysis code to use this function to read data from your google sheet. Once you have the data in your MATLAB analysis, you can use thingSpeakWrite to write a value into a ThingSpeak channel. You can completely automate this by scheduling your MATLAB analysis using the TimeControl app to do this on a regular interval.

5 Comments

Thanks Vinod.
I´m two days trying to make ir works, but I have some problems.
1) Now, I have the data in a Matlab Analysis like you told me. It works perfect.
But, 2) When I try to send it in the ThnigSpeak Channel woth the thingSpeakeWrite, the system give me an error: "error using Tilt1 Google (line 36). 'Values' value must be an array or a table.".
The data is something like this:
ans =
325×7 cell array
{'Timestamp' } {'Timepoint'} {'SG' } {'Temp'} {'Color'} {'Beer' } {'Comment' }
{'6/27/2020 7:31:02'} {'44,009.69'} {'1.001'} {'78' } {'RED' } {'Prueba 1'} {0×0 double}
{'6/27/2020 7:31:14'} {'44,009.69'} {'1.001'} {'78' } {'RED' } {'Prueba 1'} {0×0 double}
{'6/27/2020 7:32:09'} {'44,009.69'} {'1.00
How can I write the first Column in the Channel 1 Field 1, the second in the Channel 1 Field 2, etc...?
As the error says, you need to convert your cell array from the Google sheet into a table.
SGTable = table(ans(:,1), ans(:,3),'VariableNames',{'timestamp','SG'}) % where ans is the cell array you got back from reading the google sheet
Now, you should be able to use thingSpeakWrite to get the data in SGTable to ThingSpeak.
Hi. Could you please explain how to do the opposit? I need to send the data from one channel of ThingSpeak to the Google sheets.
Regards
Behnam
Thanks for the recomandation. I have a monitoring system that should be installed on a building, sending the data to ThingSpeak IoT in real time. On the other hand I have developed a Matlab algorithm to get the data from ThingSpeak and transfer them to a Google sheet, in real time. The case is that when I turn off the Laptop this process stops as the Matlab algorthm is not working anymore.
Is there any solution for that?? Lets say a Matlab function to use it in the algorithm to make the algorithm keep working for a year, even if the laptop is turn off?!
Regards
Behnam

Sign in to comment.

More Answers (0)

Communities

More Answers in the  ThingSpeak Community

Categories

Find more on ThingSpeak in Help Center and File Exchange

Products

Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!