# Use Dynamic[] with DeviceExecute[] to Display Data h?

Posted 2 months ago
301 Views
|
4 Replies
|
3 Total Likes
|
 Hello, I am using an Mathematica to process code within an Arduino that in the end will display the current temperature of the thermocouple attached. I can run DeviceExecute and get a temperature. However, I have been trying In[30]:= Dynamic[temp, UpdateInterval -> 0.5] Out[30]= Dynamic[23.25, UpdateInterval -> 0.5] to no avail, as the temperature is not output in real time, only when I request it using DeviceExecute.Any thoughts as to get data real time without having to run the command?
Answer
4 Replies
Sort By:
Posted 2 months ago
 Dynamic is spelled wrong. But what is wrong with using deviceexecute?
Answer
Posted 2 months ago
 It was spelled right when I attempted it code, believe me. I don't want to have to use DeviceExecute to get the temperature. I am aiming to collect temperatures every 10 seconds or so for nearly 24 hours.
Answer
Posted 2 months ago
 Sorry, but I had to assume you spelled it wrong because you showed an input and corresponding output with the misspelling before editing it.As to your question, You have given no details of your code so I can only give you the general workflow...Look at ScheduledTask and set your read to happen every 10 seconds. the workflow should look like this: Use DeviceOpen to make a connection to the Arduino Set up a function to read the temperature (using DeviceRead if your Arduino code and hardware are setup to read an analog port directly or DeviceExecute if you need to run a remote command to get the temperature) Execute ScheduledTask to cause your function to run periodically on a schedule, setting the temperature to a variable (say "temperature") Use Dynamic to display the constantly updating temperature variable with Dynamic[temperature]  or a more elegant variation -- Setting a nice background graphic or Font, color, etc.You can log your temperature history by having the scheduled task append to a variable (say "tempLog"). Your Dynamic can then stay the same (showing the last value of temperature) or be updated to Dynamic[tempLog[[-1]]] When you are done you should stop the ScheduledTask and close the Device.I hope this helps.Regards,Neil
Answer
Posted 2 months ago
 I got it to work with your help. I very much appreciate it. Regards
Answer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments