Awesome Open Source
Awesome Open Source

Micropython Tutorial for Wemos D1 Mini

All examples are for Wemos D1 Mini, WS2812B RGB Shield (NeoPixel) and DHT Pro Shield.

Student prerequisities

  • Python knowledge
  • Micro USB cable
  • Python 3 installed
    • If you have Python 2 installed you can get into problems mixing Python versions. You must use Python 3. Check what is default version of Python on your system.
  • Python IDE installed
  • Git client (optional)


Computer setup


  • Internet connection
  • Install serial terminal
    • Windows: Putty
    • Linux, Mac: Use screen or minicom tool
  • Install ampy, install instruction
    • Add ampy to PATH
  • Install drivers for CH340 (Mac, Windows < 8.1)


  • add your user to dialout user group ( usually sudo usermod -a -G dialout yourUsername )
  • log out/log in to make the change applied to your user
  • to make sure that you'll be using python3 environment for workshop, clone the repository and create a python3 virtualenv
    • Clone the repo: git clone
    • Go to directory: cd Micropython
    • Create python3 virtualenv: python3 -m venv <absolutePath>/Micropython/venv
    • Activate the virtualenv: source ./venv/bin/activate
    • Update pip and setuptools: pip install pip setuptools --upgrade
    • Install python tooling for workshop: pip install esptool adafruit-ampy

Firmware update

First you need to upload Micropython to ESP8266 chip.

Firmware for ESP8266

Windows: NodeMCU Flasher

Documentation and source code

Instalation (if it's not already installed)

pip install esptool

Example how to use it

It is important to erase flash first.

Windows --port COM7 erase_flash --port COM7 write_flash -fm dio 0x000000 esp8266-20170823-v1.9.2.bin

Linux -p /dev/ttyUSB0 erase_flash -p /dev/ttyUSB0 write_flash -fm dio 0x000000 <downloaded ESP8266 bin file>

First script

Interactive prompt using serial terminal

Connect device using USB cable to your computer. Device will present as serial port. On Windows it will be COMx. On Linux and Mac it will be /dev/ttyUSBx. x is number.

Open your serial communication appliction and connect to right serial port using baudrate (speed) 115200. After you connect you will probably need to press enter to see promt >>>. No it works es Python interactive console on standard computer.

Linux - use for example minicom -s and set the correct USB serial port path, then exit (not exit the minicom)

Control LED on ESP8266 chip. LED is connected on pin 2 to VCC. You control ground (0 - on, 1 - off). LED is located close antena.

import machine
pin = machine.Pin(2, machine.Pin.OUT)

Upload script using ampy

Scrip name:

Close interactive prompt.

Example for Windows. Use your serial port number.

ampy --port COM14 run

Example for Linux and Mac. Do not forget to use full path to your serial port.

ampy --port /dev/ttyUSB0 run

File system

Documentation ampy

Startup scripts

  • - runs automatically after start
ampy --port COM4 put
ampy --port /dev/ttyUSB0 put

DHT22 (DHT11) and RGB LED

Using hardware drivers

How it works with pins

Read temperature and humidity

What is it Neopixel LED and how it works

Control Neopixel RGB LED

Create simple thermometer using RGB LED and DHT11 - temperature is showed using colors (for example red hot, blue cold)

HTTP protocol

How it works


HTTP Headers



Explain Wi-Fi modes - access point vs. client

Connect to local Wi-Fi

Download website Connect to Wi-Fi first!


Create ThingSpeak Account

Create Channel

Send data from DHT11 to channel


How to use Access point mode

Run this code to find mac address of your board.

import network

wlan = network.WLAN(network.STA_IF) # create station interface       # activate the interface
print(":".join(map(lambda x: "%02x" % x, wlan.config('mac'))))

Open list of available Wi-Fi and connect to Wi-Fi named MicroPython-xxxxxx where xxxxxx is part of MAC address. Password is micropythoN. IP addres of board is

Create webserver

Important: There is bug in ampy tool. It is recommended to upload code as using put command instaed of to try run it using run command. Do not forget restart ESP8266.

Create web server showing current temperature

Crete web server controlling on board LED

Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Python (805,485
Led (9,353
Esp (8,425
Serial (7,935
Rgb (4,986
Dht (1,604
Micropython (1,552
Neopixel (888