Micropython : esp32 #1 hello world

python

Development environment

reference

Arch linux

windows 10 WSL2 installation method

arch mac : Initial setting #1 install

Install esptool

reference

mkdir micropython

cd micropython

download Firmware

Be sure to download to the current hierarchy

sudo pacman -S esptool

sudo esptool.py flash_id

esptool.py v3.0
Found 1 serial ports
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WD (revision 1)
Features: WiFi, BT, Dual Core, Coding Scheme None
Crystal is 40MHz
MAC: 30:ae:a4:9d:51:1c
Uploading stub...
Running stub...
Stub running...
Manufacturer: 20
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...

serial poat /dev/ttyUSB0

Check the part of /dev/ttyUSB0

sudo esptool.py --port /dev/tty??????? erase_flash

Because it is /dev/ttyUSB0 in my development environment

sudo esptool.py --port /dev/ttyUSB0 erase_flash

esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WD (revision 1)
Features: WiFi, BT, Dual Core, Coding Scheme None
Crystal is 40MHz
MAC: 30:ae:a4:9d:51:1c
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 8.5s
Hard resetting via RTS pin...

sudo esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 esp32-idf3-20210202-v1.14.bin

esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32-D0WD (revision 1)
Features: WiFi, BT, Dual Core, Coding Scheme None
Crystal is 40MHz
MAC: 30:ae:a4:9d:51:1c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Compressed 1445632 bytes to 925476...
Wrote 1445632 bytes (925476 compressed) at 0x00001000 in 82.2 seconds (effective 140.8 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

REPL connection

sudo pacman -S picocom

sudo picocom /dev/ttyUSB0 -b115200

Exit picocom

Hold Ctrl + a Then release. Then hold Ctrl + x

add main.py in ESP32

yay -S adafruit-ampy

sudo ampy -p /dev/ttyUSB0 get boot.py

Output the contents of boot.py contained in the microcomputer

# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
import webrepl
webrepl.start()

Hello world in mycom

touch main.py

micro main.py

import machine
import time

pin13 = machine.Pin(13, machine.Pin.OUT)

while True:
  pin13.on()
  time.sleep_ms(500)
  pin13.off()
  time.sleep_ms(500)

sudo ampy -p /dev/ttyUSB0 put main.py

Upload main.py to the microcontroller

ampy Cheet sheet

sudo ampy -p /dev/ttyUSB0 ls

List display

sudo ampy -p /dev/ttyUSB0 get ??????

Output the contents of ??????

sudo ampy -p /dev/ttyUSB0 put ??????

Upload ??????

sudo ampy -p /dev/ttyUSB0 rm ??????

Remove ??????

Board schematic

key

ESP32/io13 → LED anode(+, Long leg) --| LED cathode(-、Short leg) → 470Ω resistor → ESP32/GND

key

reference image

Microcomputer Boot or Reset Press the switch to execute

twitter reference image

Success if the LED flashes

thank you

Thank you for watching until the end. I'm glad if you can use it as a reference.

Thank you for Helping

Give money to us for Amazon gift

We will continue to update useful information. I am delighted to jump to your help. Thank you very much.