Skip to content

Installing firmware

Chege James edited this page Oct 9, 2019 · 3 revisions

Previous page: Components supply - Next page: Known Errors

Installing USB2Serial driver

The operating system of the computer which will upload the sensor software or "firmware" to the NodeMCU - also called to flash - will need a driver to communicate with it. The computer will interact with the USB2Serial chip on the NodeMCU. This will also depend on the version of the NodeMCU. Linux natively provides drivers already.

Identify NodeMCU version

If the version of the NodeMCU is unknown, a description of either CP2102 or CH340G can be found on the back. Alternatively one of the chips are marked,in which case you will most likely need a magnifying glass.

CP2102 (NodeMCU v2)

CP210x USB TO UART Bridge Drivers

CH340G (NodeMCU v3)

CH340G Bridge Drivers

Restart the computer after installing the drivers. Comment MacOS >10.9: Unsigned drivers have to be explicitly allowed. A good description can be found here.

Install firmware

Caution: Do not use USB cables longer then 1m for uploading the firmware to NodeMCU.

We will be describing two variants of installing the sensor software. VARIANT 1 includes compilation of the source code, whereas with VARIANT 2 you use the esptool of the Arduino IDE to upload binaries. VARIANT 2 is recommended as fast path or for beginners. For both variants you'll need the follow these instructions:

  1. Download and install Arduino IDE.
  2. Install platform packages for ESP8266 (v2.3.0) with Boards Manager following these instructions.
  3. Close Arduino IDE.

Identifying the USB port

In order to upload the firmware you will need to supply information of the USB port the operating system is supposed to use. You can do this by connecting the NodeMCU to the port you want use later on and then start the Arduino IDE. At ToolsPort the available ports will be listed and the NodeMCU should be easy to find. To confirm this is actually the right port: Select the port and select ToolsGet Board Info. In the status bar, under VID and PID you should now see codes. Close the IDE now to free up the ports.

  • MAC: CP2102 on /dev/cu.SLAB_USBTOUART and CH340G on /dev/cu.wchusbserialXXXXXXXX.
  • Windows: COM3. If its not that port, just try the next ones in the list of available ports.
  • Linux: /dev/ttyUSB0 or similar

VARIANT 1 Arduino IDE

Here we show how to compile the firmware yourself and upload it to the NodeMCU.

  1. Start Arduino IDE (after previously installing platform packages and closing it).
  2. Install the following libraries. Compare Readme.md and note license:
  1. In the IDE at ToolsBoard select
    • NodeMCU 0.9 (ESP-12 Module) for NodeMCU v1
    • NodeMCU 1.0 (ESP-12E Module) for NodeMCU v2 und v3
  2. Now connect NodeMCU via USB and select the port at ToolsPort.
  3. Copy the source code to your computer. Best and most convenient method is to clone the repository or download the repository as archive and unpack it. Alternatively all files from the source code directory can be manually copied as well. If you do choose the latter, the RAW button might help.
  4. Open the sketch (INO) file in Arduino IDE.
  5. Change the ext_def.h to meet your requirements (WLAN configuration, sensors, ...)
  6. Now flash the NodeMCU with SketchUpload or the upload button (right arrow).

    Bildschirmaufnahme der Arduino-IDE beim Flashen der Firmware

VARIANT 2 Command line

In this variant we will use the command line tool esptool, which came with the Arduino IDE installation.

  1. Download the compiled firmware in English or another language
  2. Open a command prompt or terminal in your operating system.
  3. Paths below may differ due a different version number - also the location of the esptool might have changed with your installation:
    • Windows: "%USERPROFILE%\AppData\Local\Arduino15\packages\esp8266\tools\esptool\0.4.13\esptool.exe" -vv -cd nodemcu -cb 57600 -ca 0x00000 -cp COM11 -cf "_PATH-TO-DOWNLOADED-FIRMWARE-FILE_"
      • Change the port after-cp to yours
      • Use quotation marks as documented
    • Linux/MacOS: $PATH-TO-ESPTOOL -vv -cd nodemcu -cb 57600 -ca 0x00000 -cp $USBPORT -cf $BINARY
      • $PATH-TO-ESPTOOL might look something like ~/Library/Arduino15/packages/esp8266/tools/esptool/0.4.13/esptool or ~/.arduino15/packages/esp8266/tools/esptool/0.4.13/esptool
      • $USBPORT might look like something like this /dev/cu.wchusbserial1410 or /dev/ttyUSB0
      • $BINARY is the path to the binary, eg. latest_en.bin or sensors-software/airrohr-firmware/airrohr-firmware.ino.nodemcu.bin

Description of parameters:

-vv           show additional information while flashing (useful for troubleshooting)  
-cd nodemcu   which reset method should be used
-cb 57600     baud rate for flashing
-ca 0x00000   start address in flash memory
-cp <pfad>    path to the port the NodeMCU is connected to
-cf <pfad>    path to downloaded firmware file

Deleting the configuration

For Linux, yet untested with MacOs, there's a script to delete the config here.

rm config VARIANT 1

You can delete the config with Arduino IDE and the ESP8266fs Plugin. After installing and executing the plugin, you'll have to confirm that you want to upload an empty SPIFFS image. The upload process (3 MB) might take a while. Once finished, the NodeMCU can be restarted.

rm config VARIANT 2

Download this image file and use the esptool similar to VARIANT 2, but with these modifications:

  • change -ca 0x00000 to -ca 0x100000
  • change path to just downloaded file. See above mentioned script.

Testing sensor activity

In Arduino IDE, activate ToolsSerial Montior to review debug information via USB. The output can be read at a baud rate of 9600. Errors such as WLAN login failures or unsuccessful upload of data can be monitored here.