Is there a more natural fit in IoT than Flic and ARTIK Cloud? ARTIK Cloud can connect just about any smart device, sensor, or data source imaginable, while Flic gives you remote control in a single smart button. Each Flic button syncs with your smartphone via BLE (Bluetooth low energy) and sends commands to your smartphone apps via the Flic App.
Let’s build an Android application that sends Flic button events to ARTIK Cloud. From there, you can immediately extend the Flic to control a much wider range of devices via ARTIK Cloud Rules. It won’t be necessary to build any custom integration between Flic and these other IoT devices.
After completing this sample, you will learn how to:
- Add a device to ARTIK Cloud programmatically.
- Intercept Flic button events.
- Proxy the events to ARTIK Cloud.
Find the source code of at GitHub.
Installation and setup
Follow the GitHub instructions to
- Set up at ARTIK Cloud,
- Set up at Flic developer site,
- Prepare the source files and build the Android app.
We will use the ARTIK Cloud device type “Example Flic Button” (unique name:
- Launch the sample app (which you have built previously) on your Android phone and login using your account.
- The app automatically creates a device with type “Example Flic Button” in your ARTIK Cloud account. The screen has four sections displaying: ARTIK Cloud device info; the physical Flic button info; the message sent to ARTIK Cloud; and the response from ARTIK Cloud.
- Click “Grab Flic Button”, which navigates to the Flic App.
- Click the button on the Flic Grabber app. After the grabbing succeeds, our sample app can intercept the events of the physical Flic button. Section 2 is updated with the name and ID of the physical Flic button.
- Now you can play with the Flic by clicking, double-clicking, or holding the physical button. The sample app sends a message to ARTIK Cloud for each button event. Section 3 prints out the sent message and Section 4 shows the message ID returned by ARTIK Cloud:
- If you log into My ARTIK Cloud, you can see each Flic event charted in real-time:
- This is the really fun part! Use the interface at My ARTIK Cloud to set up Rules for the Flic and the ARTIK Cloud ecosystem. In the below example, a single click turns on a (local or remote) outlet, locker, light, and sprinkler. Using our Rules interface, your Flic can also send emails and make HTTP requests. The possibilities are limited only by your creativity.
Add the Flic to ARTIK Cloud account
Once the user logs in, the app automatically creates a new device of type “Example Flic Button” in the user’s ARTIK Cloud account. To programmatically do so, call the Create a Device REST API.
Intercept the events
We followed the Flic for Android documentation to implement the Flic integration. Nested class
ProxyActivity intercepts clicking events from the physical Flic button.
Proxy the events to ARTIK Cloud
Once the application intercepts a button event, it constructs and sends a message to ARTIK Cloud. The message’s payload should follow the definition in the “Example Flic Button” (unique name:
cloud.artik.example.flicbutton) Manifest. You can learn the Manifest by calling Get the latest Manifest properties on the API Console.
Bringing Flic to ARTIK Cloud makes it extremely easy to control the Internet of Things with simple button presses. This is true interoperability at work!
Need ideas for things to interact with? Check out the products that work with ARTIK Cloud. In addition, you can find more device types in the drop down menu when connecting a device at My ARTIK Cloud.
Thanks to Tushar Chugh for creating the first integration between Flic and ARTIK Cloud.
Interested in trying out Samsung ARTIK Cloud? Sign up for a developer account and connect devices and services while bypassing silos. We look forward to seeing your IoT solutions!