Plotting the incoming data stream

We now have all the pieces that we need in order to display our sensor data in real time; a figure to plot the data on and a serial data stream to retrieve the data from. The only thing missing now is the code necessary to connect these two pieces. We are going to use the animations feature of Matplotlib in order to this.

The animation feature essentially allows us to create a separate thread that will run on the host for each figure that we want to update. We select the figure that will be updated, the function that will be called, and the interval that we want the plot to be updated at. I've found that on my host machine, updating any faster than a few times per second causes a fair amount of lag if I want ...

Get MicroPython Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.