Gesture-Controlled Light Switch with Bluetooth Low Energy (BLE)
COVID-19-safe controller: switch lamps and other devices on and off by using gestures instead of pressing buttons (on a remote control).
Today, with the coronavirus going on and the whole world being locked down, touchless control probably has a bright future as it can help prevent contamination through physical contact. As I had two Tactigon One wireless motion controller modules lying on my desk, I thought it would be a good opportunity to try to use them for controlling something without touching it.
The Tactigon One 'Wearable Gesture & Motion Controller' from Next Industries (Italy) is a kind of 3D wireless mouse that lets you control a computer or some other device or machine with gestures. It features Bluetooth Low Energy (BLE) and has 3D motion sensors in the shape of a gyroscope, accelerometer and magnetometer. It also comes with a rechargeable Li-Ion battery and some other stuff.
The device to control that I quickly cobbled up consists of two mains-powered lamps where each lamp is switched by a solid-state relay. The reason for this was that I had a suitable module for that left over from a previous project.
The Tactigon communicates over Bluetooth and so I set up my Raspberry Pi 4 for this as it has Bluetooth built in.
The software for the device itself can be written in the Arduino IDE thanks to a special Boards Package.
Preparing the Raspberry Pi for Bluetooth is, unfortunately, a project in itself. It starts by installing the BlueZ protocol stack. The first time I tried I apparently did something wrong and I ended up in a library dependency war with bluealsa. The second time, on a fresh Pi operating system, I did not run into bluealsa, and evertyhing went fine.
You must also install bluepy so you can use BLE with Python. However, it seems that the current version 1.3.0 of bluepy doesn’t work with my setup, and I had to install version 1.2.0 instead. This means that you cannot “pip install” it, but you have to build it yourself from the source code and then install it, like this:
I based my remote control on an example from the Tactigon website. I modified the Arduino sketch to better define the gestures. For toggling the lamps, I created a kind of key turn gesture. Turn right to light the lamp on the right, turn left to light the other. To switch them both on you flip the board up, to switch both lamps off, flip the board down. Actually, these are not really gestures, because when you keep the board steady in the same position, the command will be repeated every 500 ms.
When a gesture is detected it is transmitted as a two-byte value to the client who will decode it and take the corresponding action, which is in this case switching on or off one or two lamps.
The BLE client must be paired to the Tactigon so that only one device is authorized to control the lamps. You do this by specifying the module’s MAC address, a 12-digit hexadecimal number, on the client side.
My gesture-controlled lamps work fine. Note that this is a rather simple example of what you can do with a Tactigon One as the board features a 9D inertial measurement unit (10D with the pressure sensor) and I only used the accelerometer.
Startups: the electronica Fast Forward Award 2020 powered by Elektor
The Tactigon One 'Wearable Gesture & Motion Controller' from Next Industries (Italy) is a kind of 3D wireless mouse that lets you control a computer or some other device or machine with gestures. It features Bluetooth Low Energy (BLE) and has 3D motion sensors in the shape of a gyroscope, accelerometer and magnetometer. It also comes with a rechargeable Li-Ion battery and some other stuff.
The device to control that I quickly cobbled up consists of two mains-powered lamps where each lamp is switched by a solid-state relay. The reason for this was that I had a suitable module for that left over from a previous project.
The Tactigon communicates over Bluetooth and so I set up my Raspberry Pi 4 for this as it has Bluetooth built in.
The software for the device itself can be written in the Arduino IDE thanks to a special Boards Package.
Preparing the Raspberry Pi for Bluetooth is, unfortunately, a project in itself. It starts by installing the BlueZ protocol stack. The first time I tried I apparently did something wrong and I ended up in a library dependency war with bluealsa. The second time, on a fresh Pi operating system, I did not run into bluealsa, and evertyhing went fine.
You must also install bluepy so you can use BLE with Python. However, it seems that the current version 1.3.0 of bluepy doesn’t work with my setup, and I had to install version 1.2.0 instead. This means that you cannot “pip install” it, but you have to build it yourself from the source code and then install it, like this:
$ cd ~
$ wget https://github.com/IanHarvey/bluepy/archive/v/1.2.0.tar.gz
$ tar -xvf bluepy-v-1.2.0.tar.gz
$ cd bluepy-v-1.2.0
$ python setup.py build
$ sudo python setup.py install
$ wget https://github.com/IanHarvey/bluepy/archive/v/1.2.0.tar.gz
$ tar -xvf bluepy-v-1.2.0.tar.gz
$ cd bluepy-v-1.2.0
$ python setup.py build
$ sudo python setup.py install
I based my remote control on an example from the Tactigon website. I modified the Arduino sketch to better define the gestures. For toggling the lamps, I created a kind of key turn gesture. Turn right to light the lamp on the right, turn left to light the other. To switch them both on you flip the board up, to switch both lamps off, flip the board down. Actually, these are not really gestures, because when you keep the board steady in the same position, the command will be repeated every 500 ms.
When a gesture is detected it is transmitted as a two-byte value to the client who will decode it and take the corresponding action, which is in this case switching on or off one or two lamps.
The BLE client must be paired to the Tactigon so that only one device is authorized to control the lamps. You do this by specifying the module’s MAC address, a 12-digit hexadecimal number, on the client side.
My gesture-controlled lamps work fine. Note that this is a rather simple example of what you can do with a Tactigon One as the board features a 9D inertial measurement unit (10D with the pressure sensor) and I only used the accelerometer.
Startups: the electronica Fast Forward Award 2020 powered by Elektor
Discussion (0 commentaire(s))