I used Wemos D1-mini and NodeMCU Amica board. It wasn't easy, but eventually I managed to make it work.
- Python + pip
- Wemos Driver
- ESPtool
- nodemcu-tool
- LuaTool
- Wemos - get started in nodemcu
- NodeMCU build
- NodeMCU firmware
- NodeMCU documentation
- NodeLua - couldn't run it on D1-mini
(My device name is: cu.wchusbserial1410
– if you use Linux the name might be different - you can easily find it out by listing /dev/
directoy)
-
Install tools from the requirements.
-
Connect your board and erase everything from the flash memory:
sudo esptool.py --port /dev/cu.wchusbserial1410 erase_flash ```
-
Now we can upload
bin
file to your module (--verify
flag will check if digest matches)
sudo esptool.py --port /dev/cu.wchusbserial1410 --baud 9600 write_flash 0x00000 ./bin/nodemcu-master-7-modules-2016-09-14-16-58-11-float.bin 0x3fc000 ./bin/esp_init_data_default.bin -fm dio -fs 32m ```
(Change the path to `bin` file if you're going to use custom firmware)
-
Once it's ready you should see logs like this:
esptool.py v1.1 Connecting... Running Cesanta flasher stub... Flash params set to 0x0000 Writing 364544 @ 0x0... 364544 (100 %) Wrote 364544 bytes at 0x0 in 31.5 seconds (92.5 kbit/s)... Leaving... Verifying just-written flash... Verifying 0x587fc (362492) bytes @ 0x00000000 in flash against bin/nodemcu-master-10-modules-2015-09-29-17-58-26-integer.bin... -- verify OK (digest matched) ```
- You have to REBOOT your board by clicking the
Reset
button. The LED should blink once. If it's blinking like crazy, probably something went wrong while uploading yourfirmware
. Try to repeat all steps: erase & upload and make sure that your are setting-fm
and-fs
.
- Download ESPtool.
- Connect to your board.
- Open / Create lua script.
- Click Save to ESP
-
Install nodemcu-tool
npm i -g nodemcu-tool ```
-
Upload Lua file:
nodemcu-tool --port /dev/cu.wchusbserial1410 upload ./lua/led/init.lua ```
- Press Reset button
NodeMCU-Tool offers more useful commands:
fsinfo [options] Show file system info (current files, memory usage)
run <file> Executes an existing .lua or .lc file on NodeMCU
upload [options] [files...] Upload Files to NodeMCU (ESP8266) target
download <file> Download files from NodeMCU (ESP8266) target
remove <file> Removes a file from NodeMCU filesystem
mkfs [options] Format the SPIFFS filesystem - ALL FILES ARE REMOVED
terminal [options] Opens a Terminal connection to NodeMCU
init Initialize a project-based Configuration (file) within current directory
devices [options] Shows a list of all available NodeMCU Modules/Serial Devices
reset [options] Execute a Hard-Reset of the Module using DTR/RTS reset circuit
-
Run
luatool.py
sudo luatool.py -p /dev/cu.wchusbserial1410 --src ./lua/led.lua --dest init.lua --verbose ```
Your console should print 4 Stages:
```
Upload starting
Stage 1. Deleting old file from flash memory
->file.open("init.lua", "w") -> ok
->file.close() -> ok
Stage 2. Creating file in flash memory and write first line->file.remove("init.lua") -> ok
Stage 3. Start writing data to flash memory...->file.open("init.lua", "w+") -> ok
-> ...
Stage 4. Flush data and closing file->file.writeline([==[tmr.alarm(0, duration, 1, blink)]==]) -> ok
->file.flush() -> ok
->file.close() -> ok
--->>> All done <<<---
```
- Press the
Reset
button. - LED should start blinking.
(Check your device name and replace if needed)
make erase
will erase everything from the flash memorymake flash
will upload binary file
It ain't so easy to use Lua together with D1-mini board. Sometimes firmware produces garbage output on the console (nodemcu/nodemcu-firmware#1474). I still didn't figure it out why it's happening.
It would be great to have IDE like Arduino where everything works out of the box.
I tried to flash AI-Thinker module and everything went smooth but I couldn't use ESPlorer. I had to switch to nodemcu-tool
which is perfect if you prefer to use CLI.