Driving Yoctopuce modules with Flic buttons

Driving Yoctopuce modules with Flic buttons

After the NEEO remote control fiasco, we decided to get over it by playing with Flic buttons, the aim obviously being to use these buttons to drive Yoctopuce modules. This week, we present the results of our experiments on this topic...





Presentation

Flic buttons look like small soft plastic caps that look like PET bottle caps but not as high. They are in fact small Bluetooth transmitters and the idea is to configure an arbitrary action which executes each time someone pushes the button. Simple and efficient. A Swedish company, Shortcut Labs, presented these buttons during a crowd funding campaign on Indiegogo a little over 5 years ago. Since then, Shortcut Labs went a long way as you can now find these buttons in almost any online shop selling consumer electronics.

Shortcut Labs Flic buttons
Shortcut Labs Flic buttons


You can use these buttons in several ways:

Usage, option 1: the smart phone

Initially, Flic buttons are designed to be used with your smart phone. When you have bought your buttons, you only need to download and install the corresponding application. Note that the said application forces you to create a Flic account to start and that it requires access to the localization service of your phone to pair the buttons. This later point is apparently linked to a bug an Android feature.

Sigh....
Sigh....



Well, when you have paired your buttons, you can associate them to a multitude of activities which go from fart generator to the control of TRÅDFRI. But one of the proposed activity stands out: you can forge an HTTP request when you activate a button. Thus, you can succinctly drive Yoctopuce actuators connected to a YoctoHub or to a computer on which a VirtualHub is running.

You can drive Yoctopuce actuators by forging URLs
You can drive Yoctopuce actuators by forging URLs



For example, let's imagine that you have a Yocto-PowerRelay-V3 with the RELAYHI3-100920 serial number, connected to a YoctoHub-Wireless-g with the 192.168.1.69 IP address, you can switch the relay to the B output thanks to the following URL:

http://192.168.1.69/bySerial/RELAYHI3-100920/api/relay1?state=1



You can also switch it from one output to the other thanks to this URL:

http://192.168.1.69/bySerial/RELAYHI3-100920/api/relay1?state=X


Even harder, you can switch it to the B output then automatically switch it back to the A output after 5000ms with this URL:

http://192.168.1.69/bySerial/RELAYHI3-100920/api/relay1?pulseTimer=5000



Regular users of the Yoctopuce API surely recognize the set_state(), toggle(), and pulse() functions of the YRelay class. You can similarly drive most Yoctopuce actuator functions. The requests that you must forge are not explicitly documented in the products' User's guide, but you can find them by using the "API browser" function of the YoctoHub and VirtualHub.

The API browser windows gives you the URL corresponding to each command
The API browser windows gives you the URL corresponding to each command



As you have understood it, most of the work is in fact performed by the Flic application. The buttons only warn the later that they have been pushed. Which means that the system stops working as soon as the phone running the application moves away from the Bluetooth range of the buttons. In other words, if you use the Flic button system to drive lights at home, no one can turn them on or off as soon as you leave home. Thankfully, there is an alternative.

Usage, option 2: The Flic Hub

Shortcut Labs commercializes a small box called Flic Hub which can do the same job as the Flic application. You only need to power it with a simple USB charger and to connect it to your network. We tested it, it works furiously well. However, you still need to run the Flic application on your phone to configure the Flic Hub.

The Flic Hub
The Flic Hub



Usage, option 3: Yocto-Flic

It so happens that Shortcut Labs also provides an SDK to interface these buttons. We obviously took advantage of it to write out own control application for Flic buttons which we called Yocto-Flic. We wrote it in Python, it implements a small web server which can drive various Yoctopuce actuators: relays, servo outputs, buzzers, 4-20mA outputs, and 0-10V outputs.

We wrote our own control application
We wrote our own control application



Having our own application to drive Yoctopuce modules enables us to do without the original application and its shady confidentiality, but it also enables us to have a configuration interface somewhat more user-friendly than having to type the URLs by hand.

We developed this application with and for a Raspberry Pi 3 B+. The advantage of the Raspberry Pi is that we can let it run own its own in a corner, and as we also mounted a Raspberry Pi PoE HAT, we only need a UTP cable with PoE to make it work without a mains socket nearby. This being said, it's probably possible to make Yocto-Flic work under Windows 10, but we didn't try.

Installing the Yocto-Flic application

To take advantage of our Yocto-Flic application, you must first download the SDK from GitHub. If, at the time of reading this post, the archive has disappeared, you can find a backup copy here. Unzip the archive content wherever you want on your Raspberry Pi, read the readme.md file and then go to the bin/armv6l/ directory and run the command

sudo setcap cap_net_admin=ep ./flicd


for the server to access the Bluetooth adapter, you need to do this only once. Then start the Flic server with the command

./flicd -f flic.sqlite3


When this server, provided precompiled by Shortcut Labs, is running, it takes care of Bluetooth communications with Flic buttons.

Then, download Yocto-flic from gihub, unzip the archive content wherever you want and run the application with the command

python3 Yocto-flic.py


Note that you can use systemd to automatically run the two processes when the Raspberry Pi starts up.

Yocto-Flic creates a web server on port 8081 of your Raspberry Pi which makes it usable from any device which can run a reasonably recent web browser.

Using Yocto-Flic

To use Yocto-Flic, simply connect yourself to port 8081 of your Raspberry Pi with a web browser. Thus, if the IP address of your Raspberry Pi is 192.168.1.70, the URL to access the application is

http://192.168.1.70:8081



The interface allows you to pair buttons and to add IP addresses of YoctoHubs or VirtualHubs. The application finds on its own the compatible Yoctopuce actuators connected to these hubs and spontaneously proposes them when you configure the button actions.

Example of the configuration of a relay in Yocto-Flic
Example of the configuration of a relay in Yocto-Flic



Yocto-Flic doesn't need the servers of Shortcut Labs to work, apart during the pairing of the buttons and the Raspberry Pi. But as you don't need a Shortcut Labs account with the SDK, this action stays quite anonymous.

We made you a small demo of the working system which features the WiFi extension cord we made 3 weeks ago and a Yocto-buzzer.

  





Conclusion: what we think of Flic buttons

Nothing to complain about feature-wise: it works, it's stable, and it's pretty convenient to drive small devices anywhere in our premisses. Shortcut Labs marketing is rather efficient and fun, their pre-campaign for version 2 of the Flic buttons is literally worth points. On the other hand, it's not quite as neat behind the scenes. Their SDK works but the associated documentation is rather incomplete, we had to wait for more than a week to obtain answers on their developer forum. There is this application which forces you to provide Shortcut Labs with data which are certainly not required to the good working of these buttons. Finally, the pairing requiring a connection to Shortcut Labs servers: if this company disappears, the buttons may become useless in the short term.

However, to be totally objective, we must say that Shortcul Labs promised in its kickstarter campaign that the buttons Version 2 won't have these confidentiality issues.

Now, that's a good idea. (screen shot of the Kickstarter campaign for Flic 2)
Now, that's a good idea. (screen shot of the Kickstarter campaign for Flic 2)



Add a comment No comment yet Back to blog












Yoctopuce, get your stuff connected.