Skip to content
This repository has been archived by the owner on Aug 22, 2021. It is now read-only.

Flashing the Firmware

Sacha Telgenhof edited this page Jan 3, 2020 · 22 revisions

AiLight

Having your Ai-Thinker (or compatible) Smart Light run using the AiLight firmware is quite simple and consists only of two parts:

  1. Compiling the firmware
  2. Flashing (i.e uploading) the firmware.

Before starting, please make sure you have all that is needed.

Compiling the firmware

  1. Clone this AiLight repository (or download a Zip file) and change your current directory to where AiLight is cloned (or where you extracted the Zip file).
  2. Make a copy of the config.example.h file in the 'src' folder named config.h Depending on your environment, set at least the following values in the config.h file:
  • WIFI_SSID // Your WiFi SSID
  • WIFI_PSK // Your WiFi PSK/Password
  • MQTT_SERVER // The hostname/IP address of your MQTT broker
  • MQTT_USER // The username to connect to your MQTT broker
  • MQTT_PASSWORD // The password to connect to your MQTT broker

Leaving the WiFi values blank, will make the AiLight start in AP mode (Access Point). From there you can access the settings screen and enter your WiFi settings. (TBD)

Other configuration variables can be left as is, however, feel free to adjust as you see fit.

  1. Make a copy of the platformio.example.ini file named platformio.ini. This PlatformIO configuration doesn't require any changes, however, it is recommended to change the OTA port number and OTA password when using your Ai-Thinker (or compatible) Smart Light in production. (In that case, don't forget to update the respective variables in your config.h file too).

  2. For the Web UI component, install the Node dependencies by issueing a npm install (or if you prefer yarn yarn install). Most of the times AiLight releases and the repository will contain a prebuilt Web UI file (src\html.gz.h) but in case this file is missing, the compilation requires these dependencies. Without this Web UI file, the compilation will fail.

  3. Click on the "PlatformIO: Build" icon or issue a platformio run command from the PlatformIO terminal.

Flashing the firmware for the first time

If no compilation errors popped up, you can start uploading (i.e 'flashing') the firmware to your Ai-Thinker (or compatible) Smart Light using an USB/UART (or equivalent) adapter. This is, of course, a required step since your Smart light still has the original factory firmware.

  1. Connect your USB/UART (or equivalent) adapter or an AiLight Jig to your PC using a Micro USB to USB cable.
  2. Click on the "PlatformIO: Upload icon" (Arrow pointing to the right) or issue a platform run --target upload command from the PlatformIO terminal. Uploading should start automatically as PlatformIO will detect the connected Serial Port itself. Alternatively, you can manually specify in the platformio.ini or at the command line which serial port you want use.

Note: If you have trouble making a connection, check if PlatformIO can detect your adapter by clicking "List Serial Ports" in the "PlatformIO" menu. If not, this usually means your cable is not connected or your driver is not properly installed. (You can also see this information from the command terminal by issuing this command: pio list devices)

If the upload of the AiLight firmware was successful, it is recommended restarting your Ai-Thinker (or compatible) Smart Light. This can be done by reconnecting the power of your USB/UART (or equivalent) adapter.

While connected to your USB/UART (or equivalent) adapter, check the output on your Serial Monitor. You should see some messages appear that will tell you details of the AiLight firmware, the device, hostname and the assigned IP address.

AiLight

Similar information can be seen in the Web UI (About page). By default, the Web UI can be accessed via 'http://AiLight-######.local' where '#####' is the unique identifier of your Ai-Thinker (or compatible) Smart Light. If you have changed your hostname, then, of course, the URL is different also. The Web UI can also be accessed using the assigned IP address. However, you often don't know what the assigned IP address is, so you may need to check your router for that.

Your Ai-Thinker (or compatible) Smart Light is now ready and runs the AiLight firmware! Please go ahead and disconnect the USB/UART (or equivalent) adapter or AiLight Jig and put your light in your kitchen light, ceiling light, etc.