2017년 8월 3일 목요일

Help with medical app project


I am currently working on a biomedical app project that sends synthetic ECG data via Bluetooth from an Arduino Duemilanove to an Android app using App Inventor Classic. My end goal is to have either (1) the app display a graph of the synthetic ECG data in real time or (2) capture the synthetic ECG data to a certain extent onto the app, convert it to a .csv file, upload it to the TinyWebDB server, and graph the data points there. Here is what I have been able to achieve so far:

1. Bluetooth connection
2. Send a continuous stream of synthetic ECG data via Bluetooth to my app from an arduino sketch
3. Manually capture a portion of that data (20 points/sec) and upload it to my own TinyWebDB server: http://healthappsjsu.appspot.com

The current problems I am facing are the following

1. The canvas is only DISPLAYING about 20 data points every second and refreshes it to another set of 20 data points further down the transmission. I wish to be able to see a continuous stream of all the data coming in and not random portions.
2. When I am able to capture a certain portion of data and send it to the TinyWebDB server, the server displays it as the following:

""43\r\n0.52\r\n0.61\r\n0.71\r\n0.80\r\n0.89\r\n0.99\r\n1.08\r\n1.17\r\n1.27\r\n1.36\r\n1.45\r\n1.55\r\n1.92\r\n3.02\r\n4.83\r\n7.06\r\n9.30\r\n11.53\r\n13.77\r\n15.""

From what I understand, "\r\n" signifies a line break, which I obviously do not want to see when displaying the data and I can't really do much in terms of graphing from the data that is being displayed. My only thought is that I need to convert the data that is being transmitted into a .csv file and have the TinyWebDB server graph the data points in the .csv file.

Can anyone steer me in the right direction on how I can go about doing this? It seems like an easy process but I am unable to grasp the concept easily.

I uploaded the source for the app if it helps.

ECG_Project_1.zip

--
Neat app Jeff,

For full disclosure, I do not program in AI Classic but still might have some suggestions of value.

Some preliminary observations:

1) Be aware, support for AI Classic is being discontinued later this year according to what I have heard.  Should you be developing in AI2?  There will be some new tools later this year that certainly will be a plus in your app; AI will not be upgraded I understand.

2) getting rid of \r \n and other things is relatively easy with AI2  .   There is an AI2 Text block   replace all  text      (the text goes here)
                                                                                            segment     \r or \n goes here .... the text you want to get rid of
                                                                                    replacement     a blank text block would go here ...what you want to replace it with.
that will fix the parsing issue probably.   Hopefully AIClassic has a similar block.
3) regarding: "need to convert the data that is being transmitted into a .csv file and have the TinyWebDB server graph the data points in the .csv file." , that might be one way to do it.
with AI2, depending on your code (which unfortunately I can not see at the moment) there may be several ways to do this.

4) does it all have to be done on a devic?  Why not use the app to capture the data.  Send it to a Fusion table or TinyWebDB (I prefer fusion table) and export to an Excel or OpenOffice spreadsheet and graph there?

I'll think about this later, perhaps someone else currently using AIClassic will have other ideas.

--
1) Thanks for the heads up about AI Classic support. Unfortunately, time isn't a luxury for me at the moment (as is always the case with 90% of these things) so translating it into AI2 may prove to be time consuming so I need to make do with what I have. The reason I even started the project in AI classic was that most of the examples/tutorials I researched were written in the AI classic environment. :-/

2) I was able to find the "replace all text" functionality in AI classic but I was still unable to remove the \r\n on the server end; I attempted to use the "replace all text" function everywhere I saw a text "ECGDATA," global "ECG," and global "ECGdata" in the block diagram but to no luck. This leads me to believe that I might possibly need to implement an identical method within the python/java coding of the server itself or possibly I'm still implementing it wrong within the AI classic environment.

3) and 4) Not sure I understand your question so please forgive me if this wasn't the answer you were expecting. The thought process behind the app acting as the medium to a separate device is that initially the project was supposed to be an attempt at remotely monitoring a patient while they are at home. The patient would be hooked up to a portable device (acting as the measurement tool) and transmit the physiological data (ECG) wirelessly to an app on their phone. A minimum amount of electrodes would be attached to the patient allowing them to be mobile and give their hands freedom to do their daily activities. The app would then upload their data to a cloud server where a physician could remotely access this information if needed. If the app were to also act as the device thus eliminating the need for the arduino (as I've seen implemented in various other projects such as utilizing the camera and/or attaching electrodes to the casing of the phone), continuous monitoring would be inconvenient to the patient since the patient would need to continuously grasp the phone to record the data. I see the potential of this thought process as ultimately making the app universal to several devices but of course I am still focusing on the foundation at the moment.

As of right now, most of this is up in the air since I have hit a roadblock in just graphing the data coming in on the server end since the data being uploaded is not in a form that the server likes. I have seen the idea of Fusion Tables being thrown around but I do not have enough experience yet into how I would be able to implement that.

I think I was able to solve one of the issues I previously inquired involving the amount of transmitted data being displayed in the canvas of the app. From what I determined, if I have a baud rate of 9600 b/s coming from the Arduino, I would need to define at least 1200 bytes in the "BluetoothClient1.ReceiveText" part of the block diagram. Unfortunately, when I implemented that, the app started to lag considerably.

So that's kinda where I am at the moment. 

--
Understand the time investment in AI Classic.

2) I was able to find the "replace all text" functionality in AI classic but I was still unable to remove the \r\n on the server end; I attempted to use the "replace all text" function everywhere I saw a text "ECGDATA," global "ECG," and global "ECGdata" in the block diagram but to no luck. This leads me to believe that I might possibly need to implement an identical method within the python/java coding of the server itself or possibly I'm still implementing it wrong within the AI classic environment.


OK, so now I am confused.    You should be able to remove the extraneous data as it is received from the ardiuno into your Android  and also when the data stream is transmitted from the Adroid to the server.  To bad I can not view your blocks.

Regarding 3.     What I attempted to say is if the data needs to be in CSV format at the tinyWebDB server, it should be possible to put the data into that format before it leaves the Adroid.    Or, it could be send in different form. depending on whether the data stream is continuous or in packets

Regarding 4.   Does it make a difference where the data is graphed?    Does the patient need to see the data?   if so, you graph on the Android ..AI2 has lousy tools to do that (AI also).  As far as how you would get the server to graph, I have no Idea, however if the data is in a Fusion table ...something like an Excel spreadsheet, the data base would be there and accessible to a physician. ( This link   https://support.google.com/fusiontables/answer/2548807?hl=en&ref_topic=27017 indicates contents of  the fusion table itself can be downloaded as a csv table.  Be aware, a spreadsheet program like Excel can read csv files AND graph them.   A bit cumbersome but doable.     I haven't tried but I think I could write a Windows program to download a fusion table and provide a graph display.   This is not difficult stuff if one has the tools.   In this case, the arduino>Android>fusion table  to a Windows program that would graph a csv  to download to a spreadsheet Windows application and graph/
As of right now, most of this is up in the air since I have hit a roadblock in just graphing the data coming in on the server end since the data being uploaded is not in a form that the server likes. I have seen the idea of Fusion Tables being thrown around but I do not have enough experience yet into how I would be able to implement that.
Not good, but why must the data be graphed on the server.    Fusion table.... the AIClassic Pizza Party shows one way to use a fusion table   http://explore.appinventor.mit.edu/content/pizzaparty   and perhaps it will give you some ideas.

I assume you need csv... if we could figure out how to parse your data stream of the \r and \n and get it into csv, would that help?  

--
I do similar thing (collect data, show graph representation, send data as csv to server). However, what I do, uses an extension of MIT AI. You can take a look at THIS video and if you have question, you can email me directly so that MIT AI forum does not get cluttered with non AI question.

--
I assume you need csv... if we could figure out how to parse your data stream of the \r and \n and get it into csv, would that help?  
In short, yes, I believe so.

--
You never did show the data stream from the Android device, just what the TinyWebDB has to deal with.

""43\r\n0.52\r\n0.61\r\n0.71\r\n0.80\r\n0.89\r\n0.99\r\n1.08\r\n1.17\r\n1.27\r\n1.36\r\n1.45\r\n1.55\r\n1.92\r\n3.02\r\n4.83\r\n7.06\r\n9.30\r\n11.53\r\n13.77\r\n15.""

and you want  43 , 0.52 , 0.61 , 0.71 , 0.80 , 0.89 , 0.99 , 1.08 , 1.17 , 1.27 , 1.36 , 1.45 , 1.55 , 1.92 , 3.02 , 4.83 , 7.06 , 9.30 , 11.53 , 13.77 , 15    ???

That line is one type of csv Jeff.

To get it you should be able to replace \r\n   space,space   (a comma)   or a semi-colon .
You similarly get rid of the "" by replacing "" with a space   on a second pass of the block that replaces text.
That should be easy and would be easy.... how about an image of the relevant blocks.. also, there may be a more direct way to create a csv 

using something like    list to csv row list    or  list to csv table   or whatever equivalents exist in AIClassic.

I just wish I could see some blocks or know for sure what the data looks like.   Is every measurement the same thing?  
Not knowing what the units above represent means this is all I can do.    And are the data sampled at a regular interval ... the data might represent the y axis, is TIME the x axis?

if the device collects and reports the time, for instance   this could look like:   8:18:19 AM, 43, 8:18:20 AM, 0.52 etc.  or if not, the Android could add the time info when it grabs part 
of the data stream

What comes into the android if you just ask for one point.    you may be able to capture the data as text  and use a JOIN to supply a comma separator.

Just ideas.

-- 
Here is a link to developers using ardernio to measure temperature ... not so different than what you are attempting  https://www.google.com/search?q=app+inventor+an+temperature+sensor&oq=app+inventor+an+temperature+sensor&aqs=chrome..69i57.7903j0j4&sourceid=chrome&espv=210&es_sm=93&ie=UTF-8

--
Steve, thanks for all the help so far. Much appreciated. Sorry for the late reply, I am currently attempting many fixes as well as your suggestions.
The data stream from the Android device is represented from the following Arduino sketch. I am defining the data points of a PQRST ecg waveform with the variable ecg[ ] and sending it through a for loop for(int k = 0;k<100;k++) to mimic continuous heart beats. The waveform plot is voltage (mV) vs. time (ms).  
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX
double ekg[] = {0.19136,0.19136,0.27337,0.41006,0.54675,0.74282,2.0672,4.8761,9.1102,13.701,18.291,22.881,27.472,30.226,29.92,26.554,21.963,17.373,12.782,8.1921,4.2015,1.7103,0.7185,0.62638,0.53427,0.44215,0.35004,0.25792,0.16581,-0.9667,-6.2608,-14.335,-14.306,-1.4965,22.712,48.475,71.736,76.651,60.719,26.441,-10.339,-44.249,-57.116,-46.071,-20.956,-4.5927,0.149,0.24213,0.33526,0.42839,0.52151,0.61464,0.70777,0.80089,0.89402,0.98715,1.0803,1.1734,1.2665,1.3597,1.4528,1.5459,1.9248,3.0181,4.8258,7.0621,9.2985,11.535,13.771,15.65,16.097,15.053,12.877,10.64,8.404,6.1676,4.0046,2.3792,1.3647,0.88781,0.48964,0.1937,0.032284,0}; int input = 0;
int lastinput = 0;

void setup()                    // run once, when the sketch starts
{
  mySerial.begin(9600);           // set up Serial library at 9600 bps
}

void loop()                       // run over and over again
{
  for(int k = 0;k<100;k++)
  {
    mySerial.println(ekg[k],2);
    delay(50);
  }
}

The data is represented on the app in a similar fashion to the temperature app example you just recently provided (I have actually based most of my foundation on this exact example). Instead of one data point being refreshed every second (in his case a temperature reading), multiple portions of non-identical data points (voltages) are being generated and continuously refreshed onto the canvas in the following fashion every second:
0.00
0.00
0.52
0.61
0.71
0.80
0.89
0.99
1.08
1.17
1.27
1.36
1.45
1.55
1.92
3.02
4.83
7.06
9.30
11.53
13.77

The canvas is only showing random portions of the continuous data stream. The current capability of my app can only manually capture that specific portion at a time and send it to the TinyWebDB in the form that was previously mentioned with the "\r\n."From the looks of it, it is also cutting off parts of it when uploaded to the server.

As for a picture of the blocks, I was under the impression I supplied it in my initial post of this thread. I went ahead and input it as an attachment instead this time.

Hope this helps. Thanks.

--
I just took a quick peek at what you sent.    I think I see a potential issue.  Getting late here so will look further in the morning.

However, want to bring this to your attention.   Look at the last two postings in this thread:  https://groups.google.com/forum/#!searchin/mitappinventortest/remote$20control/mitappinventortest/s_10cwaVm-k/G3wnYpJSRKAJ

This guy is taking data in possibly a similar way but sending the data between Android and a wifi connection to a PC ... it appears something like what I was attempting to explain.   If you can not get this working the way you intend, Valter's ideas might be appropriate ... yeah, his stuff is in AI2, however, the principles apply to AI1.

--
I am still looking.  ...and sorry, I forgot u sent some blocks earlier on.  Looking at them I cannot see where you are plotting.You mentioned something about TinyWebDB but I really did not follow that.

I see several place you may be losing data.

1) you generate the data on the Arduino, capture it to the Android where you
2) post it to a TinyWebDB apparently in what you think is real time then you 
3) graph it on a canvas on the Android ??.. I can not tell from the blocks if you do this immediately on the Android and later graph is somewhere else  
4) then you appear to retrieve data from the TinyWebDB  and ???

a flow chart would be helpful.

Every time you post data to the TinyWebDB, you are probably miss capturing data occasionally.
If you plot each point as the data is received (either first on the Android screen or to the TinWebDB), while the Android posts, you probably loose a piece of data).

I suggest you do NOT use a TinyWebDB this way.

Here is how I would do this:

1) Capture the data from the Arduino ... using Bluetooth ?
2) Save the data to a Label .... set Label1.text to  Label1.text + new data element     , watch the data populate on the Android screen  then stop the data flow.
3) Save the Label text string to a TinyDB.    Once the data is in the data base you can
      plot it on a Canvas in your app.  ALL the data should plot if this is really necessary  or
      plot it somewhere else ... whatever you are doing the plotting now?   or send it to a Fusion table, then use Windows routines to plot it

...  by keeping the steps separate, you possible will not lose data.
.. by not sending data in a continuous stream to the TinyWebDB, you will not have data transmission lag.
I do not believe it is possible to send data from the Android to an Internet DB in real time and not lose data, especially at 9600 baud.

You WILL lose data when you try to do multiple things on an Android device simultaneously..I expect the cpu is not fast enough to do everything you want to do most probably.

I realize you have lots more code than shown in the blocks u posted.  If you change some things I mention, you might as well bite the bullet and start coding with AI2.

I wish I could run some test code...no Arduino here.    In your shoes, I would stop the project.  Then, start several new projects.
1) Capture the Arduino data only to the phone.  Make sure all of it is getting reported.
2)Save the nice app u just made.  Rename it step2.
3) in step2  , add a canvas and see if you can plot the data just captured.    or perhaps you do not want to plot on the Android.  At the moment, AI2's plotting capability is terrible but usable with some clever programming.
4) save step2
5) creat step3 by renaming step2
6)

Do you see what I am attempting to do with my version?  At the moment, you are trying to debug the entire project in one piece.  That almost never works.  I think you should be developing each piece of the project separately.  When a piece works; continue developing after saving your good work with a new name and creating an aia.  Continue with the next piece of the project.

Enough said.  Perhaps something I said is useful.  ..and be sure to look at the stuff I mentioned in my previous message... it looks like there may be tools there you could use...but then you would radically change your original flow model.  

As an aside, I build Windows applications that communicate with devices using serial ports and over the Internet (for fun, not profit).  

--
Steve, thanks for the great reply. I have made a ton of progress and feel closer to my goal.

Just to recap. I went ahead and redid everything step by step.
1) Captured the data from the Arduino using Bluetooth.
2) Saved the data to a Label and watched the data populate on the Android screen. 
3) Saved the Label text string to a TinyDB.  
4) Created a Fusion Table and sent the stored data to it.
5) IN PROGRESS: plot the data in the fusion table.

The good news is, I am not losing any data and I am able to capture enough data points for a clear picture of an ECG waveform. Unfortunately, now I am at a new hurdle. After some troubleshooting, I was finally able to send the data to the fusion table but they all collect in one row of the column (see the picture below) along with the word ECG:

Any suggestions on how to fix this? I feel once I do this, I can plot the data once I define an x-axis and simply view the plot on the webviewer within the app. I have also attached my block diagram.


--
Yes, you appear to making significant progress.  A clean data set..very good.

1) Captured the data from the Arduino using Bluetooth.    OK
2) Saved the data to a Label and watched the data populate on the Android screen.   OK
3) Saved the Label text string to a TinyDB.    almost OK.   I think you missed a huge opportunity here in your code to  1)label each point (1, ,2,14 or what ever) which may or may not be useful and 2) to tag each data point with the time it was collected.   Not, 12.3   but        1,  08:15:21 , 12.3  ;   08:15:22,  3.41  ;  in your label.   Do it that way and you already have two options for your x axis later stored in your DB.
4) Created a Fusion Table and sent the stored data to it.  Fusion table needs BOTH rows and columns to plot, you have a voltage column (y axis), where is your x axis column?
       You need two variables to to make a plot.  The x axis can be either TIME  or a sequence number, if the the interval between data points is constant and known.  The time can be what the Arduino knows or it can be the time received by the Android.  They might be the same;  hopefully the elapsed time between points is the same.  Since this is supposed to be an ECG, I expect that to be very important

How to use Fusion tables is actually part of the tutorial called Pizza Party. Have you done the MIT Fusion table tutorial? .... It shows how to separate stuff in bins.

    There are two ways to use the Fusion table....design it from the Android or design it from the Fusion Table site.     Do not bother attempting to do it using your Android code; MUCH simpler on the site.   Drop your project for a while and experiment with the Fusion table and the tutorials Google provides.
5) IN PROGRESS: plot the data in the fusion table.  Yes, but much easier if you get all the data to the table in its proper place

The good news is, I am not losing any data (THIS is the GREAT news)  and I am able to capture enough data points for a clear picture of an ECG waveform. Unfortunately, now I am at a new hurdle. After some troubleshooting, I was finally able to send the data to the fusion table but they all collect in one row of the column 
   Yes, the data goes to exactly where your app told it to go in the Fusion table.    How did you create the table?   The table already should have columns for   ID#, Time, Value.   You just created a table of values.

 Any suggestions on how to fix this? ... I can plot the data once I define an x-axis and simply view the plot on the webviewer within the app.

I can not see what was posted to the Android screen, so I assume the data looks exactly like the row in the Fusion table. 

I am not sure how to explain this.  Once you get your data, I see several ways the data can be read into the Fusion table.  At the moment, you have a line of voltages, with no separating character between them.  Yes, there is a space between the voltages.  A space can be used as a separating character.   Using a comma might make things easier to format the Fusion table and then plot on the webviewer (probably doable and a nice idea) .

Before you start developing your code to get it into the fusion table,   you might think about how the table should look .... rows, columns,  security access ..at the moment I can not access your table even to view it,   so, "how to fix this?"   is a bit of a problem       1-68 shows on your Fusion Table,  I guess you created the table with space for 68 rows?    .... what data is the column set to   text  or numerical?    (Sri, off the top of my head, I do not remember)... There is also a format for time.   How you define the columns determines  how you prepare the data you send from the Android.

I think your table perhaps should like this image.  It could be different easily, depending on how you will use the data.   For instance, there could be a column for Patient and Data    only , where all the data will be stored in a comma separated string (csv)  so every ECG run will be stored as a single row   OR Patient , DataID#, Time, Voltage .   where each Fusion table row will represent one data point.      You need to figure out how you want to store.  Graphing might be easier with the second case using the table tools on Windows itself.   

I do not see commas in your label data  (can u capture your Android screen?)  so assume you removed them when u sent the info to the Fusion Table.   

Do you use Skype?   Would you like to talk about this?

You are making significant progress.   I have two wishes,   you would do this in AI2  instead of AI (so we could share blocks)  and I had an Arduino. I have more ideas,
but difficult to explain because we can not interact in real time.

Smile.... this is getting better ... your are trying to learn a lot of technology.

-- 
Currently I am at work so I apologize for how quick this response is.
 How to use Fusion tables is actually part of the tutorial called Pizza Party. Have you done the MIT Fusion table tutorial? .... It shows how to separate stuff in bins.
I have been using the Pizza Party Tutorial as a basis for the Fusion Table portion per your previous suggestion. I omitted separating stuff in bins because I was having a hard time translating manual USER INPUT vs continuous SENSOR DATA INPUT in this sense. I didn't have much time yesterday to clean up the data so my main goal was to be able to at least get the Fusion Table to receive data. I'm planning on working on this today.
 Yes, the data goes to exactly where your app told it to go in the Fusion table.    How did you create the table?   The table already should have columns for   ID#, Time, Value.   You just created a table of values.
I created a new table directly from the Fusion Table site. It initially had (Text, Number, Location, Date) which I changed first to (Time, Voltage) but then ultimately just (Voltage). I did this because I wanted to see if the fusion table blocks were working and I didn't really have time data declared into any part of my block diagram to support the X-axis. I was switching the column back and forth from TEXT to NUMBER to see what would show the data being input into the table. I'm not at my project CPU at the moment so Ill have to verify what I settled on when I get home. I did manually add 68 rows because I was unsure if the app would generate the rows for me or if I would have to provide space for the data.
I can not see what was posted to the Android screen, so I assume the data looks exactly like the row in the Fusion table.
The data is actually being displayed in a column view like so:

ECG
13.70
18.29
22.88
27.47
.
.
.
so on so forth. Once again, I'll have to grab a screen capture when I get home.
  Do you use Skype?   Would you like to talk about this?
You are making significant progress.   I have two wishes,   you would do this in AI2  instead of AI (so we could share blocks)  and I had an Arduino. I have more ideas,but difficult to explain because we can not interact in real time.
 I do use skype and would most certainly like to discuss it in real time if possible. I'm in Pacific time zone and I'm assuming you are either central or eastern? Let me try to separate the data delving deeper into the pizza party tutorial. If this proves to be troublesome, I'll definitely consider just reworking it in AI2.

--
OK ...things a bit clearer.

The data is actually being displayed in a column view like so:

ECG
13.70
18.29
22.88
27.47

so that all comes from Label3 ?       That is fine.  II guess these are blocks you use to capture data into label3     marked 1  
Here u can do some interesting and valuable things.  I am not sure AI1 has a join text block.  Hopefully.

Where u have the make text text
                                          text

in AI2 it would be     join text
                                     text 
                                     text         and u can add as many text as you like.   I am not sure you could do that.   If you could, what you would do is;

  Join --- call Clock1.FormatTime
                                  instant  ---- call Clock1.Now
          --- space   or comma
          --- global ECG
         --- space or comma or semicolon      depending on how you want to pre-format what goes to the fusion table.

           so the result in the label would look something like:

 18:22:23 PM ,13.70
 18:22:24 PM ,18.29
 18:22:25 PM ,22.88
 18:22:26 PM ,27.47     that could be sent to the fusion table in such a way the rows and columns would be preserved.... a bit of coding.

If you add a counter routine, this could look like this where the number would be incremented every time the bluetooth fires.   you would need a global variable  NumberofDataPoint or something., then you would add it to the label so that:

1, 18:22:23 PM ,13.70
2, 18:22:24 PM ,18.29
3, 18:22:25 PM ,22.88
4,  18:22:26 PM ,27.47  

where you could use 1,2,3,4    or the time to plot against.    Is this where u are headed.

Oh, Pacific time///here in central... can use a real telephone...thought you might be in the UK perhaps.

--
So here's an update...

I was pulling my hair out trying to figure out why my data kept bunching up in one row. I attempted to split the data inside a list but failed horribly. I then realized that I needed to adjust the clock cycle along with the Bytes coming in and I was able to get a consistent flow of time joined with a data point. I did the whole "join text" blocks to get predetermined X and Y axes. Once I ran the program, Label 3 is displaying the data on the app in the following manner:

18:22:23 PM,
     13.70
18:22:24 PM,

     18.29
18:22:25 PM,
     22.88
18:22:26 PM,
     27.47
so on and so forth...This is not quite what I expected since I want:
18:22:23 PM, 13.70
18:22:24 PM, 18.29

18:22:25 PM, 22.88
18:22:26 PM, 27.47
Now assuming that the way I joined the text would mimic how I would make the values for the query:
(Time, Number) along with the quotify blocks, I should be able to send the data to the Fusion Table in consecutive rows for each specified column. Unfortunately, what I am now experiencing is my error notifier stating:

There has been a transmission error. 400 Bad Request. Invalid query: Expected 2 values, but got 1 for &#39;Time&#39;,&#39;Number&#39; Please try again.
I'm assuming this basically means that I'm not coding the proper syntax for the query. Any suggestions on how to fix this? I attached the updated block diagram.  
 

--
OK.. some progress.  :)

1)  What displays on your Android screen has little if no relation how the data needs to be formatted for the Fusion Table.  I mean that making the display of Label3 on your Android screen look pretty can actually make it more difficult to send the data to the fusion table.   What information you have in the label has to be parsed in order for you to place it in the Fusion Table.  Yes, you can have your cake and eat it.   One way would be to save the data to  a global ArduinoData instead of directly to Label3.   For display on the Android u would use something like     set Label3.Text to  ArduinoData ; however that may not be what you want to save to the TinyDB. (see below)


I was pulling my hair out trying to figure out why my data kept bunching up in one row. I attempted to split the data inside a list but failed horribly. I then realized that I needed to adjust the clock cycle along with the Bytes coming in and I was able to get a consistent flow of time joined with a data point. I did the whole "join text" blocks to get predetermined X and Y axes. Once I ran the program, Label 3 is displaying the data on the app in the following manner:
18:22:23 PM,
     13.70
18:22:24 PM,
     18.29
18:22:25 PM,
     22.88
18:22:26 PM,
     27.47

Yes, that is not pretty.
so on and so forth...This is not quite what I expected since I want:
18:22:23 PM, 13.70
18:22:24 PM, 18.29
18:22:25 PM, 22.88
18:22:26 PM, 27.47
You want this to display like this on your label3 on the device?   Right?

Then you have to tell ur Android to do that.  Your code, using the \n instructs to break the label just as it displays.   You need to shift some blocks around.  I think this will make it all pretty:

Actually, I did not mark that up correctly.... the Clock2 block should go above the ECG block .... sorry.   Time before data.

However, for the file you send to the Fusion table, you will want something that looks like this:

18:22:23 PM, 13.70;18:22:24 PM, 18.29;18:22:25 PM, 22.88;18:22:26 PM, 27.47;  because what you want to put in individual rows is something like this:

1  18:22:23 PM, 13.70       2  18:22:24 PM, 18.29         3  18:22:25 PM, 22.88       4  18:22:26 PM, 27.47
Now assuming that the way I joined the text would mimic how I would make the values for the query:
Bad assumption.
(Time, Number) along with the quotify blocks, I should be able to send the data to the Fusion Table in consecutive rows for each specified column. Unfortunately, what I am now experiencing is my error notifier stating:
There has been a transmission error. 400 Bad Request. Invalid query: Expected 2 values, but got 1 for &#39;Time&#39;,&#39;Number&#39; Please try again.

I'm assuming this basically means that I'm not coding the proper syntax for the query. 

Yes, that is essentially correct.   You are not sending the two values you told the Fusion table to expect.
Hmm.. this is misbehaving..... I will continue in a second post.

-- 
I decided there is a simpler way to provide advice regarding your interesting app.   I looked at your code carefully.  I decided I can use large parts of it for something I would like to do.  As a result,ECG is now 90% converted to AI2.

How are you with trying AI2?     I will send you an aia file via email.  You can load the aia into AI2 (the aia is AI2s version of the zip file); then we can talk?

I have to create my own fusion table so the new app can talk to it.  I also need to make sure I set up the data correctly for the fusion tables.   It has been a while since I have done this and I may have to adjust how I report the input file.  While doing this, I spotted several issues in your code...nothing big but why u can't get the data u want into the table.

Do you want to do this?  Send me a direct email .

--

댓글 없음:

댓글 쓰기