Uploading IoT Application From Command Line: Difference between revisions
Appearance
Created page with "== Deploy NodeMCU (ESP8266) Code via Command Line == === Prerequisites === # Install Python: https://www.python.org/downloads # Install esptool: <code> pip install esptool </code> # Install Arduino IDE: https://www.arduino.cc/en/software # (Optional) Install USB-to-Serial Drivers: * CH340: https://sparks.gogo.co.nz/ch340.html * CP210x: https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers === Step 1: Compile Code === # Open your sketch in Arduino IDE # Go to..." |
No edit summary |
||
| Line 1: | Line 1: | ||
== | == Upload Code to NodeMCU (ESP8266) Using CMD == | ||
=== Prerequisites === | === Prerequisites === | ||
# Install Python | # Install Python from https://www.python.org/downloads (Check "Add Python to PATH") | ||
# Install | # Install required tools: | ||
<code> | <code> | ||
pip install esptool | pip install esptool pyserial | ||
</code> | </code> | ||
# Install Arduino IDE: https://www.arduino.cc/en/software | # Install Arduino IDE: https://www.arduino.cc/en/software | ||
=== Step 1: Compile | === Step 1: Compile the Sketch === | ||
# Open | # Open the sketch in Arduino IDE | ||
# | # Select board: <code>NodeMCU 1.0 (ESP-12E Module)</code> under Tools → Board | ||
# | # Go to Sketch → Export Compiled Binary | ||
# A <code>.bin</code> file will be generated in the sketch folder | |||
=== Step 2: | === Step 2: Find the COM Port === | ||
# Plug in NodeMCU | # Plug in NodeMCU | ||
# Open Command Prompt and | # Open Command Prompt and type: | ||
<code> | <code> | ||
mode | mode | ||
</code> | </code> | ||
# | # Look for a line like <code>Status for device COM3:</code> | ||
=== Step 3: Flash | === Step 3: Flash the Code === | ||
# | # Open CMD and go to the folder where the .bin file is located: | ||
<code> | <code> | ||
cd "C:\Users\ | cd "C:\Users\YourName\Documents\Arduino\MySketch" | ||
</code> | </code> | ||
# | # Upload the binary to NodeMCU: | ||
<code> | <code> | ||
python -m esptool --port COM3 --baud 115200 write_flash 0x00000 MySketch.ino.bin | python -m esptool --port COM3 --baud 115200 write_flash 0x00000 MySketch.ino.bin | ||
</code> | </code> | ||
=== Optional | === (Optional) Erase Flash Before Upload === | ||
<code> | <code> | ||
python -m esptool --port COM3 erase_flash | python -m esptool --port COM3 erase_flash | ||
</code> | </code> | ||
=== Step 4: View Serial Monitor | === Step 4: View Serial Output (Serial Monitor) === | ||
# | # Open CMD and run: | ||
<code> | <code> | ||
python -m serial.tools.miniterm COM3 115200 | python -m serial.tools.miniterm COM3 115200 | ||
</code> | </code> | ||
# | # To exit, press <code>Ctrl + ]</code> | ||
=== Notes === | === Notes === | ||
* | * Make sure the COM port matches the one detected | ||
* | * Close Arduino Serial Monitor before using miniterm | ||
* Ensure <code>Serial.begin(115200)</code> in your sketch matches the miniterm baud rate | |||
Revision as of 09:30, 6 June 2025
Upload Code to NodeMCU (ESP8266) Using CMD
Prerequisites
- Install Python from https://www.python.org/downloads (Check "Add Python to PATH")
- Install required tools:
pip install esptool pyserial
- Install Arduino IDE: https://www.arduino.cc/en/software
Step 1: Compile the Sketch
- Open the sketch in Arduino IDE
- Select board:
NodeMCU 1.0 (ESP-12E Module)under Tools → Board - Go to Sketch → Export Compiled Binary
- A
.binfile will be generated in the sketch folder
Step 2: Find the COM Port
- Plug in NodeMCU
- Open Command Prompt and type:
mode
- Look for a line like
Status for device COM3:
Step 3: Flash the Code
- Open CMD and go to the folder where the .bin file is located:
cd "C:\Users\YourName\Documents\Arduino\MySketch"
- Upload the binary to NodeMCU:
python -m esptool --port COM3 --baud 115200 write_flash 0x00000 MySketch.ino.bin
(Optional) Erase Flash Before Upload
python -m esptool --port COM3 erase_flash
Step 4: View Serial Output (Serial Monitor)
- Open CMD and run:
python -m serial.tools.miniterm COM3 115200
- To exit, press
Ctrl + ]
Notes
- Make sure the COM port matches the one detected
- Close Arduino Serial Monitor before using miniterm
- Ensure
Serial.begin(115200)in your sketch matches the miniterm baud rate