As a weekend project, I decided to select an implementation of a big red button based on Thunderboard Sense and Samsung Artik 5. Why a big red button? Because everybody likes red buttons. About it even make films (The Box, 2009).
Sorry for any possible mistakes - I am not a native English speaker/writer. By the way this article there is in russian language.
What is needed for the project
- Big red button - for this all was conceived. The button should to be normally open
Setup Thunderboard Sense
Fortunately, we do not need to change anything in the code of the Thunderboard Sense, otherwise it would become a headache - Bluetooth SDK to this device requires an IAR ARM 7.80 compiler, that for many would be a big problem.
As an actuator will act SW1 button - on this button will be tied up all logic of own project.
Default firmware do not need any changes because it have following logic:
- Board sleep in inactive state and can't accept incoming connections. For change it mode to connectable mode need to push SW1.
- After push on SW1 green led start blink there is a possibility for connect to it.
- When disconnect is happened Thunderboard Sense again going to sleep.
Thunderboard Sense provides various BLE services and characteristics (full list available in Android App repository). For us interested only one characteristic - CHARACTERISTIC_PUSH_BUTTONS, which have UUID fcb89c40-c601-59f3-7dc3-5ece444a401b and constist from one value uint8_t, with following states:
- Zero (=0) if no buttons was pressed;
- One (=1) if SW1 was pressed;
- Two (=2) if SW2 was pressed;
- Three (=3) if was pressed both SW1 and SW2;
It is noteworthy that this characteristic has only read property which leads us to the solution of a periodic value reading.
Setup Artik 5
If it a first-time work with Artik 5 then you need to basic setup according to Quick Start Guide. For start developing you should upgrade to latest firmware and setup internet connection.
Pre-installed packet manager for OS Fedora on Artik is dnf so all following instructions will be for it.
First install all software needed for Bluetooth:
dnf install bluez bluez-libs bluez-libs-devel
Besides install Git:
dnf install git
Futher install Node.JS and npm:
dnf install nodejs npm
After this we need to install main module for work with BLE - noble - this module allows to serve BLE connections in case when controller have to do a central role.(for inverse situation there is the bleno module):
npm install noble
Now we ready for coding!
Pairing
For pairing devices we need to use the interactive util bluetoothctl. First start it:
bluetoothctl
After starting we need to switch on a pairing possibility:
pairable on
Then we should activate Thunderboard sense by pressing on SW1 and start scanning:
scan on
Target device we can determine by friendly name or by address.
When the needed device is finding we should stop the scanning:
scan off
The most important for us - remember the address of own Thunderboard Sense and execute following commands:
pair 00:0B:57:36:71:82 trust 00:0B:57:36:71:82 connect 00:0B:57:36:71:82
At this stage we get message "Connection successful" and now we can request information about connected device:
info 00:0B:57:36:71:82
Output will be similar to my:
Now input:
exit
and ... we ready to write code on Node.JS!
Work with Bluetooth on Artik 5
noble allows develop code for central device. So we have to implement following logic for work with Thunderboard Sense:
- Scanning for finding connectable Thunderboard Sense.
- Connect to device with a known address.
- Gettings lists of services and characteristics.
- Read the buttons characteristic's value.
If you need only working code - go to https://bitbucket.org/sithings/app_thunderboardtoartik
Connect big red button to Thunderboard Sense.
I have this kind of the button:
Interesting fact - the button is more expensive than Thunderboard Sense Kit.
Connect the button by soldering as described on a following scheme:
In my case, it looks like this:
Video of the work
Links







Comments