EMG sensor App to send data to google sheet

I am trying to design an MIT app using electromyography sensor, Bluetooth HC-05 and Arduino Uno to to transmit the sensor data to google sheet. I am finding difficult to send the sensor readings values to google sheet. Please can anyone out there help me. ?

Please show your script and the values you want to send, and how you believe they should be presented on your google sheet

Hello, I

want to send the values the same as it is displayed on Arduino serial monitor. On click of record, the app should transmit the values to google sheet.

OK, we are nearly there....

  • Can you show the value of global Receive_data after it has captured the data. is this just a single line like this:
Voltage:  39.10 mvSensor Value: 9.00

or multiple lines?

  • How often do you intend to fetch the data ?

  • Do you want to post values to your google sheet every time for every value collected, or only for the value at the time you click the button (this implies there is only one set of values returned)?

  • you can, if you wish, reduce your script to this: (you will need to enter your SHEET_URL)

function doPost(e) {
var ss      = SpreadsheetApp.openByUrl("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');
}

(remember to create a new version)

When the data is display it does not show in a single line. However, i wish to send the values that are read to google sheet and delay it by every 5s. In that case, every 5s, it transmit the data to google sheet.

Consider this: Will there be someone monitoring the spreadsheet every 5 seconds?

What if you sent 12 records (or even just 1), once a minute ?

I am not saying it can't be done, just getting you to consider the practicality of doing it....

1 Like

and the data in global Receive_data looks like this? :

Voltage: 39.10 mvSensor Value: 9.00
Voltage: 39.10 mvSensor Value: 9.00
Voltage: 39.10 mvSensor Value: 9.00
Voltage: 39.10 mvSensor Value: 9.00
Voltage: 39.10 mvSensor Value: 9.00
Voltage: 39.10 mvSensor Value: 9.00
...

I need an arduino/Bluetooth minded colleague (@ABG , @ChrisWard) to advise on how you manage the arduino output.

if that can be done. I guess it will be time delay to send the data. Maybe i can delay it by 10 seconds to get 6 readings every minute.

How often is the ardiuno kicking out a line of data, and how often is bluetooth returning it ?

You could fire the clock to send a line or set of data from when data is received (no button click required)

It displays the data with the sensor readings but not in a straight line. This is the code on the Arduino board

It does so every 300milliseconds. I will need to use a delay here.

3 outputs a second?

OK, how often to you really need an output ? Every 10 seconds, every minute ? Set you delay to that?

This should get you down to seeing just one set of values returned which could then more easily be sent to the google sheet....

I want to see the value every 10s. This allow for the consistent measurement of the muscle signals. That is every 10s, the electromyography sensor value should be send to google sheet.

Hello Anthony

That's actually a very poor Sketch, I'm surprised it has been published - it should not assign variables inside the loop and for the purposes of sending data to an App, only the final value should be sent. Do not use a delay to set the time interval, use elapsed milliseconds - that will help to ensure consistent results from a sensor.

The data itself should just be a number (or string) without labels - this is because a bluetooth 'data packet' is very small @ approx 23 bytes.
See my website for more information about Arduino Uno and Bluetooth:
https://www.professorcad.co.uk/appinventortips#TipsMicrocontroller

Unfortunately your App Blocks have errors too. In particular, your code needs to be aware that sometimes the data size expected does not happen (especially on start). It also needs to ensure that both Location and Bluetooth are actually switched on.

Very important is the timing. The App time interval should be approx 20% shorter than the Arduino's. You have the added complication of passing the data on to a Goggle Sheet. I suggest you start with large time intervals so you can easily ensure everything is correct, then you can tweak the intervals down until you see discrepancies in the results. However, the golden rule is to always use the longest possible time intervals that meet realistic requirements.

I can provide you with a Basic App project that covers most bases which you can hack to suit your requirements, many people have used it successfully. I can also help you with your Sketch, but first of all I need to know the format of the data - some lines that represent what you need to process -value labels can be predefined as column titles in the spread sheet.

Ah, 10 seconds is a good time interval.

Your data sent to the App, Voltage and Sensor Value, Should be like this:

Value, Value Separator, Value, End Of Data Mark

So: 39.10|9.00\n

Serial.print(fVolts)
Serial.print("|") //value separator (App needs to know this!)
Serial.print(fSensor)
Serial.println() //end of data

Thanks for the response. I have done the correction. I still have issues now sending the data to google sheet. Please can you help with the google script editor codes to send the data to the google sheet.

Hi, I have made changes to the Arduino

and done some correction to the app blocks but i still have the same issues. The emg sensor data is not transmitted to the google sheet.

  • your delay still seems to be set at 300ms ?
  • what does global Receive_data look like now ?

we need to get your incoming data sorted out, then we can worry about the google sheet

I have now delayed it by 5sec. I changed the delay to 5000milliseconds