0

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
  }
}

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.