Skip to content

jinju-lee/ESP32-micropython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP32-micropython

MicroPython on ESP32 boards

Preparation of development environment

1. Set up Toolchain

$ sudo apt-get install gcc git wget make libncurses-dev flex bison gperf python python-serial

(64-bit Linux)
$ mkdir -p ~/esp
$ cd ~/esp
$ wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
$ sudo tar zxvf xtensa* -C ~/esp

$ sudo gedit ~/.bashrc
맨 밑에 export PATH=$HOME/esp/xtensa-esp32-elf/bin:$PATH 추가

터미널 하나 더 켜서
$ echo $PATH
/xtensa-esp32-elf/bin 확인

+++ Install git 
$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt-get update && sudo apt-get dist-upgrade
$ sudo apt-get install git-core
$ git version

2. Get ESP-IDF

$ cd ~/esp
$ git clone --recursive https://github.com/espressif/esp-idf.git
$ cd ~/esp/esp-idf
$ git submodule update --init --recursive

$ sudo gedit ~/.bashrc
맨 밑에 export IDF_PATH=$HOME/esp/esp-idf$IDF_PATH 추가

$ echo $IDF_PATH
/esp/esp-idf 확인

3. Start a Project

$ cd ~/esp
$ cp -r $IDF_PATH/examples/get-started/hello_world .

$ ls -al /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Aug 15 22:33 /dev/ttyUSB0
$ id
uid=1000(pearl) gid=1000(pearl) groups=1000(pearl),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare)
: dialout에 속해있지 않으므로 권한을 준다.
$ sudo usermod -a -G dialout $USER
$ sudo reboot

$ cd ~/esp/hello_world
$ make menuconfig

image

Serial flasher config --> Default serial port --> /dev/ttyUSB0

4. Build and Flash

$ make flash
$ make monitor

Install MicroPython

1. Install MicroPython ( latest version )

http://micropython.org/download#esp32

$ wget http://micropython.org/resources/firmware/esp32-20180817-v1.9.4-465-g056e0b629.bin

2. Install esptool

$ sudo apt install python-pip
$ sudo pip install esptool
$ ls -al /dev/ttyUSB0
$ python -m esptool --port /dev/ttyUSB0 flash_id
$ esptool.py --chip esp32 -p /dev/ttyUSB0 erase_flash
$ esptool.py --chip esp32 -p /dev/ttyUSB0 write_flash -z 0x1000 esp32-20180817-v1.9.4-465-g056e0b629.bin
$ sudo apt-get install screen
$ sudo screen /dev/ttyUSB0 115200

3. Install ampy

$ sudo pip install adafruit-ampy
$ sudo pip install adafruit-ampy --upgrade

4. Create a MicroPython module

$ gedit blink.py

# screen과 동시 사용하면 작동하지 않음
$ ampy -p /dev/ttyUSB0 run blink.py
$ sudo ampy -p /dev/ttyUSB0 run blink.py

$ ampy -p /dev/ttyUSB0 put blink.py
$ sudo ampy -p /dev/ttyUSB0 put blink.py
$ ampy -p /dev/ttyUSB0 get blink.py
$ sudo ampy -p /dev/ttyUSB0 get blink.py

>>> import os
>>> os.listdir()
['boot.py', 'blink.py']

*** 'boot.py'에 넣으면 재부팅시 실행 ***

About

MicroPython on ESP32 boards

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages