I have a project where I need to log data on a file on a computer, which is connected to an arduino, which will read sensors.
I played around with reading the serial port using python. The Arduino just does a loop where it increments a variable by one, and prints the variables' value to the serial port. But, when I read the data from the port in python, the data I get is old(from before the python program even started). Also, when I start the python program again, it starts with the old data (i.e. 1,2,3,4...). Python has no built-in way to read serial ports, so I installed PySerial[URL].
How do I get the latest data that is printed to the serial port?
Also, could someone clarify how the serial ports work?
Thanks,
Ben
I played around with reading the serial port using python. The Arduino just does a loop where it increments a variable by one, and prints the variables' value to the serial port. But, when I read the data from the port in python, the data I get is old(from before the python program even started). Also, when I start the python program again, it starts with the old data (i.e. 1,2,3,4...). Python has no built-in way to read serial ports, so I installed PySerial[URL].
How do I get the latest data that is printed to the serial port?
Also, could someone clarify how the serial ports work?
Thanks,
Ben