Set Up MicroPython on NodeMCU on MacOS Mojave and higher

Getting Started Sep 30, 2019

Installing on the MacOS requires following software

Step 1 : Installing XCode (This is required on the MacOs for future installation in the following setups.)
XcodeIcon_2x

Installing MacPorts

MacOS Package Install

Step 2 : Download and install the Package MacPorts

OR

Source Install

Step 2 : Download MacPorts and run the following commands in the terminal.

If everything works fine then run the command below to confirm macports has been installed on MacOS.

port version

This will output :

Version: 2.6.0
cd MacPorts-2.6.1/
./configure
make
sudo make install

Installing Virtual COM Port (VCP)

The CP210x USB to UART Bridge Virtual COM Port (VCP) drivers are required for device operation as a Virtual COM Port to facilitate host communication with CP210x products. These devices can also interface to a host using the direct access driver.

Step 3 : Installing CP210x VCP Driver
2019-10-04_02-56-54-1

Step 4 : Open the downloaded folder and install the driver

2019-10-04_03-05-43

Step 5 : If you have got the following output, GREAT! your driver is installed.

2019-10-04_03-25-44

Step 6 : Drag the driver app (displayed in the above pic) to the application folder.

Step 7 : Now Open the terminal and search for SLAB_USBtoUART using the following command.

ls /dev/tty*

Screenshot-2019-09-30-at-1.33.51-AM

If you find the above file then go to next step, if not try reinstalling the driver and PLUG IN THE NodeMCU then try again.

Voila ! Now you are ready to use the NodeMCU

Getting a MicroPython REPL prompt

REPL stands for Read Evaluate Print Loop, and is the name given to the interactive MicroPython prompt that you can access on the ESP8266. Using the REPL is by far the easiest way to test out your code and run commands.

There are two ways to access the REPL: either via a wired connection through the UART serial port, or via WiFi.

REPL over the serial port

To access the prompt over USB-serial you need to use a terminal emulator program.

On Mac you can use the built-in screen program or alternatively you can also install picocom

screen /dev/tty.SLAB_USBtoUART -b115200

OR

picocom /dev/tty.SLAB_USBtoUART -b115200

Once you have made the connection over the serial port you can test if it is working by hitting enter a few times. You should see the Python REPL prompt, indicated by >>>.

Now you are ready to play with the NodeMCU

Testing the NodeMCU

In the REPL run these commands :


print("Hey, I am ESP8266")

2019-10-04_08-42-23

Quitting the REPL

Ctrl-A + Ctrl-Q

Frequently Asked Questions

  1. I used screen command, how to quit it?
    Case : 1
    If you are on the screen and want to quit
    Image after using screen
    Use this command :
    ctrl-A + ctrl-\
    It will then ask you to confirm :
    confirmation
    Type y and press Enter
    Case : 2
    If you have quit the terminal and now unable to run picocom
    2019-10-03_01-43-47
    Use the command in the terminal
    lsof | grep screen
    
    2019-10-03_01-56-16
    screen -x 26778 # 26778 is the Process Id
    [screen is terminating]
    
    now again repeat the process in the case: 1

Resources:

Note:

Please do let us know if we are missing any topic or you want us to elaborate any topic, comment below and subscribe to be updated.