Skip to content

meri-imperiumi/signalk-bluetooth-anchor-button

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

Bluetooth button for controlling Signal K

This repository is an example on how to control a Signal K boat computer system using a cheap Bluetooth "camera shutter" button. Use case is starting the anchor alarm more conveniently:

  • Single button click to set anchor and start watch
  • Double click to stop anchor watch

Camera button

Hardware

Pairing the button

Set the camera button On.

SSH to your Raspberry Pi and discover the device:

$ hcitool scan
Scanning ...
XX:XX:XX:XX:XX:XX Camkix Shutter

Note down the Bluetooth ID shown for the button (the name and model may be different depending what button you bought).

Then pair and trust the button as a "Bluetooth keyboard":

$ sudo bluetoothctl
[bluetooth]# pair XX:XX:XX:XX:XX:XX
[bluetooth]# connect XX:XX:XX:XX:XX:XX
[Camkix Shutter]# trust XX:XX:XX:XX:XX:XX

Now you can run udevadm to see the device connection and disconnection events when turning it on and off:

$ udevadm monitor --environment
KERNEL[7000.708383] add      /devices/platform/soc/xxxxxxxx.serial/tty/ttyAMA0/hci0/hci0:11 (bluetooth)
ACTION=add
DEVPATH=/devices/platform/soc/xxxxxxxx.serial/tty/ttyAMA0/hci0/hci0:11
SUBSYSTEM=bluetooth
DEVTYPE=link
SEQNUM=1358

...

Software setup

Please note that this repository will not work for your hardware out of the box. You will need to adapt at least the udev and systemd files to match your hardware identifiers. Clone this repository to /home/pi/kbd and adapt the files to your liking. Note: You need to add your device ID to the listener.py file.

Install the dependencies with:

$ pip3 install -r requirements.pip

Copy the systemd service file in place and reload:

$ sudo cp systemd/signalk-bluetooth-button.service /etc/systemd/system
$ sudo systemctl daemon-reload

Copy the udev rules in place and reload udev:

$ sudo cp udev/99-camerabutton.rules /etc/udev/rules.d/
$ sudo service udev restart
$ sudo udevadm trigger

Now you should see the Python script starting and running whenever the Bluetooth button is turned on:

$ journalctl -u signalk-bluetooth-button -f
Mar 04 12:02:23 curiosity-pi systemd[1]: Starting Listen to Bluetooth camera button events...
Mar 04 12:02:24 curiosity-pi listener.py[1356]: Connected to button
Mar 04 12:02:27 curiosity-pi listener.py[1356]: Click, drop anchor
Mar 04 12:02:28 curiosity-pi listener.py[1356]: ok
Mar 04 12:03:46 curiosity-pi listener.py[1356]: Double click, raise anchor
Mar 04 12:03:46 curiosity-pi listener.py[1356]: ok
Mar 04 12:04:51 curiosity-pi listener.py[1356]: Disconnected
Mar 04 12:04:51 curiosity-pi systemd[1]: signalk-bluetooth-button.service: Succeeded.

About

Set Signal K anchor using a Bluetooth camera remote button

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages