Video Tutorial (Optional)
Watch first if you want to see the Thonny Plotter workflow end to end.
Project Overview
In this guide, you use a Raspberry Pi running MicroPython and Thonnys Plotter tool to plot sensor data in real time using simple print() statements.
Thonny includes a built-in plotting tool that can be integrated directly into your output so you can visualize data streams quickly without installing any extra packages.
- Time: 5 to 10 minutes
- Skill level: Beginner
-
What you will build: A live-updating plot in Thonny driven by your MicroPython
print()output
Parts List
From ShillehTek
- None required for this tutorial
External
- Raspberry Pi running MicroPython
- Thonny IDE (with the Plotter tool)
- Optional: any sensor or data source producing a numeric stream
Note: Thonny Plotter is intended for simple numeric data streams. Multi-dimensional data is not supported by this tool.
Step-by-Step Guide
Step 1 - Open the Thonny Plotter tool
Goal: Enable the Plotter panel so Thonny can graph values from your program output.
What to do: In Thonny, go to View > Plotter.
You should see an empty plotter appear on the bottom right.
Expected result: The Plotter panel is visible and ready to graph incoming values.
Step 2 - Output labeled values using print()
Goal: Send values to the Plotter using a standard MicroPython print() statement.
What to do: Print your latest datapoints in your program. You can plot multiple graphs on the same plotter by including multiple labeled values in one print statement.
Code:
print("Data 1", datapoint_1, "Data 2", datapoint_2)
Expected result: Each time this line runs, Thonny Plotter updates the plot with the newest values.
Step 3 - Understand what the Plotter is showing
Goal: Know how labels and datapoints appear in the legend and plot.
What to do: In the print statement above, Data 1 and Data 2 are the labels shown in the legend, while datapoint_1 and datapoint_2 are the values from your data stream.
The data will resemble the following.
Expected result: You can match each plotted line to its label and confirm your data stream is updating in real time.
Step 4 - Use the print() output in a loop for streaming data
Goal: Continuously plot live sensor or application data.
What to do: Use the same labeled print() approach inside a loop mechanism so new values are printed repeatedly.
Expected result: The plot continuously updates as your loop prints new datapoints.
Conclusion
You now know how to plot a simple real-time data stream in Thonny using a Raspberry Pi (MicroPython) and the built-in Plotter tool, with no extra packages required. This is a convenient way to visualize sensor data quickly while developing.
Want the exact parts used in your next Raspberry Pi sensor build? Grab what you need from ShillehTek.com. If you want help tailoring data collection, visualization, or a full IoT prototype for your project, check out our IoT consulting services.
Please consider subscribing to the channel if you find this content useful. Thanks!