Conservancy, we love free software!

NodeMCU Setup (Advanced!)

These notes are for advanced users who want to work with MicroBlocks on the NodeMCU and are comfortable with the extra technical challenges involved.

The NodeMCU

The NodeMCU is an inexpensive board based on the Espressif ESP8266 module that includes a WiFi radio, 32-bit processor, 8 useable digital I/O pins, and 1 analog input pin. NodeMCU boards are available on Amazon for as little as $6. The NodeMUC doesn't have many built in capabilities (just a user LED), and installing and using MicroBlocks on it is more complex than other boards such as the BBC micro:bit, so the NodeMCU is not recommended for beginners yet. (We're working on that!)

NodeMCU Pins

There are a number of variations of the Node MCU and similar boards based on ESP8266. On my NodeMCU (a 12-E module), the MicroBlocks pin numbering does not match the numbers silk-screened onto the board. Different boards may have different pin layouts, so you'll need to Google for a pinout that matches your board.

For example, here's a pinout for a 12-E board from here:

nodeMCU12E.png

MicroBlocks uses the "GPIO" pin numbers in this diagram. For example, toggling digital pin 16 in MicroBlocks changes the state of the top-right pin in the picture (GPIO16). That also toggles the red user LED. The sense of the LED's on the NodeMCU is inverted: setting pin 16 to "false" turns the red LED on.

Some of the NodeMCU GPIO pins are used internally and cannot be used with MicroBlocks. Attempting to read or write to those pins does nothing. Only the following digital GPIO pins are available for use with MicroBlocks:

Digital GPIO pins: 2 (blue LED), 4, 5, 12, 13, 14, 15, 16 (red LED)

The Node MCU has a single analog input pin, marked "ADC0" on the pinout (top-left in the picture). That pin is input-only; it can't be used as an output.

Node MCU Setup

1. Install esptool.py

To install MicroBlocks on a NodeMCU, you'll use a Python program called esptool.py. Different platforms use different commands to install Python programs. For Mac OS you can do the following:

sudo pip install esptool

2. Download the MicroBlocks virtual machine for the NodeMCU

To download the latest version, go to this page on the MicroBlocks repository and click the "View raw" link. In most browsers, that will actually download, not view, the file. The file vm.ino.nodemcu.bin will be downloaded.

3. Install MicroBlocks on your NodeMCU

Plug in your NodeMCU board and run:

esptool.py write_flash 0 vm.ino.nodemcu.bin

It should find the correct serial port automatically. You'll see a bunch of stuff print in the terminal as the install happens. The entire process takes 25-30 seconds.

4. Connect

Start MicroBlocks, click the "Connect" button, and select the serial port. The indicator should turn green.

To verify that everything is working, try the following:

SetUserLEDBlock.png

The user LED on your board should light up, showing that the board is connected. You're ready to code!