How to plot raw sensor data in micropython?

Hey Hi. Nice tutorial. Can you please let me know how you are plotting? because I am trying to plot the raw sensor data of MPU6050 through Pico. Any hint related to plotting will be much helpful.

2 Likes

Hi @SUSMITA217320 Susmita - welcome to the forums :smiley:

In thonny, open the plotter with View > Plotter

Now, anything you print will be plotted. You have to print the same message over and over eg.

# This will plot
print('My values {}   {}   {}'.format(value1, value2, value2)

The following example will not plot, because the text pattern is broken up.

# This will not plot, since the text in the printed messages is changing
print('First value {}'.format(value1)
print('Second value {}'.format(value2)

Hope that helps. best of luck with your projects :smiley:

4 Likes

Hi Michael,

Thanks for the Welcome and reply. The reply is really helpful and did work for me. However, as a viewer, I have a request. Can you please make a video on how to read raw sensor data through PICO and store it in CSV and then make a continuous plot with animated matplotlib. Is it possible?

Thanks,
Susmita

1 Like

Our guide on the Makerverse MicroSD card adapter goes into datalogging a bit. You can use the same code to log csv data either to the Pico’s flash memory, or external storage as shown.

As for matplotlib and live plots - this is probably only available for something like Raspberry Pi
you might be able to use matplotlib to create the graphs needed to eg. drive an OLED display from the Pico but we’re getting pretty specific here.
My advice would be to take small steps. Start by datalogging, then plotting on your computer.

1 Like