Reputation: 363
I am getting a temperature reading from my Arduino. The arduino also control 2 switches and goes through thermal cycles. What I want to do is record the temperature for every cycles. The computer need to know what "state" the arduino is in, i.e., when the cycle ends so it can generate a new graphic and store the old data. What I was thinking doing is to print in the serial an array like that: [temperature, state] The thing is that I don't really find it elegant. I'd like to know if there would be a trigger coming from the arduino that would, e.g., break a while (printing data on graphic) and produce a new one.
while True: {
produce new graph
while arduinoTrigger==false:{
plot data
}
}
Upvotes: 0
Views: 480
Reputation: 252
You can do this by sending a particular string from the Arduino, and on the other side, check if the received string matches, say, "state change"
. Otherwise, treat the string as temperature. This is assuming that the a temperature string can never be "state change"
, which will probably never happen.
You can have something like this in your python implementation:
while True:
msg = ser.readline()
if msg == 'state change':
# switch to new graph
else:
data = int(msg)
# plot data on current graph
Upvotes: 1