MicroPython (mac) with ESP-WROOM-02

There is a lot of information on using ESP-WROOM-02 with Arduino, but there is little information on running MicroPython, so I have summarized the procedure up to L Chika. MicroPython MicroPython is a Python3 execution environment that runs on a microcomputer board. Originally, it ran on a microcomputer board called pyboard, but it was also ported to esp8266.

Preparation

Environment construction on Mac

ESP-WROOM-02 Build an environment to write a micropython farm on the board.

pip installation

Skip if pip is already installed

python


$ curl -O https://bootstrap.pypa.io/get-pip.py
$ sudo python ./get-pip.py

This will install pip.

esptool installation

esptool is a tool to access ESP-WROOM-02 from the command line. Install using the pip installed above. $ sudo pip install esptool This is the only environment construction.

Access the board using esptool

Set IO0 of ESP-WROOM-02 to LOW to enter firmware write mode. Use USB serial to connect to your Mac. The USB serial device will be /dev/tty.usbserial-xxxx. (Xxxx depends on the USB serial device)

esptool test

Use esptool to test if you can access the board.

$ esptool.py --port=/dev/tty.usbserial-xxxx --baud 115200 chip_id
esptool.py v1.1
Connecting...
Chip ID: 0x000????

If you start esptool and get the above message, you can access the board normally with esptool. (???? changes depending on the chip ID)

Check the size of flash memory

Use esptool to check the size of the flash memory.

$ esptool.py --port=/dev/tty.usbserial-DJ00L51M --baud 115200 flash_id
esptool.py v1.1
Connecting...
Manufacturer: a1
Device: 4016

The last two digits of 4016 seem to indicate the size. For 16, the flash size is 32Mbit. I referred to the site of [here](http://flogics.com/wp/2016/09/esp8266-try -nodemcu-firmware and -micropython- /).

Writing MicroPython

The firmware can be found at the bottom of MicroPython Downloads. When I downloaded, esp8266-20160909-v1.8.4.bin was the latest.

$ esptool.py --port=/dev/tty.usbserial-xxxx --baud 115200 write_flash --flash_size=32m 0 ./esp8266-20160909-v1.8.4.bin 
esptool.py v1.1
Connecting...
Running Cesanta flasher stub...
Flash params set to 0x0040
Writing 565248 @ 0x0... 565248 (100 %)
Wrote 565248 bytes at 0x0 in 49.0 seconds (92.2 kbit/s)...
Leaving...

If you can write like this, you are successful.

Start and L Chika

Set IO0 of ESP-WROOM-02 to HIGH, put it in execution mode, and connect to the terminal with the cu command. $ sudo cu -s 115200 -l /dev/tty.usbserial-xxxx If you hit return and the > >> prompt appears, the python command line is ready to accept. hello world For the time being, hello world

>>> print ('hello world')
hello world

L Chika

Turn on the LED connected to IO4.

>>> import machine
>>> pin = machine.Pin(4, machine.Pin.OUT)
>>> pin.high()
>>> pin.low()

that's all. The reference URL was MicroPython tutorial for ESP8266.

As a sequel, I summarized the introduction of the shell. Introduction of MicroPython (Mac) shell with ESP-WROOM-02

We also added how to use DeepSleeep in MicroPython and how to get the power supply voltage. MicroPython on the ESP8266 (ESP-WROOM-02) deep sleep MicroPython on the ESP8266 (ESP-WROOM-02) Acquisition of power supply voltage

Recommended Posts

MicroPython (mac) with ESP-WROOM-02
Introducing MicroPython (Mac) shell with ESP-WROOM-02
Get started with MicroPython
Python3 + Django ~ Mac ~ with Apache
Testing HTTP requests with ESP-WROOM-32
Using OpenCV with Python @Mac
tensor flow with anaconda on mac
Get started with MicroPython (on macOS)
Introducing OpenCV on Mac with homebrew
Install python with mac vs code
[Python] Building an environment with Anaconda [Mac]
Follow active applications on Mac with Python
Build Python environment with Anaconda on Mac