Alternative firmware for Arilux AL-LC03 for use with MQTT and Home Assistant (RGB light strip controller)

Hi,
If you’re using a local MQTT broker, TLS is for me, not mandatory. On the other hand, if you’re using a public MQTT broker, it’s recommended to use SSL/TLS because your credentials are sent in plain text (message MQTT CONNECT).

I think that it’s better to configure each light individually and to create another light (optimistic: false) to control all the lights at the same time. In the sketch, you need to add the code to subscribe to the group topics (see below) and the necessary code to handle these topics (callback method).

Light 1 - X (MQTT topics):
State:

  • State: arilux/1/state/state
  • Command: arilux/1/state/set
    Brightness:
  • State: arilux/1/brightness/state
  • Command: arilux/1/brightness/set
    Color:
  • State: arilux/1/color/state
  • Command: arilux/1/color/set

Group of lights 1 - X (optimistic mode: true):
State:

  • Command: arilux/group/state/set
    Brightness:
  • Command: arilux/group/brightness/set
    Color:
  • Command: arilux/group/color/set

Hi, I spent a few hours to make OTA work for this little gadget… and succeeed. Now, I am able to upload my code anytime. My controller arrived a few days ago, ordered from Banggood recently. I have noticed that they have changed the ESP8266 module version. The original post mentions ESP-12F but mine has ESP-12S. It’s a newer model with different flash layout/size - at least that was my idea. I need to say I’m NOT using Arduino IDE but PlatformIO to develop and upload stuff for my ESP modules, but I don’t think it is really matters. So, I used ‘CheckFlashConfig.ino’ (from Arduino/ESP8266 examples) to see what real size of flash do I have and it said it’s 1M not 512K and it reported ‘Flash chip configuration wrong’ error. AFAIK it means my new codes didn’t fit into the OTA when I tried it. Anyway, I quickly uploaded "BasicOTA.ino’ to confirm manual OTA uploads with espota.py and it worked. So I flashed this firmware for Arilux by mertenats (thanks!!!) and tried OTA on that again. All good.

[env:esp12e]
platform = espressif8266
board = esp12e
framework = arduino
upload_resetmethod = ck
board_flash_mode = dio
;board_f_flash = 40000000L
;board_f_cpu = 80000000L
build_flags = -Wl,-Tesp8266.flash.1m64.ld

note: esp8266.flash.1m64.ld means 1M (64K SPIFFS) flash size

Hope this helps someone with their OTA issues.

Oh, one more comment. The IR controller didn’t work either. Looks like the vendor includes a different IR remote these days. The codes are different. eg.

#define ARILUX_IR_CODE_KEY_OFF         0x7CCD4D09 // 0xFFF807
#define ARILUX_IR_CODE_KEY_ON          0x947173A1 // 0xFFB04F

I did a quick and dirty code change a around line 386 to see what IR codes the remote sends.

  DEBUG_PRINTLN(F("ERROR: IR code not defined"));
  DEBUG_PRINTLN(results.value);

@mertenats thank you for your reply. That is 90% clear, but just to check…

  1. Each time I flash a controller (1-x) I will edit and increment both the state and command topics in the sketch so that each controller is effectively unique in MQTT terms.
  2. Each light will be individually configured in HA yaml using its matching pub and sub topics, At this stage I will have 6 configured, working and individually addressable lights.

Correct so far?

Your next bit is my missing 10%! I tried, before posting yesterday, the MQTT concept of “+” to address the lights together, but the configuration was rejected by HA. Are you saying that /group/ is the same thing but the correct syntax in yaml? Is the example you’ve written to be used as-is, or does it require a HA group to be set-up and then that id used instead of /group/?

As an aside, I’ve also had it suggested in another thread that if I change the mqtt_client_id in the sketch (currently set to arilux) to be unique in each controller (the suggestion is to use the 8266 chip code for simplicity) then I can actually use multiple controllers with the same mqtt pub and sub details.

I’ve gone from being frustrated and stuck to having two routes, which is a good result in 24hrs! I’ll explore both…

Hi SethKins,
My solution is just a suggestion and I’ve not tried it yet.

  1. Correct
  2. Correct

Normally, with the MQTT protocol, we can use +and #. As you mentioned, it’s not working. My suggestion is to use a unique command_topic for all the lights, whatever it’s name.

Yes! Each device must have an unique ID.

char              MQTT_CLIENT_ID[7]                                 = {0};
...
  // get the Chip ID of the ESP and use it as the MQTT client ID
  sprintf(MQTT_CLIENT_ID, "%06X", ESP.getChipId());
  ...
  if (mqttClient.connect(MQTT_CLIENT_ID, settings.mqttUser, settings.mqttPassword)) {
  ...

Example here

Hi everyone,

I am interested in trying to flash one of these.

If I buy this:

and this:

Apart from a soldering iron will I need anything else? I dont really have any experience with hardware modifications. Do I need a usb to serial converter?

@kiwinol

That is the Arilux version of the controller which incorporates IR control as well as wifi. If you don’t plan on using the IR, get the AL-LC01.

Secondly, you won’t need pinheaders to reflash these boards, there are no pin holes to install them. You will have to solder temporary programming wires to pads on the board or use a custom made programming jig with pogo pins or the like.

You only need a usb/serial converter, a soldering iron and four dupont wires to reflash these. I have reflashed four of these, it only took about 15 minutes per board.

Thanks Dwalt. I have gone ahead and ordered everything including:
http://www.ebay.com.au/itm/272279719836
http://www.ebay.com.au/itm/172317051200

Now I just need to wait a month or so for everything to arrive. Then I may have some more questions :slight_smile:

1 Like

To answer to an open issue on the firmware’s Github page

Hi there,

I noticed there are also RGBW controllers:
http://www.banggood.com/ARILUX-AL-LC02-Super-Mini-LED-WIFI-APP-Controller-Dimmer-for-RGBW-LED-Strip-Light-DC-9-12V-p-1060222.html

would support be possible? :slight_smile:

I’ve ordered a RGBW lightstrip and I’ll try to convert my RGB controller into a RGBW controller (one free pin unused). However, I don’t know how to proceed with the firmware to handle the white channel.

  • Use the white channel if the RGB value is equal to 255, 255, 255 and turn off the others
  • Use the white channel as an independent light (ON/OFF, brightness)
  • Try to convert RGB into RGBW and vice versa (Home Assistant supports only RGB with the MQTT component)

Any advice? Thanks!

Adding one white channel makes the device one step closer to the H801 controller (which is RGBWW) with only differing pin assignments. I have stumbled across several alternative MQTT firmwares for the H801 on Github. That might be a good starting place.

Regarding RGB to RGBW conversions, you may find these snippets useful.

1 Like

A few comments up I promised I would try something and report back…

I bought a few LC01 models from banggood and edited the sketch to make each client_id unique (basically the chip id) on each arilux unit. It all works perfectly, I have 9 lights set up that all act as a single unit via HA, which is exactly what I wanted. Turning them on and off, changing brightness or RGB colour is just one click for all of them simultaneously. I used the HA config suggested at the top of this thread, I didn’t bother to try to set up each light individually and then group them, they just act as one unit, despite not actually being physically linked.

I’m really really pleased with the solution!

3 Likes

Hi @SethKins ,
Can you confirm that the sketch is working without modifications on an Arilux AL-LC01 (without your modifications for the unique ID)?
Thx,
Sam

Absolutely yes! IR and RF control lines commented out, the ID line changed and the units flashed! Worked perfectly and first time. The LC01’s are running in parallel with the LC03s, with no differences in performance,

Thanks again for your time in producing and publishing the firmware @mertenats

1 Like

A couple of breakthroughs for me tonight.

  1. I got the firmware loaded without using crocodile clips or soldering! Thanks to a helpful post from the SmartThings forums I figured out that there are pads on the bottom to flash with. These provide a few benefits over the top pads:

    1. Instead of needing two FTDI’s you can just use the power supply included with the device and a single FTDI for TX/RX and GND only.
    2. You can accomplish the flashing without needing solder or crocodile clips!
    3. Makes it possible to put the board back into the original case for a clean look.

    Here’s a picture of what I’m talking about:

    Quoting from the ST forums:

    I find that holding the wires in place is rather easy if you have an extra set of hands available to plug things in and press keys on the keyboard. So these controllers you connect TX, RX and Ground to the pins shown below. With this all connected and the FTDI connected to your computer, then apply 12V power by plugging in the Arilux controller. After the initial flash, you can upgrade via OTA

  2. I figured out the OTA issues that people were having. When you initially flash the board you should use these settings which properly match the board capabilities. Thanks to @GaborBognar for the initial tips, it took a bit more playing to figure out exact settings. The key is to make sure your Flash Size is set to 1M (64K SPIFFS). You will need to flash once more while connected to the board if you previously flashed with a smaller flash size. After ensuring that I flashed with the correct flash size I was able to continually OTA upgrade without issues. Previously I was using the settings from the firmware README which led to failures because the flash size was incorrect.

I’m now making changes to the library to improve things, like configuration and adding MQTT last will and testaments. I hope to port some of the FastLED effects over to this firmware as well.

As for RGBW support, someone has already added support for both RGBW and RGBWW but they closed their pull request. I am using their fork and everything seems to be working quite well. Hoping to get their work merged in soon…

3 Likes

Hi Robbie,

Do I need to connect the ground of the FTDI to both ground pads or is just one of them sufficient?

Both pads required

1 Like

Of course. To enter flashing mode. I see that you already updated


:slight_smile:

Does anyone have a device with a remote and the original firmware still on it? Trying to implement the special remote functions but I don’t know or remember what the original effects looked like or did. Can someone record a video with all the effects?

Here’s the full list:

Infrared (IR) Remote functions:

  • Fade
  • Flash
  • Smooth
  • Strobe

Radio Frequency (RF) Remote functions:

  • Mode Minus
  • Mode Plus
  • Speed Minus
  • Speed Plus
  • Toggle

Let me know if I missed any too!

Thanks!

In other news, big features (effects, JSON, transition, flashing) and improvements coming down the pipe thanks to some work I did on MQTT Lights that will be out in Home Assistant 0.40. Check out the pull request here.

2 Likes

I am sure this is a simple issue. When I try to compile the firmware I get:

Arilux_AL-LC0X:61: error: 'StaticJsonBuffer' does not name a type
 StaticJsonBuffer<512> HOME_ASSISTANT_MQTT_DISCOVERY_CONFIG;
 ^
/home/adam/Downloads/Arilux_AL-LC0X/Arilux_AL-LC0X.ino: In function 'void callback(char*, byte*, unsigned int)':
Arilux_AL-LC0X:153: error: 'ARILUX_MQTT_WHITE_COMMAND_TOPIC' was not declared in this scope
   } else if (String(ARILUX_MQTT_WHITE_COMMAND_TOPIC).equals(p_topic)) {
                     ^
/home/adam/Downloads/Arilux_AL-LC0X/Arilux_AL-LC0X.ino: In function 'void handleCMD()':
Arilux_AL-LC0X:514: error: 'ARILUX_MQTT_WHITE_STATE_TOPIC' was not declared in this scope
       publishToMQTT(ARILUX_MQTT_WHITE_STATE_TOPIC, msgBuffer);
                     ^
exit status 1
'StaticJsonBuffer' does not name a type

What am I doing wrong?