Control Your Windows Computer Over BLE Using BleuIO

April 14, 2025
Control Your Windows Computer Over BLE Using BleuIO

Controlling your computer wirelessly might sound complex — but with the power of Bluetooth Low Energy (BLE) and the BleuIO dongle, it’s surprisingly simple. In this guide, we’ll walk through a creative example where you can control the brightness of your Windows PC using BLE commands sent from your mobile phone using BLE app.

What This Project Does

Using a BleuIO dongle connected to a Windows PC, we enable BLE communication using the Serial Port Service (SPS). When a BLE-enabled phone connects to the dongle and sends a value (from 1 to 10), the PC receives this data and adjusts its screen brightness accordingly — all in real-time.

It’s a simple and powerful demonstration of BLE-to-system integration, and it’s only the beginning of what’s possible with BleuIO.

Tools & Requirements

Install both with:

python -m pip install --user pyserial screen-brightness-control

How It Works

This project uses the BleuIO dongle in SPS Server mode, which allows it to receive data over Bluetooth Low Energy (BLE) from a connected device — in our case, a smartphone using the nRF Connect app.

Here’s a breakdown of how everything works together:

Initialize the Dongle on the PC ( SPS)

When you run the Python script on Windows, it sends the following commands to the BleuIO dongle via serial:

  • AT+ADVSTART → Starts advertising the dongle so it becomes discoverable over BLE.

Connect to BleuIO from Your Phone (Using nRF Connect)

On your mobile device, open the nRF Connect app:

  • Tap “Scan” and look for a device named “BleuIO”
  • Tap “Connect” to establish a BLE connection

Once connected, you’ll see a list of services and characteristics provided by the BleuIO dongle.

Identify the Correct BLE Characteristic to Send Data

In the attribute table:

  • Look for a writable characteristic under one of the unknown services.
  • You’ll often see one with the following properties:
    • Write Without Response
    • (Optionally also Notify)
  • The UUID will look like: 0783B03E-8535-B5A0-7140-A304D2495CBA

Send the SPS Command from the App

Now that you’re connected and have found the correct characteristic:

  1. Tap the write icon (↥) on that characteristic
  2. Choose “UTF-8 string” as the format (not hex!)
  3. In the message field, enter something like: AT+SPSSEND=5
  4. Tap “Send”

This sends a Bluetooth message to the BleuIO dongle, which forwards it via the SPS protocol to the Python script on your PC.

Python Script Reads and Acts on the Message

On the PC, the Python script reads the incoming SPS message and extracts the number from the AT+SPSSEND= command. It then adjusts your screen brightness using the screen-brightness-control library.

For example:

  • Sending AT+SPSSEND=1 → brightness set to 10%
  • Sending AT+SPSSEND=5 → brightness set to 50%
  • Sending AT+SPSSEND=10 → brightness set to 100%

Repeating

You can send new values anytime while connected — and your computer will respond instantly by updating the brightness accordingly.

Full Python Script

Here’s the script used in the project:

import serial
import time
import screen_brightness_control as sbc

BLEU_IO_PORT = "COM4"  # Update this to match your BleuIO COM port
BAUD_RATE = 9600

def set_brightness(level):
    brightness = int(max(10, min(100, level * 10)))
    try:
        sbc.set_brightness(brightness)
        print(f"Brightness set to {brightness}%")
    except Exception as e:
        print(f"Failed to set brightness: {e}")

def setup_bleuio(ser):
    commands = [
        b'AT+SPS=1\r\n',
        b'AT+ADVSTART\r\n'
    ]
    for cmd in commands:
        ser.write(cmd)
        time.sleep(0.5)
    print("BleuIO is in Peripheral + SPS mode, now advertising...")

def read_message(ser):
    buffer = ""
    while True:
        if ser.in_waiting:
            data = ser.read(ser.in_waiting).decode("utf-8", errors="ignore")
            buffer += data
            while "\r\n" in buffer:
                line, buffer = buffer.split("\r\n", 1)
                yield line.strip()
        else:
            time.sleep(0.1)

def process_message(msg):
    if not msg or msg.startswith("AT+") or "Invalid" in msg or "CONNECTED" in msg or "ADVERTISING" in msg:
        return

    print(f"Received message: '{msg}'")
    try:
        if "=" in msg:
            _, value = msg.split("=", 1)
        else:
            value = msg
        val = int(value.strip())
        if 1 <= val <= 10:
            set_brightness(val)
        else:
            print("Value out of range (1–10)")
    except ValueError:
        print("Invalid message format")

def main():
    try:
        with serial.Serial(BLEU_IO_PORT, BAUD_RATE, timeout=1) as ser:
            setup_bleuio(ser)
            print("Waiting for BLE messages via SPS from your phone...")
            for msg in read_message(ser):
                process_message(msg)
    except serial.SerialException as e:
        print(f"Serial error: {e}")
    except KeyboardInterrupt:
        print("Exiting...")

if __name__ == "__main__":
    main()

What is SPS on BleuIO?

SPS stands for Serial Port Service, a custom BLE profile supported by BleuIO to send and receive data like a UART over BLE.

Key SPS AT Commands:

  • AT+SPSSEND=message → Sends data via BLE from client to host or vice versa

In our case, the mobile phone is the BLE client sending data to BleuIO, which is the peripheral/server.

Use Cases & Future Ideas

This project is just the beginning! Here are more ways to expand on it:

  • Control volume using BLE
  • Send commands to launch apps or toggle Wi-Fi
  • Build a BLE-based authentication system for login or locking/unlocking the screen
  • Lock/sleep windows computer

Controlling your computer via Bluetooth from a phone is now as easy as a few lines of Python and a BLE dongle like BleuIO. This project is a great foundation for building more interactive, wireless automation solutions — from IoT control panels to personal smart systems.

Share this post on :

Leave a Reply

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

Follow us on LinkedIn :

Order Now