Message Boards Message Boards

How can I make dynamic or live gauges from serial data stream?

Posted 9 years ago

Newish to Mathematica, first post, yadayada...

So I have an Arduino pushing serial data in super simple format (Arduino code snippet is Serial.println(Analog0_value);)

I've opened the comport in Mathematica, interpreted the input stream and can display a live/dynamic number from the Arduino. But...I can't get the live behavior into a simple Guage!? what gives?

    port = "/dev/tty.usbmodem1411"
    dev = DeviceOpen["Serial", {port, "BaudRate" -> 9600}]

    out := Dynamic[FromCharacterCode[DeviceReadBuffer[dev, "ReadTerminator" -> 10]]]

So far so good: out shows a live value that corresponds to the analog value on Analog0 input of the Arduino. now the fail: AngularGauge[out, {0, 100}] Any permutation I've tried I never get the gauge to light up with my live data. I may get just (changing number here),{0,100} for example.

Thoughts!?

POSTED BY: Leif Summerfield
2 Replies

M -It's good to see live data being so verbosely plotted, nice job! I just found the debug note telling me what I'm doing wrong...duhhhh

Something about (i'm guessing) the command terminator is not getting process properly. I get this" Tag FromCharacterCode in FromCharacterCode[{49,51,13}] is Protected. >> "

Which, silly me I was trying to plot a String...not a number. So one "ToExpression" later and Bingo!!! I'm plotting live.

Thanks for your examples, and keep up the good work.

POSTED BY: Leif Summerfield

Hi there,

perhaps this post helps:

http://community.wolfram.com/groups/-/m/t/344278

Cheers,

M.

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract