The shutter of iPhone cameras can be remotely released with volume_up_key_code 115. For example, the small remote shutters send bluetooth command volume_up_key_code 115 to release the camera shutter. My goal is to remote control the shutter of iPhone camera from a Python3 code running in a Raspberry Pi 5.
The Bluetooth part, however, seems to be tricky. Although I have a Bluetooth connection between the Raspberry Pi and the iPhone, and furthermore, although bluetoothctl
and thereafter devices
commands show me the connection is established, I have not managed to create a python code that recognised the connection.
I’ve installed Bluez
and Bleak
–installing PyBluez
to Raspberry Pi5 does not seem to work–- and have tried to create python code with bleak
but, for example, the following code already fails in connecting to the iPhone. Is anybody able to help and suggest what is the issue?
import asyncio
from bleak import BleakClient
# Replace with your mobile phone's Bluetooth address
DEVICE_ADDRESS = "XX:XX:XX:XX:XX:XX" # here I set the actual iPhone DEVICE_ADDRESS
# UUID for the characteristic that accepts keyboard input
CHARACTERISTIC_UUID = "00002a4d-0000-1000-8000-00805f9b34fb"
# Key code for "volume up"
VOLUME_UP_KEY_CODE = 115
async def send_volume_up_command(address):
async with BleakClient(address) as client:
if client.is_connected:
print(f"Connected to {address}")
# Send the volume up key code
await client.write_gatt_char(CHARACTERISTIC_UUID, bytearray([VOLUME_UP_KEY_CODE]))
print("Volume up command sent")
else:
print(f"Failed to connect to {address}")
loop = asyncio.get_event_loop()
loop.run_until_complete(send_volume_up_command(DEVICE_ADDRESS))
LarryFX is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.