Dependancies
Buy the components
blinky.py
from machine import Pin
import time
led_pin = 3 # Default on-board RGB LED GPIO08 does not work
led = Pin(led_pin, Pin.OUT)
for i in range(10):
led.on()
time.sleep_ms(500)
led.off()
time.sleep_ms(500)
print("Blink ", i+1)
PYTHON_FILE=blink.py
BIN_FILENAME=ESP32_GENERIC_C3-20231005-v1.21.0.bin
PORT?=/dev/cu.usbserial-*
.PHONY: help default upload log
default: upload
help: ## Show help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% 0-9a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
upload: ## Erase flash and then upload the micropython binary
@echo "Ensure you plug in the board into the USB port"
@ls /dev/cu.*
esptool.py --chip esp32c3 --port $(PORT) erase_flash
esptool.py --chip esp32c3 --port $(PORT) --baud 460800 write_flash -z 0x0 $(BIN_FILENAME)
log: ## Access the serial monitor with rshell
@ls /dev/cu.*
@echo "Ensure you plug in the board into the USB port"
@echo "Then upload the python file with command: cp blinky.py /pyboard"
@echo "Then entier the REPL with command: repl"
@echo "Then enter command: import blinky"
rshell --port $(PORT)
rollback:
@ls /dev/cu.*
@echo "Ensure you plug in the board into the USB port"
esptool.py --port $(PORT) erase_flash
@echo "Flash in ESP-IDF blinky"
The default RGB LED on-board which is GPIO8
does on work. So, wire up a simple LED to GPIO3
with a 1k
resistor to the ground.
USB
port to know the port number
$ ls /dev/cu.*
/dev/cu.SLAB_USBtoUART /dev/cu.usbserial-1410
*.bin
file for the board esp32c3-*.bin
esptool.py --chip esp32c3 --port /dev/cu.SLAB_USBtoUART erase_flash
esptool.py --chip esp32c3 --port /dev/cu.SLAB_USBtoUART write_flash -z 0 _tutorials/code/blinky-micropython-esp32c3/esp32c3-*.bin
pip install rshell
ls /dev/cu.*
/dev/cu.usbserial-1410
rshell -p /dev/cu.usbserial-1410
blink.py
in rshell
cp blinky.py /pyboard
repl
import blinky
or whatever the filename is