goatchurchprime / jupyter_micropython_kernel

Jupyter kernel to interact with a MicroPython/ESP8266 over the serial REPL
BSD 3-Clause "New" or "Revised" License
149 stars 33 forks source link

Streaming of sensor output to another notebook script or a file #30

Open goatchurchprime opened 6 years ago

goatchurchprime commented 6 years ago

The Arduino/Processing combination provided the capability to print the readings of a sensor from a loop to the serial.out and direct it to a processing script that parsed the numbers and created a realtime graph.
https://itp.nyu.edu/physcomp/labs/labs-serial-communication/serial-output-from-an-arduino/

Note that in the implementation it takes two separate programs to make this happen.

This could have been done using multiple kernels in the same notebook, but this kind of thing didn't work out so well in practice: https://github.com/jupyterhub/jupyterhub/issues/202

You could still do this using a different notebook page that could either read from a file, serial socket or websocket that's being filled by a micropython script/cell contents from the first notebook page.

(Graphing numbers that were printed to the serial buffer was seen as so fundamental it got put into the IDE https://www.youtube.com/watch?v=Q7rJkEjdoYE )

The following workflow could then be supported: 1) raw sensor data streamed to python in a notebook where it can be plotted using matplotlib and analysed using scipy 2) various ARIMA-type filters applied to the sensor data to identify the underlying levels of noise and necessary sample rates 3) the filter with the best constants could be implemented in micropython and loaded into the board so we get clean properly understood sensor data 4) quality and application of sensor data massively improves because we're no longer hacking filters into the sensors blindly