Selasa, 18 Oktober 2016

Memulai dengan ESP8266 NodeMCU V1.0 development board (Arduino IDE)

Tulisan ini saya buat, setelah berkutat dengan masalah gagalnya upload program dari Arduino IDE ke board IoT nodeMCU Versi 1.0 Amica (pada board yang tidak terinstalasi NodeMCU x.x Lua)  dengan pesan Error:

warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed
error: espcomm_upload_mem failed


Setelah mencari referensi ke Web, akhirnya mendapat solusi.

Semoga tulisan ini dapat membantu anda jika mengalami masalah yang sama.

NodeMCU adalah suatu open source IoT platform yang memasukan firmware yag mana berjalan diatas chip ESP8266 Wi-Fi SoC.

 Gambar 1. Board NodeMCU

 Gambar 2. Tampilan belakang Board NodeMCU

Langkah-langkah:
1. Tancapkan Board NodeMCU diatas breadboard

Gambar 3. NodeMCU yang ditancapkan diatas breadboard

2. Install driver CP2102 (USB to Serial Converter) sesuai dengan sistem operasi  yang dapat di download.
3. Catat nomor port hasil instalasi, misalnya COM4 


Gambar 4. Port setelah instalasi driver USB CP2102
3. Install Arduino IDE (Sketch) yang dapat di download
4. Install esp8266 boards manager
4.a. Pada menu File, pilih Preferences
4.b. Pada Additional Board Manager URLs isikan:
http://arduino.esp8266.com/stable/package_esp8266com_index.json

Gambar 5. Isian pada Preferences
4.c. Pada menu Tools, Board ..., pada sub menu pilih Boards manager.
4.d. Scroll kebawah, dan pilih esp8266 by ESP8266, dan install

 Gambar 6. Setelah boards manager diinstalasi

5. Pilih board & Port yang sesuai
5.a. Pada menu Tools, Board ...,  pada sub menu pilih NodeMCU 1.0 (ESP 12E module)
5.b. Pada menu Tools, Port, pilih COM4

 Gambar 7. Setting pada Tools
6.Buatlah rangkaian anda dimana kaki anoda pada pin D7, dan kaki cathoda pada GND
Gambar  8. Led pada pin D7 dan GND

7. Buat koding sebagai berikut:
void setup() {
  pinMode(D7, OUTPUT);
}

void loop() {
  digitalWrite(D7, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(D7, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}
8. Lakukan verify
9. Lakukan upload


Gambar 9. Upload berhasil

Jika anda berhasil melakukan hal tersebut diatas, maka led akan blink.

10. Jika gagal

Trouble Shooting:
Pada saat upload muncul error:

warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed
error: espcomm_upload_mem failed


Untuk mendapatkan verbose output yang lebih spesific, dapat disetting pada menu File, Preference, dan berikan tanda check pada Show verbose output during (x) compilation (x) upload.

Solusi:
Hal tersebut dapat terjadi karena board tidak berhasil masuk ke programming/flash mode, untuk memungkinkan programming/flash mode hubungkan pin D3 (GPIO 0) ke  GND

Gambar 10. Pull pin D3 (GPIO 0) ke GND

Dan coba Upload ulang (contoh verbose hasil upload yang berhasil).

Sketch uses 230,113 bytes (22%) of program storage space. Maximum is 1,044,464 bytes.
Global variables use 32,368 bytes (39%) of dynamic memory, leaving 49,552 bytes for local variables. Maximum is 81,920 bytes.
C:\Users\hendra-new\AppData\Local\Arduino15\packages\esp8266\tools\esptool\0.4.9/esptool.exe -vv -cd nodemcu -cb 115200 -cp COM4 -ca 0x00000 -cf C:\Users\HENDRA~1\AppData\Local\Temp\arduino_build_696037/nodeMCUhelloworld.ino.bin
esptool v0.4.9 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
    setting board to nodemcu
    setting baudrate from 115200 to 115200
    setting port from COM1 to COM4
    setting address from 0x00000000 to 0x00000000
    espcomm_upload_file
    espcomm_upload_mem
    setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
Uploading 234256 bytes from C:\Users\HENDRA~1\AppData\Local\Temp\arduino_build_696037/nodeMCUhelloworld.ino.bin to flash at 0x00000000
    erasing flash
    size: 039310 address: 000000
    first_sector_index: 0
    total_sector_count: 58
    head_sector_count: 16
    adjusted_sector_count: 42
    erase_size: 02a000
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    setting serial port timeouts to 15000 ms
    setting serial port timeouts to 1000 ms
    espcomm_send_command: receiving 2 bytes of data
    writing flash
................................................................................ [ 34% ]
................................................................................ [ 69% ]
.....................................................................            [ 100% ]
starting app without reboot
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    espcomm_send_command: receiving 2 bytes of data
closing bootloader
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete

Akhir silakan mencoba, dan semoga berhasil.

Salam,
Hendra.

1 komentar: