Jump to content

Uploading IoT Application From Command Line: Difference between revisions

From cognifront
Pooja (talk | contribs)
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..."
 
Pooja (talk | contribs)
No edit summary
Line 1: Line 1:
== Deploy NodeMCU (ESP8266) Code via Command Line ==
== Upload Code to NodeMCU (ESP8266) Using CMD ==


=== Prerequisites ===
=== Prerequisites ===
# Install Python: https://www.python.org/downloads
# Install Python from https://www.python.org/downloads (Check "Add Python to PATH")
# Install esptool:
# 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
# (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 ===
=== Step 1: Compile the Sketch ===
# Open your sketch in Arduino IDE
# Open the sketch in Arduino IDE
# Go to: <code>Sketch → Export Compiled Binary</code>
# Select board: <code>NodeMCU 1.0 (ESP-12E Module)</code> under Tools → Board
# Find the <code>.bin</code> file in your sketch folder (e.g., <code>MySketch.ino.bin</code>)
# Go to Sketch → Export Compiled Binary
# A <code>.bin</code> file will be generated in the sketch folder


=== Step 2: Identify COM Port ===
=== Step 2: Find the COM Port ===
# Plug in NodeMCU
# Plug in NodeMCU
# Open Command Prompt and run:
# Open Command Prompt and type:
<code>
<code>
mode
mode
</code>
</code>
# Note your device COM port (e.g., <code>COM3</code>)
# Look for a line like <code>Status for device COM3:</code>


=== Step 3: Flash Firmware ===
=== Step 3: Flash the Code ===
# Navigate to your compiled sketch folder:
# Open CMD and go to the folder where the .bin file is located:
<code>
<code>
cd "C:\Users\<YourName>\Documents\Arduino\MySketch"
cd "C:\Users\YourName\Documents\Arduino\MySketch"
</code>
</code>
# Flash the firmware:
# 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: Erase Flash Before Writing ===
=== (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 Output ===
=== Step 4: View Serial Output (Serial Monitor) ===
# Install pyserial (if not already):
# Open CMD and run:
<code>
pip install pyserial
</code>
# View Serial Monitor:
<code>
<code>
python -m serial.tools.miniterm COM3 115200
python -m serial.tools.miniterm COM3 115200
</code>
</code>
# Press <code>Ctrl + ]</code> to exit
# To exit, press <code>Ctrl + ]</code>


=== Notes ===
=== Notes ===
* Ensure no other serial monitor (like Arduino IDE) is open when using miniterm.
* Make sure the COM port matches the one detected
* Make sure baud rate matches your <code>Serial.begin()</code> setting.
* 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

  1. Install Python from https://www.python.org/downloads (Check "Add Python to PATH")
  2. Install required tools:

pip install esptool pyserial

  1. Install Arduino IDE: https://www.arduino.cc/en/software

Step 1: Compile the Sketch

  1. Open the sketch in Arduino IDE
  2. Select board: NodeMCU 1.0 (ESP-12E Module) under Tools → Board
  3. Go to Sketch → Export Compiled Binary
  4. A .bin file will be generated in the sketch folder

Step 2: Find the COM Port

  1. Plug in NodeMCU
  2. Open Command Prompt and type:

mode

  1. Look for a line like Status for device COM3:

Step 3: Flash the Code

  1. Open CMD and go to the folder where the .bin file is located:

cd "C:\Users\YourName\Documents\Arduino\MySketch"

  1. 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)

  1. Open CMD and run:

python -m serial.tools.miniterm COM3 115200

  1. 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