|
| 1 | +[esp32-micropython on PyPI](https://pypi.org/project/esp32-micropython/0.2.4/) • [GitHub repo](https://github.com/laelhalawani/esp32_micropython) |
| 2 | + |
| 3 | +I automated the tedious steps of flashing and managing files on ESP32-C3 boards with a simple CLI tool. |
| 4 | + |
| 5 | +1. Install the utility: |
| 6 | +```bash |
| 7 | +pip install esp32_micropython |
| 8 | +``` |
| 9 | + |
| 10 | +2. Connect your board via USB-C. |
| 11 | +- Verify it appears under “Ports (COM & LPT)” in Device Manager. |
| 12 | +- If it keeps reconnecting, hold the BOOT (power) button while plugging in. |
| 13 | + |
| 14 | +3. List available ports: |
| 15 | +```bash |
| 16 | +esp32 devices |
| 17 | +``` |
| 18 | + |
| 19 | +4. Select your board’s port (example uses COM5): |
| 20 | +```bash |
| 21 | +esp32 device COM5 --force |
| 22 | +``` |
| 23 | + |
| 24 | +5. Flash MicroPython firmware: |
| 25 | +```bash |
| 26 | +esp32 flash |
| 27 | +``` |
| 28 | +By default, this downloads and installs the official USB-enabled build. |
| 29 | +To use a custom firmware: |
| 30 | +```bash |
| 31 | +esp32 flash https://example.com/your_firmware.bin |
| 32 | +``` |
| 33 | + |
| 34 | +6. Verify the connection (no `--force` needed if already flashed): |
| 35 | +```bash |
| 36 | +esp32 device COM5 |
| 37 | +``` |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## Uploading files |
| 42 | + |
| 43 | +### Upload a single file to the root |
| 44 | +```bash |
| 45 | +esp32 upload main.py |
| 46 | +``` |
| 47 | +Result on ESP32: `/main.py` |
| 48 | + |
| 49 | +### Upload a single file to a specific remote directory |
| 50 | +```bash |
| 51 | +esp32 upload utils.py lib |
| 52 | +``` |
| 53 | +Result on ESP32: `/lib/utils.py` (directory `lib/` created if needed) |
| 54 | + |
| 55 | +### Upload contents of a local directory to root |
| 56 | +```bash |
| 57 | +esp32 upload local_project/ |
| 58 | +``` |
| 59 | +Assuming `local_project/` contains `file1.py` and `subdir/file2.py`, result: |
| 60 | +``` |
| 61 | +/file1.py |
| 62 | +/subdir/file2.py |
| 63 | +``` |
| 64 | + |
| 65 | +### Upload contents of a local directory to a specific remote directory |
| 66 | +```bash |
| 67 | +esp32 upload local_project/ remote_app |
| 68 | +``` |
| 69 | +Result: |
| 70 | +``` |
| 71 | +/remote_app/file1.py |
| 72 | +/remote_app/subdir/file2.py |
| 73 | +``` |
| 74 | + |
| 75 | +### Upload a local directory itself to root |
| 76 | +```bash |
| 77 | +esp32 upload my_library |
| 78 | +``` |
| 79 | +Result: |
| 80 | +``` |
| 81 | +/my_library/... |
| 82 | +``` |
| 83 | + |
| 84 | +### Upload a local directory into a specific remote directory |
| 85 | +```bash |
| 86 | +esp32 upload my_library existing_remote_lib_folder |
| 87 | +``` |
| 88 | +Result: |
| 89 | +``` |
| 90 | +/existing_remote_lib_folder/my_library/... |
| 91 | +``` |
| 92 | + |
| 93 | +--- |
| 94 | + |
| 95 | +## Downloading files |
| 96 | + |
| 97 | +### Download a remote file to the current local directory |
| 98 | +```bash |
| 99 | +esp32 download /boot.py |
| 100 | +``` |
| 101 | +Result: `./boot.py` |
| 102 | + |
| 103 | +### Download a remote file to a specific local directory |
| 104 | +```bash |
| 105 | +esp32 download /lib/utils.py my_local_lib |
| 106 | +``` |
| 107 | +Result: `./my_local_lib/utils.py` |
| 108 | + |
| 109 | +### Download a remote file to a specific local path and name |
| 110 | +```bash |
| 111 | +esp32 download /data/sensor.dat backup/latest_sensor.dat |
| 112 | +``` |
| 113 | +Result: `./backup/latest_sensor.dat` |
| 114 | + |
| 115 | +### Download a remote directory and its contents into the current local directory |
| 116 | +```bash |
| 117 | +esp32 download /logs |
| 118 | +``` |
| 119 | +Result: |
| 120 | +``` |
| 121 | +./logs/... |
| 122 | +``` |
| 123 | + |
| 124 | +### Download a remote directory and its contents into a specified local directory |
| 125 | +```bash |
| 126 | +esp32 download /data backup_data |
| 127 | +``` |
| 128 | +Result: |
| 129 | +``` |
| 130 | +./backup_data/data/... |
| 131 | +``` |
| 132 | + |
| 133 | +### Download the contents of a remote directory into the current local directory |
| 134 | +```bash |
| 135 | +esp32 download /app/ . |
| 136 | +``` |
| 137 | +If `/app/main.py` and `/app/gfx/img.png` exist, they become: |
| 138 | +``` |
| 139 | +./main.py |
| 140 | +./gfx/img.png |
| 141 | +``` |
| 142 | + |
| 143 | +### Download the contents of a remote directory into a specified local directory |
| 144 | +```bash |
| 145 | +esp32 download /lib/ local_libs_backup |
| 146 | +``` |
| 147 | +Result: |
| 148 | +``` |
| 149 | +./local_libs_backup/tool.py |
| 150 | +``` |
| 151 | + |
| 152 | +### Download the contents of the device’s root directory into a local directory |
| 153 | +```bash |
| 154 | +esp32 download // full_backup |
| 155 | +``` |
| 156 | +Result: |
| 157 | +``` |
| 158 | +./full_backup/... |
| 159 | +``` |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +## Running scripts |
| 164 | + |
| 165 | +Execute any uploaded Python script and view its output: |
| 166 | +```bash |
| 167 | +esp32 run path/to/script.py |
| 168 | +``` |
| 169 | + |
| 170 | +--- |
| 171 | + |
| 172 | +## Exploring the device |
| 173 | + |
| 174 | +### List files |
| 175 | +```bash |
| 176 | +esp32 list |
| 177 | +``` |
| 178 | +Optionally pass a path: |
| 179 | +```bash |
| 180 | +esp32 list lib |
| 181 | +``` |
| 182 | + |
| 183 | +### Show directory tree |
| 184 | +```bash |
| 185 | +esp32 tree |
| 186 | +``` |
| 187 | +Optionally pass a path: |
| 188 | +```bash |
| 189 | +esp32 tree lib |
| 190 | +``` |
| 191 | +Example output: |
| 192 | +``` |
| 193 | +Tree for ':/' on device: |
| 194 | +. |
| 195 | +├── __init__.py |
| 196 | +├── boot.py |
| 197 | +├── main.py |
| 198 | +└── networking |
| 199 | + ├── __init__.py |
| 200 | + ├── models.py |
| 201 | + └── wifi.py |
| 202 | +``` |
| 203 | + |
| 204 | +--- |
| 205 | + |
| 206 | +Feel free to adapt this workflow to your needs. Contributions and feedback are welcome—see the full docs on GitHub! |
0 commit comments