Copyright
MicroPython for ESP8266 Development Workshop
Agus Kurniawan
1st Edition, 2016
Copyright 2016 Agus Kurniawan
Table of Contents
Preface
This book was written to help anyone want to get started with MicroPython development for ESP8266 boards. It describes the basic elements of MicroPython development.
Agus Kurniawan
Depok, November 2016
1. Preparing Development Environment
1.1 MicroPython Boards
MicroPython is a lean and efficient implementation of the Python programming language that includes a small subset of the Python standard library and is optimised to run on microcontrollers and in constrained environments.
We can deploy MicroPython on ESP8266 boards. For instance, you can deploy on these boards:
- NodeMCU, http://nodemcu.com/index_en.html
- SparkFun ESP8266 Thing, https://www.sparkfun.com/products/13231
- Adafruit HUZZAH ESP8266 Breakout, https://www.adafruit.com/product/2471
- Adafruit Feather HUZZAH with ESP8266 WiFi, https://www.adafruit.com/product/2821
NodeMCU v2 board:
SparkFun ESP8266 Thing.
Adafruit HUZZAH ESP8266 Breakout.
Adafruit Feather HUZZAH with ESP8266 WiFi.
1.2 Electronics Components
We need electronic components to build our testing, for instance, Resistor, LED, sensor devices and etc. I recommend you can buy electronic component kit. We can use electronics kit from Arduino to be developed on MicroPython board. The following is a list of electronics kit which can be used in our case.
1.2.1 Arduino Starter Kit
Store website: http://arduino.cc/en/Main/ArduinoStarterKit
1.2.2 Fritzing
Store website: http://shop.fritzing.org/ .
You can buy Fritzing Starter Kit with Arduino UNO or Fritzing Starter Kit with Arduino Mega.
1.2.3 Cooking-Hacks: Arduino Starter Kit
Store website: http://www.cooking-hacks.com/index.php/shop/arduino/starter-kits/arduino-starter-kit.html
1.2.4 Arduino Sidekick Basic kit v2
Store website: http://www.seeedstudio.com/depot/Sidekick-Basic-Kit-for-Arduino-V2-p-1858.html
You also can find this kit on this online store.
http://www.exp-tech.de/seeed-studio-sidekick-basic-kit-for-arduino-v2
1.2.5 Grove - Starter Kit for Arduino
Another option, you can buy this kit on Seeedstudio, http://www.seeedstudio.com/depot/Grove-Starter-Kit-for-Arduino-p-1855.html .
1.2.6 DFRobot - Arduino Kit for Beginner v3
DFRobot provides Arduino kit too. You can buy it on the following website.
http://www.dfrobot.com/index.php?route=product/product&path=35_49&product_id=345
1.3 Development Tools
To develop app with MicroPython target, we can use any editor. You can learn how to install it on chapter 2.
1.4 Testing
For testing, I used NodeMCU v2 and SparkFun ESP8266 Thing boards for MicroPython on Windows, Linux and Mac.
I also used Arduino Sidekick Basic kit for electronic components and some sensor and actuator devices.
2. Setting Up MicroPython
This chapter explains how to work on setting up MicroPython board.
2.1 Getting Started
In this chapter, we learn how to get started with MicroPython board. We try to reflash the latest MicroPython firmware and then test some basic scripts. For testing, I use NodeMCU as sample for MicroPython board.
2.2 Connecting MicroPython Boards to Computer
Firstly, you connect MicroPython board to PC via USB/microUSB cable. After connected, you may get lighting on blue LED, for instance for, NodeMCU board.
If you are working on Windows platform, open Device Manager, you should see NodeMCU board detected on Ports (COM & LPT) as Silicon Labs
However, if you get a problem about NodeMCU hardware driver, you update that driver. You also can install a driver from Silicon Labs because NodeMCU v2 uses this chip, from https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx . Please download it based on your platform.
For instance, you download the driver for mac. Just follow instructions.
After installed, you verify it. For instance, on my OS X it has detected. Type this command.
ls /dev/cu*
For Linux, you can use ls /dev/tty* .
Then, you see a list of driver. This board is recognized as /dev/cu.SLAB_USBtoUART .
If you use SparkFun ESP8266 Thing, you need additional tool such as serial USB tool to communicate with ESP8266.
2.3 Flashing The Latest MicroPython Firmware
In this section, we try to flash the latest MicroPython firmware. You can get the latest MicroPython firmware https://micropython.org/download#esp8266. Download *.bin file.
In this scenario, I try to flash MicroPython firmware on Windows, OSX and Linux.