Filter results by

Smart Light with ARTIK Cloud

Here we provide technical details of using an ARTIK 055s module to implement a smart dimmable light, based on the Tizen RT RTOS. The smart light application can be used with the Samsung ARTIK mobile app to turn on, turn off, and adjust brightness of the light. A physical on-device button is also provided for a more traditional way of controlling light.

By using the Samsung ARTIK mobile app, users can easily on-board the smart light to ARTIK Cloud. Over-the-air (OTA) firmware update capability is included in the smart light application as well.

Introduction

There are 5 pre-set brightness levels that can be used to control the LED brightness.

Control Action Brightness Level (%)
SetOn 100%
SetReading 80%
SetMovie 35%
SetSleep 8%
SetOff 0%

The above 5 brightness settings can be used both locally by pressing physical button (SW703 on starter kit), and remotely by selecting the particular action using mobile app through ARTIK Cloud.

There is an additional remote action, SetBrightness, that can be supported by using the mobile app. It can be used to remotely adjust LED brightness to any preferable brightness level between 0% to 100%.

Once the ARTIK 055s smart light device is powered up and connected to Wi-Fi and ARTIK Cloud through the built-in onboarding process, the smart LED light is ready to use.

Prerequisites

The smart light Tizen RT application can be used as a reference to develop the connected dimmable LED lamp project for the ARTIK 05x module.

Hardware

  • ARTIK 055s dev board

  • LED (as light)

  • Resistor (100 Ω)

  • Wires

  • A universal micro-USB cable to interface with your development machine 

Software

A Linux cross-compilation development environment is required to develop applications using Tizen RT software. For more information about how to setting up Tizen RT development environment, refer to the advanced developers article. Here we use VirtualBox running on a Windows 7 PC.

Connect External Circuit

Before you can run the smart light application to experience of remotely control dimmable LED light, you will need to connect to external circuit. Connect the circuit as instructed in the picture below (or refer to the GitHub hardware article ) The ARTIK 055s starter kit pinout map can be found here.

The smart light application pre-programs the connection to the “XPWMTOUT_3” pin. We are using pulse width modulation (PWM) to drive the LED in this application, meaning that the LED is getting switched on and off. When the switching frequency is high enough, the brightness of the LED is integrated over time, and human eyes cannot tell the difference. We are setting the switching frequency of the LED to be 1000Hz in the code, turning the LED on for 0.1 millisecond and then off for another 0.9 millisecond.

When powering an LED, it’s always a good practice to connect a resistor to limit the current though the LED and prevent its burnout. The LED cathode (-) pin is the pin right next to the flat spot of the LED, and connects to ground. The anode (+) is the other pin that connects to the resistor and XPWMTOUT_3.

Build Application

When Tizen RT development environment is set up, you can download or clone the smart light application from the GitHub repo. Follow the instructions to build the smart light Tizen RT application. When the application builds successfully, you will see library size information output at the console as shown.

Program Tizen RT binary

After successfully building Tizen RT application, follow the instructions to flash the image to the target ARTIK 055s device.

You will see something like shown in the picture below. Each of the flash partitions is loaded to the target board. For more information about ARTIK 055s flash partitions refer to the memory map.

ARTIK Cloud

Register and log in to your ARTIK Cloud account.

When creating a new device type under your ARTIK Cloud, you can just load the pre-defined manifest.json file for smart light device found here.

After creating the device, the other thing you need to do is to browse to “Device Management” tab under your newly created device, then click “SET UP PROPERTIES” to enable server properties and device properties and allow LWM2M to run for your device.

Click here for more information about device management and LWM2M.

Running Application

Now we are ready to run the smart light application. Connect the micro USB cable from ARTIK 055s to host PC. Start the terminal emulator program as instructed here. After pressing the reset button (SW700 located on the ARTIK 055s starter board), you should see the TASH shell CLI interface like shown in the screen capture below:

Note that the commit hash under system information reflects a commit ID of the source repository. So the commit hash may have been changed by the time you build your smart light application. This is totally fine.

At the TASH shell prompt, type “help”. All of the currently available applications will be displayed. “smartlight” is one of them.

Now, type:

TASH>> smartlight

The “smartlight” application will start.

Now, refer to the getting started tutorial to:

  • Download mobile app

  • Provision Wi-Fi to your smart light device

  • Onboard smart light device onto ARTIK Cloud

After successfully onboarding the smart light, from your mobile app, you should be able to see the smart light device appears under your ARTIK Cloud account.
If you click on the smart light device you just added, all of the actions defined for the device manifest file will be shown. You can click on the action to change the state of the LED light remotely.
All of the actions, except SetBrightness do not require additional setup. As mentioned in previous section, the brightness level can be set between 0% and 100%. To set the preferred brightness level, click on SetBrightness action from the mobile app device action list, then type in integer between 0 and 100 in the text field.

Also note that the brightness of the LED light can also be changed anytime by pressing SW703.

When SW703 is pressed, the terminal will also show messages to indicate current LED brightness level.

  • Button press once would turn “ON” the LED light.

  • Button press twice would change the LED light to “READING” mode

  • Button press three times would change the LED light to “MOVIE” mode

  • Button press four times would change the LED light to “SLEEP” mode

  • Button press five times would change the LED light to “OFF” mode

Generate OTA Image

There are cases that you may want to update your application firmware to add more functionality or to fix bugs. The smart light application also has OTA capabilities built in to the code base. When you finish updating your firmware, make sure that you’ve also updated the firmware version. The firmware version is defined by the following line in the smart light header code

#define ONBOARDING_VERSION "1.8.0.0"

After that, build the application as mentioned in earlier section. Then, run the command below to generate a special binary for OTA:

make image ota

Note that the resulting "ota.bin" can be found under /build/configs/$(BOARD_NAME)/bin

This ota.bin image can be uploaded into ARTIK Cloud device management for OTA update. When uploading new OTA update image, you need to choose “Edge Node” as the type of target device. Make sure you enter the same firmware version number as you programmed in the code.

Check the OTA article for more details about OTA.

Last updated on: