Websocket graph

16 Feb 2014

Hi,

I have recently been experimenting with the mbed websocket and managed to send some text to the server. Next I would like to display a real time graph of a analog input. The code below is my attempt to this.

include the mbed library with this snippet

#include "mbed.h"
#include "EthernetInterface.h"
#include "Websocket.h"

AnalogIn ain(p20);

int main()
{

char json_str[100];
int fecg;

EthernetInterface eth;
eth.init();
eth.connect();
printf("IP Address is %s\n\r", eth.getIPAddress());

Websocket ws("ws://sockets.mbed.org:443/ws/ecg/wo");
ws.connect();

while (1)
    {   
    fecg = ain/50;
    sprintf (json_str, "{\"id\":\"ECG\",\"ecg\":%d\"}", (int)fecg);
    ws.send(json_str);
    }  
}    

As I understand it, I should be able to send data to the server, http://sockets.mbed.org/ecg, in json and it would display a graph automatically with me having to code anything for the server. Is this correct and so did I make a mistake in the code above or am I completely wrong and have to program the server using eclipse since I am on windows?

Thanks

03 Apr 2014

Did you ever figure the graph out? I'm wanting to do the same thing but lack practical graphics and html / web programming

04 May 2014

not yet, will post update when i do

19 May 2014

Have you looked at Jchart2D?

I want to do something similar as well. I have the real time plot looking nice, but I haven't started the JSON part yet.