Pages

Monday, 8 July 2019

MicroPython in Jupyter Notebook


Some of the favourite tools that I have been using over the last year have been Jupyter Notebook for the study of data analysis and machine learning, and MicroPython runtime on ESP32 micro-controllers.

I recently came across the MicroPython kernel for Jupyter which enables remote interaction with ESP8266 and ESP32 micro-controllers running MicroPython. Installation is straight forward. You will need Python 3.6 or higher installed on your laptop.

From the shell command to install the MicroPython kernel for Jupyter run:

    pip install jupyter_micropython_remote

Next register the kernel with Jupyter:

    python -m mpy_kernel.install

And that should be it!!! Run Jupyter notebooks:

    jupyter notebook

You should now have a 'MicroPython Remote' option when creating a new Jupyter notebook.


Connect your ESP32 board with a USB cable to your laptop. Before using the notebook you will need to establish a connection to your ESP32 board. In the first cell of the new notebook run (replace device with the port connected to your ESP32 eg. COM4):

    %connect COM4 --baudrate=115200

If the connection fails check that you are using the correct device port and that there are no other applications with an open connection to the device (eg. putty). To check that your notebook is connected to the ESP32, in a new cell run:

    import os
    print(os.uname())

   (sysname='esp32', nodename='esp32', release='1.11.0', version='v1.11-126-g7c2e83324 on 2019-07-07', machine='ESP32 module with ESP32')



No comments:

Post a Comment