Skip to content

Building and Uploading the Firmware

Victor-Mo edited this page Nov 22, 2019 · 1 revision

A. Building yourself from the source code

This requires PlatformIO.

On Windows using the PlatformIO IDE:

  • Download Git (install using the default settings)
  • Download and install Visual Studio Code (VSC)
  • Restart the PC (if using Windows) to apply the new PATH settings. It should now detect Git
  • Install the VSC extension "PlatformIO IDE"
  • Git clone this repo with "git clone" from the command palette and using the URL https://github.com/proddy/EMS-ESP.git
  • Install NodeJS from here.
  • Test if Node is installed correctly by node --version (both v10 and v12 are ok)
  • Install the modules in the tools/webfilesbuilder folder with:
cd tools/webfilesbuilder
npm ci
  • Check you can build the web files by typing node node_modules/gulp/bin/gulp.js from the webfilesbuilder folder.
  • Finally use the build targets in PlatformIO's to build & upload.

If you seeing fatal errors in the npm install and came from an earlier build then you'll may need to refresh the library, like

  1. Remove the local node_modules
  2. Clean npm cache by npm cache verify
  3. Update the global npm by sudo npm ci -g npm
  4. Reinstall the local node_modules by npm ci

On Ubuntu using Command Line Interface:

  • Install python: % sudo apt install python-pip
  • Install PlatformIO (see https://docs.platformio.org/en/latest/installation.html): % python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/develop/scripts/get-platformio.py)"
  • Edit ~/.profile and add: export PATH=$PATH:~/.platformio/penv/bin to the end, then exit, and start a new shell
  • Grab the IRT-EMS-ESP code: git clone https://github.com/Victor-Mo/IRT-EMS-ESP.git
  • Install NodeJS. See instructions here.
  • Build the firmware: pio run
  • Upload to firmware: pio run -t upload

Modifying the web front end

If you plan to make changes to the web (css/html/js) you can simulate the front-end by installing the npm modules in the wsemulator folder:

cd tools\wsemulator
npm ci

for the first time and then using the run script to start it. e.g. ./run or ./run.sh just run depending on the OS. The password for the web admin user is neo.

B. Using the pre-built Firmware

A pre-baked firmware for the Wemos D1 mini is available in the GitHub releases which you can upload yourself using the esptool bootloader.

Here's how to install for the first time:

  • Install ESPTool by running pip install esptool. You'll need Python installed.
  • Download the firmware from https://github.com/Victor-Mo/IRT-EMS-ESP/releases/latest. You can use wget for this.
  • esptool -p COM5 write_flash 0x00000 *.bin (use COM* for windows, /dev/tty* for Linux/OSX)

The ESP8266 will start in Access Point (AP) mode which you can connect using a WiFi enabled laptop/tablet/phone to the SSID ems-esp and then open the URL http://ems-esp or http://192.168.4.1 to set the wifi and mqtt settings. The default web password is admin.

For upgrading via OTA (Over The Air):

  • Download espota. Eg. wget https://raw.githubusercontent.com/esp8266/Arduino/master/tools/espota.py
  • Download the firmware from https://github.com/Victor-Mo/IRT-EMS-ESP/releases/latest. You can use wget for this.
  • python espota.py -i ems-esp -f *.bin