Setting up an Electrodragon IoT board with MicroPython
This post explains how to install MicroPython on an ElectroDragon IoT board using a Raspberry Pi and a USB TTL cable.
From the Raspberry Pi
MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimised to run on microcontrollers
http://docs.micropython.org/en/latest/esp8266/
Check the latest stable MircoPython firmware release on https://micropython.org/download/#esp8266
From the Raspberry Pi
Tip it is much easier to restart the ESP8266 with a USB TTL cable that includes a switch.

From the Raspberry Pi
Restart the ElectroDragon IoT board in flash mode:
From the Raspberry Pi
Install minicom on the Raspberry Pi to connect and verify the installation using the below commands. See http://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/network_basics.html
Tip: To exit minicom: Ctrl-Shft-A Shft-X <enter>
From the Raspberry Pi
Install ampy, restart the ElectroDragon in normal mode and connect.
Tip: Make sure you exit minicom before using ampy
ElectroDragon Wifi IoT Relay Boards
ElectroDragon IoT boards are built on Espressif Systems ESP8266-12 F microcontrollers which include WiFi and 4 MB of flash memory and can readily run MicroPython. ElectroDragon now offer several configurations. The original AC powered dual relay version is used below. http://www.ElectroDragon.com/product/wifi-iot-relay-board-based-esp8266/Key Specifications
- Based on ESP-12F ESP8266 Wifi Board
- This relay board use one AC input, and supports two relay AC outputs.
- Use mature AC-DC power module, input voltage 85 – 265VAC
- Relay: HF32F-G-5-HS, Common – open, 10A 250VAC, 30VDC, Control 5V
- Plastic enclosure design support, package includes the PCB board, plastic case, and self-drilled screws (screws are not assembled). Case general dimension is 111*42 mm
Primary Header Pins
GND
|
5V
|
GPIO-15
|
GPIO-00
Button 2 / Flash
|
GPIO-04
|
GPIO-03
RXD
|
CHPD
3.3V
|
GPIO-13
Output Relay 1
|
GPIO-02
Button 1
|
GPIO-05
|
ADC
|
GPIO-01
TXD
|
Other Pins
GPIO-16
|
LED status
|
GPIO-14
|
DHT22
|
GPIO-12
|
Output Relay 2
|
Install the ESP flash tool
https://github.com/espressif/esptoolFrom the Raspberry Pi
sudo pip2 install esptool
sudo pip2 install esptool --upgrade
Download the MircoPython firmware

Check the latest stable MircoPython firmware release on https://micropython.org/download/#esp8266
From the Raspberry Pi
mkdir ~/working
cd ~/working
wget http://micropython.org/resources/firmware/esp8266-20170823-v1.9.2.bin
Connect the Raspberry Pi to the ElectroDragon IoT board
Using a USB TTL cable, connect the ElectroDragon IoT board as below and then to the Raspberry PiTip it is much easier to restart the ESP8266 with a USB TTL cable that includes a switch.
To put the ElectroDragon in:
- flash mode - hold BUTTON 2 (nearest the GPIO pins) when connect power 5V/GND
- normal mode - don’t hold any buttons down when connect power 5V/GND.
Flash the MicroPython firmware and verify
Erase the existing firmware
To erase the firmware, put the ElectroDragon IoT board in flash mode:From the Raspberry Pi
#execute the following commands
sudo esptool.py --port /dev/ttyUSB0 erase_flash
Flash the MicroPython firmware and verify
To install the latest MicroPython firmware, put the ElectroDragon IoT board in flash mode. You may need to repeat the below operations multiple times as it is not always successful in the first attempt.Restart the ElectroDragon IoT board in flash mode:
From the Raspberry Pi
#execute the following commands
sudo esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 esp8266-20170823-v1.9.bin
sudo esptool.py --port /dev/ttyUSB0 --baud 460800 verify_flash --flash_size=detect 0 esp8266-20170526-v1.9.bin
Check that MicroPython is installed correctly
Restart the ElectroDragon IoT Board in normal mode.Install minicom on the Raspberry Pi to connect and verify the installation using the below commands. See http://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/network_basics.html
Tip: To exit minicom: Ctrl-Shft-A Shft-X <enter>
sudo apt-get install minicom
minicom -o -D /dev/ttyUSB0
On the ElectroDragon
>>>
# Should get python prompt
# If not try Ctrl-C
# Check flash is good
>>> import esp
>>> esp.check_fw()
size: 598068
md5: cf3a503028855e9dc093a2ec3ab53634
True
# Check version is good
>>> import sys
>>> print(sys.implementation)
(name='micropython', version=(1, 9, 0))
# Optionally enable WebREPL if you want to connect over web
>>> import webrepl_setup
WebREPL daemon auto-start status: disabled
Would you like to (E)nable or (D)isable it running on boot?
(Empty line to quit)
> E
To enable WebREPL, you must set password for it
# To soft-reset micropython and restart the start-up files. Ctrl-D
# Exit minicom Ctrl-Shft-A Shft-X
Install Adafruit MicroPython Tool (ampy) on the Raspberry Pi
Adafruit MicroPython Tool (ampy) is a utility tool to interact with a MicroPython microcontroller including copying files back and forth.Install ampy, restart the ElectroDragon in normal mode and connect.
Tip: Make sure you exit minicom before using ampy
From the Raspberry Pi
sudo pip3 install adafruit-ampy
sudo pip3 install adafruit-ampy --upgrade
ampy --port /dev/ttyUSB0 ls
boot.py
ampy --port /dev/ttyUSB0 get boot.py default_boot.py
cat default_boot.py
I admire this article for the well-researched content and excellent wording. Electronic PCB Board Cloning. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.
ReplyDeleteYou have worked nicely with your insights. Lots of valuable data can be taken from your article. Genuinely it is a significant article for us.Custom Layout Training Institutes in India
ReplyDeleteExcellent post. I really enjoy reading and also appreciate your work. This concept is a good way to enhance knowledge. Keep sharing this kind of articles, Reverse Engineering PCB Board Thank you.
ReplyDeleteNice info, I am very thankful to you for sharing this important knowledge. This information is helpful for everyone. Read more info about Arduino Starter Kit for Sale. So please always share this kind of information. Thanks.
ReplyDeleteExcellent post. I really enjoy reading and also appreciate your work.engineer consultant This concept is a good way to enhance knowledge. Keep sharing this kind of articles, Thank you.
ReplyDeleteIt is what I was searching for is really informative.Global 1 Consulting LLC It is a significant and useful article for us. Thankful to you for sharing an article like this.
ReplyDelete