Table of contents:

Assembling a LED strip controller or a Wi-Fi lamp is simple enough as there are plenty of ready-made solutions available on the Internet (more about how to assemble an LED strip controller 2Smart). Such projects, as well as a list of components, Gerber board designs, and ready-made firmware, are available on the 2Smart Cloud GitHub. You can also optionally add extra modes for the LED strip or lamp matrix that are not included in the proposed firmware.

Adding a new effect for the LED strip controller or Wi-Fi lamp

To adapt the ready-made firmware code for yourself and add new controller effects, first of all, you need to create a new product in the 2Smart Cloud developer cabinet:

  1.  On the “Products” tab, click “Add Product”.
    The Products page of the 2Smart Cloud vendor cabinet
  2. Select the microcontroller – ESP32.
    Microcontroller selection window
  3. Click “Add Firmware” and select the Custom option.
    Button for creating firmware in the 2Smart Cloud vendor account
    Firmware base selection window
  4. Click the “Connection Info” link and leave the window with the product connection parameters open.
    Connection Info link
    A window with data for connecting the device to the platform
  5. Download the LED controller or Wi-Fi lamp project from the repository. Open it in the terminal, and make the necessary changes in a text editor:
    • add the effect method to lib/lenta/lenta.h, add the effect name to LedStripStates:
      Adding a method and an effect name
    • in modes_, assign the name for the mobile application to the name of the effect:
      Assigning an effect to a title for a mobile app
    • in lib/lenta/lenta.cpp add the method body with a description of the entire logic of the effect. If necessary, add auxiliary methods.
      Attention! Remember that diode lighting is also a mode task., for which you need to use the LEDS.show(); command.Adding the method body
    • in HandleCurrentState, add the mode to switch:
      Adding a mode to switch
  6. Open the Firmware/src/main.h file and make the following changes:
    • copy the product ID from the “Connection Info” window in the vendor’s account and paste it into the firmwareName and ProductID fields,
    • specify the name of your device’s access point instead of the default one in the deviceName area,
    • if you create a new product, make sure that its device_version is set to 1.

    Adding connection data to the firmware

  7. Connect the controller to the computer with a USB cable and flash it. Don’t forget to disable the feed first!Use the following commands to install the firmware:

  8. After completing the firmware installation, the device activates its Wi-Fi access point. When connecting to it, you will be able to access the controller’s web interface and configure it to connect to the platform:
    • link to the access point of the controller – “2Smart Led Strip” or “2Smart Lamp” (the name can also be changed to your own in the main.h file) and enter the link http://192.168.4.1 in the address bar of the browser to enter the web interface device, use the login and password “admin”,
    • on the Credentials tab, specify your product parameters from the “Connection Info” window opened in the vendor’s cabinet:
    • in the Login field – the value “User login”,
    • in the Token field – the value “Access token”,
    • in the Hostname field (under the Advanced spoiler), enter the value “cloud.2smart.com ”,
    • in the Broker port field, enter the value “11883”,
    • copy the value “Test device ID” in the Device ID field.
      Adding connection data to the device's web interface
    • after filling in all the fields, click Save and go to the Wi-Fi tab of the controller’s web interface. Click Scan to search for available Wi-Fi networks:
      Scanning of available Wi-Fi networks in the web interface of the device
    • select your access point from the list of found access points and enter your password:
      Selecting a Wi-Fi network in the device's web interface
  9. If all the settings are correct, the device will connect to the platform, and its status will change to Ready.Product page with device status – Ready

Let’s collaborate

We’re empower your business with our technology expertise

Let’s discuss your case

Setting up and publishing a product

  1. Click “Add Layout” and customize the appearance of the mobile application. For more information about setting up the interface, see the article about creating a temperature sensor or the series of articles about creating a “smart” Wi-Fi relay.
    Link to create a mobile application interface
  2. Test device control from the application emulator or directly from your smartphone – just log into the application with the same login and password as in the developer’s cabinet.
  3. After successful testing, the device is ready to be published on the platform. It remains to upload the firmware to the platform server and publish the product.
    You can find the finished firmware file in the Firmware/.pio/build/esp32dev/firmware.bin folder (do not forget to enable the display of hidden files in the explorer to find the directory).
  4. Click “Upload firmware” in the vendor’s office and upload the .bin file.
  5. After uploading the firmware, click “Publish”. After the product is published, it will be available for binding to the mobile application by all users. The standard procedure is enough to pair the device to the mobile application.

Rate this article:

4.7 / 5. 7

( 7 votes )

Don't forget to share this post!

Let’s dive into your case

Share with us your business idea and expectations about the software or additional services.

    Thanks for contacting us!

    We will get in touch soon.

    This site is protected by Google reCAPTCHA and the following Privacy policy and Terms of use apply

    Send us a message

    This site is protected by Google reCAPTCHA and the following Privacy policy and Terms of use apply