Setting up a serial data stream in MicroPython

As we saw in the hardware architecture for this project, we are going to be using a serial port on the MicroPython device to send a stream of known data to the visualizer to plot. Once we've tested and debugged both sets of code, we can update our MicroPython device to send real sensor data. For now, we just need to send known values that we can use for testing:

  1. Before we do anything, we need to make sure that we import the Universal Asynchronous Receiver/Transmitter (UART) module from pyb and set the emergency exception buffer size. Just like we did in previous projects, this can be done using the following code:
import micropython                      # For emergency exception bufferfrom pyb import UART# Buffer ...

Get MicroPython Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.