Add graphs to your IoT projects

I’m building a trombone controller. And why not? I’m using a distance sensor to track the position of the trombone slide. The output is a bit noisy. But how noisy? A graph would help, but how do I get that? Very easily as it turns out. I just added a print statement to my Circuit Python application:

print(raw,",",average)

This prints out my raw and averaged values with a comma between them. Then I used Thonny to run the program in the trombone for a while and moved the slider. Then I stopped the program, copied the output of the terminal window into notepad and saved it with the file extension “.csv”. (Comma separated values).

Then I opened the file with Excel (other spreadsheets are available) and made the above graph. It shows how my rolling average (the red trace) cleans up a lot of noise but makes the values lag slightly (look at the how the red trace rises slightly after the blue one).

If you aren’t sure what your signals look like this is a very easy way to do it. The Arduino IDE has a graphing feature built in that I’ve used once or twice, but there’s nothing like dropping your values into a proper spreadsheet for analysis. And it is very easy to do using the magic of cut and paste.