How to Control Electronics from a Browser Using MicroPython in Jupyter Notebook

If you want to control electronic devices, such as a relay or motor, you can do so using MicroPython with an ESP8266 and web browser. Usually, you'd program an ESP8266 using Arduino, but C++, which Arduino uses, is not always the easiest programming language for beginners to learn.


MicroPython is much simpler to program in. Plus, it's a great way to utilize Python code on a microcontroller, such as an ESP8266 or ESP32, to control basically any electronic component you want from your computer running Jupyter Notebook in a browser. If you're new to MicroPython, check out our previous guides on using it with a microcontroller; one covers creating rogue access points, while the other talks about programming an MCU over Wi-Fi.


Our Example Scenario


To help show you how MicroPython, an MCU, and Jupyter Notebook could be used together to control electronic components, we'll be using a setup that's normally very difficult to do in Arduino but very easy in MicroPython.


On a breadboard, we have our ESP8266 paired with a D1 Mini, which is plugged into a relay switch. A relay is an electronic switch similar to the single-pole wall switches that are in many of your rooms. When we send it a power signal, it switches on or off. There's a 9-volt battery attached, which will turn on the motor when we want it to.


What You'll Need


The project parts:


That's the basics of it, but when you have your D1 Mini plugged into your breadboard, ..

Support the originator by clicking the read the rest link below.