SamuZai
Pybricks
Pybricks

patreon


Data logging with Pybricks

Did you know you can do experiments and data analysis with Pybricks? A teacher recently asked us about it, so we thought we'd share it here as well.

You can see how it works in the example above. By configuring the print block to print multiple values, you get columns of data in the output window. You can copy the data to your favorite spreadsheet editor for visualization and further analysis.

In this experiment, we used the time as the first column, which becomes the x-axis for both of the other values on the y-axis (angle and reflection).

Since you can print any value, you are not limited to logging sensor values. You could also log the results of your own calculations to verify that they give the expected output.

Tip: If you clear the output before you run your program, you can right-click and choose select all to conveniently copy everything to your spreadsheet editor.

Data logging with Pybricks

Comments

Right-click on it and choose 'Clear'.

Laurens Valk

I've looked several times before... How do you clear the output window?

Alexander Bell

The output is directly given in the output pane. This ensures you never run out of memory. So you can print very many lines. So this approach doesn't store a file on the hub itself.

Laurens Valk

Very nice use case. But correctly understood: I pull a copy from the pyBricks log file - creating a log file (e.g. *.csv) in pyBricks with remanent data storage for later retrieval is not possible? 🧐

chris


More Creators