EMG sensor App to send data to google sheet

There actually no error message. Just that nothing saves on the google sheet.

You may not be using Web1.GotText. Add these blocks to your project, and then try to send the data to your google sheet again. What do you see in Label1.Text

I also note that your google apps script does not have a return element, this is usually required. You could, as previously suggested, edit your script to this:

function doPost(e) {
var ss      = SpreadsheetApp.openByUrl("YOUR_SHEET_URL");
var sh      = ss.getSheetByName("Sheet1");
var Sensor  = e.parameter.Sensor;
var Voltage = e.parameter.Voltage;
sh.appendRow([Sensor,Voltage]);
return ContentService.createTextOutput('data appended');
}

I have done this but it is still not working. There is no data saved on google sheet.

This is sad :frowning:

I have just set up a test project which works for me.

I see you are using the legacy editor.

For the script, when publishing for the first time I set the script to run as Me (my google account) and for it to be accessible by Anyone, even anonymous . This is the only way a google apps script will work with AI2.

I used this script:

function doPost(e) {
var ss      = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1si756vNKC8z3cNCKlPcQGlMc1pmn7vuqHtRc2dLUnck/edit#gid=0");
var sh      = ss.getSheetByName("Sheet1");
var Sensor  = e.parameter.Sensor;
var Voltage = e.parameter.Voltage;
sh.appendRow([Sensor,Voltage]);
return ContentService.createTextOutput('data appended');
}

and these blocks

when I run the app in companion and click Button 1, the data appears in my google sheet

image

and data appended appears in label1.Text.

You might also read this:

Ok..I will just try that now.

Note that in the example link above I use doGet(e). In your project we are using doPost(e).
You cannot test doPost(e) in your computer browser

please can you come again. do you mean the script. because i used doGet(e) in the first part. and doPost(e) in the second.

function doPost(e) {
var ss = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1si756vNKC8z3cNCKlPcQGlMc1pmn7vuqHtRc2dLUnck/edit#gid=0");
var sh = ss.getSheetByName("Sheet1");
var Sensor = e.parameter.Sensor;
var Voltage = e.parameter.Voltage;
sh.appendRow([Sensor,Voltage]);
return ContentService.createTextOutput('data appended');
}

You only need to use the script content I posted above, you do not need the doGet(e).

Yes, just that, and nothing else....

Ok.. I will do that

Remember, every time you change your code in the google apps script, you must republish your web app, selecting New under Project version: in the dialog, then clicking the Update button.

finally it works. :smile

Hooray :smiley:

Now I need to hand you back to @ChrisWard who can help you get your arduino data to fit into the PostText blocks

Ok.. I very much appreciate your time and efforts. However, I still need to get EMG sensor values to google sheet. that is still in contention. I trying my best to implement it.

Hello, @TIMAI2 @ChrisWard Thanks for you help. I am now able to figure out how to send the EMG sensor data to google sheet. The next part of my project is to plot the signal using the canvas. I have done some and still need your support again.

You might consider:

to chart your values....

3 Likes

Hi Anthony

We have moved along with you on your Topic as an expedience - you happened to get two Power Users that could help with (1) Bluetooth and (2) Uploading to a Google Sheet. However, they are separate subjects and should have been separate Topics. Like wise, Charting data is a separate subject and should be a separate Topic.

There are two reasons:

  1. Your Topic will get a better response from the experts of the particular subject field.
  2. Other Users searching the Forum for a specific subject will be more likely to find the Topics on that subject.

It's important to us because App Inventor has well over 400,000 unique active Users per month and we are a small team of volunteers. :upside_down_face:

1 Like

Ok..thank you for the information. I am now trying to plot the emg signals in graph form.