In the previous article, we described how to make an addressable LED strip controller and write firmware based on the 2Smart Cloud SDK. This article will show you how to write a fully compatible firmware for the same controller but based on ESPHome.
Details on how to make an LED strip controller and write firmware for it are here. The first article describes how to create firmware using the SDK of the platform for IoT product development, a powerful tool that we recommend to most vendors.
However, in many cases, ESPHome is a fairly functional tool. Its main advantage is simplicity. Using ESPHome, it will be easier for you to modify the firmware and add new functionality — for example, connect additional sensors and create a smart multitool. This also means that ESPHome is perfect for prototyping, allowing you to save time creating a Proof of Concept.
You can use the firmware configuration provided in this article as part of the code configuration for a more complex device. You can also use the LED strip controller to compare two firmware creation tools for the ESP32 microcontroller: SDK and ESPHome.
Using ESPHome to create the firmware for an IoT device, with 2Smart, you get a complete product suitable for going to market. Each device with ESPHome-based firmware can be linked to the mobile application using standard pairing. At the same time, the end user specifies the credentials of their Wi-Fi network during pairing; they do not need to be embedded in the firmware code as when using ESPHome on native platforms.
The 2Smart Cloud mobile application, in addition to managing the device using widgets in its interface, provides the following additional features:
In addition, you can deploy the advanced open-source home automation system 2Smart Standalone and include a device with ESPHome-based firmware in your ecosystem of smart home devices. Such a device can be completely autonomous or combine the advantages of an automation platform with its flexible scenarios and a cloud platform with its ability to control devices remotely from anywhere in the world.




After selecting the appropriate lines of config, we added controller effects and included support for the Reset button and Wi-Fi signal sensor in the firmware.
Full configuration from our example:
light:
  - platform: fastled_clockless
    chipset: WS2812B
    pin: 18
    num_leds: 300
    rgb_order: GRB
    name: FastLED WS2812 Light
    id: light_rgb
    effects:
      - random: null
      - pulse:
          name: "Fast Pulse"
          transition_length: 0.5s
          update_interval: 0.5s
      - strobe: null
      - addressable_scan:
          move_interval: 50ms
          scan_width: 4
      - addressable_random_twinkle:
          twinkle_probability: 20%
          progress_interval: 100ms
      - addressable_color_wipe: null
      - addressable_rainbow: null
      - addressable_fireworks:
          name: Fireworks Effect With Custom Values
          update_interval: 32ms
          spark_probability: 10%
          use_random_color: false
          fade_out_rate: 120
binary_sensor:
  - platform: gpio
    id: led_switch
    pin:
      number: GPIO5
      mode: INPUT_PULLUP
      inverted: true
    name: Led switch
    on_click:
      then:
        - light.toggle: light_rgb
  - platform: gpio
    id: change_effect
    pin:
      number: GPIO4
      mode: INPUT_PULLUP
      inverted: true
    name: Change effect
    on_click:
      then:
        - lambda: !<!lambda> |-
            uint32_t total = id(light_rgb)->get_effects().size();
            uint32_t curr_idx = 0;
            uint32_t i = 0;
            std::string curr_effect = id(light_rgb)->get_effect_name();
            auto call = id(light_rgb)->turn_on();
            // set first effect in list
            if (strcasecmp(curr_effect.c_str(), "none") == 0) {
              call.set_effect(1);
              call.perform();
              return;
            }
            for (auto *effect : id(light_rgb)->get_effects()) {
              i++;
              if (strcasecmp(effect->get_name().c_str(), curr_effect.c_str()) == 0)
                curr_idx = i;
            }
            if (curr_idx == total) {
              call.set_effect(0);
            } else {
              call.set_effect(curr_idx + 1);
            }
            call.perform();
  - platform: reset_sensor
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: true
    name: Reset button
    filters:
      - delayed_on: 1s
sensor:
  - platform: wifi_signal
    name: WiFi1 Signal
    update_interval: 30s
    id: wifi_config

 
 
 
  
 

 
 

We’re empower your business with our technology expertise







That’s it! We have created a LED strip controller without programming and using assembler programs. The firmware code for ESPHome was written according to the documentation for this base. In fact, we just took ready-made examples and used them on our device.
Simplicity is the main advantage of ESPHome. Therefore, even if you plan to use firmware based on our SDK on production devices, we recommend testing the product using simpler tools. This reduces the time to create an IoT device.
The development of this idea is an LED lighting smart IoT solution where the controller described above controls the LED matrix, which is the basis for a smart lamp with multiple effects.
Share with us your business idea and expectations about the software or additional services.