How to Automate light Strips

Latest Comments

Uncategorized

This guide is how to automate a light strip using Bluetooth LE

What you will need …..

  • Raspberry Pi Zero W – Already connected and running
  • Govve Light strip Indoor/outdoor
  • The scripts !

Step 1

Locate the mac address of your light strip by doing the following:

  • login in to the pi
  • Run the command bluetoothctl
  • Run scan on
    You should then get something like the below, make a note of the mac.

Step 2

Copy and paste the below into a file called Christmas.sh

#!/bin/bash

# Array of commands to execute
commands=(
    "echo 'Blue'" "gatttool -b A4:C1:38:37:2E:31 --char-write-req --handle 0x0015 --value 3305020000FF00000000000000000000000000CB > /dev/null"
    "echo 'Red'" "gatttool -b A4:C1:38:37:2E:31 --char-write-req --handle 0x0015 --value 330502FF000000000000000000000000000000CB  > /dev/null"
    "echo 'Green'" "gatttool -b A4:C1:38:37:2E:31 --char-write-req --handle 0x0015 --value  33050200FF0000000000000000000000000000CB > /dev/null"

)

# Infinite loop to repeat the commands
while true; do
    # Loop through the commands
    for command in "${commands[@]}"; do
        # Execute the command
        eval "$command"

        # Sleep for 500ms (0.5 seconds)
        sleep 0.5
    done
done


Step 3

Replace the mac address seen in bold above with the MAC of your light strip.

Step 4

Run the command with the following syntax

./Christmas.sh

Tags:

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *