I'm trying to communicate between an iOS app and Raspberry Pi using Bluetooth. The Raspberry Pi is using a Python script for this purpose.
I was originally using the PyBluez library, however this does not support Bluetooth LE and thus can't be used with CoreBluetooth on iOS.
My next solution was to use the private BluetoothManager framework to communicate with the Pi, but this doesn't work on iOS 7.
I've researched a bit more and have seen suggestions for manually sending/receiving LE packets with PyBluez, but this seems incredibly complex and I really have no idea where to start.
So at the moment, I'm stuck. I need either:
A solution to communicate with a non-LE Bluetooth device via iOS, or
A solution for advertising and communicating as a LE device on the Raspberry Pi via Python
One option is to buy a USB dongle with a BLE stack in it already.
We have used the Laird BL620-USB, flashed with BL600 firmware to operate as a BLE peripheral.
Having BLE stack in the dongle means it can be communicated with from the Raspberry Pi like a simple USB serial port, without using any linux Bluetooth stack.
BL600 includes the Nordic / Laird proprietary Virtual Serial Port Profile already, so you can achieve the simplicity similar to the classic Bluetooth SPP, even when communicating to an iOS device.
Laird will provide iOS and Android code to use the VSP on the mobile side.
Other BLE module makers probably do the same.
Have you tried this?
By default, the Wheezy distribution comes without a Bluetooth stack. The bluez package is version 4.99, which has patchy support for Low Energy.
Keep in mind at the time of writing Bluetooth Low Energy (BLE) is not well supported by the standard Raspberry Pi distributions. Some work is required to get it working, as described in the link provided above.
NewAer has built a P2P messaging framework to share 500 Bytes (SDK 5) to 15K with certain devices. That being said, we can send 15K between iOS devices, or iOS and the Raspberry Pi 3. As Android gains further OS and hardware support for BLE, we expect to ad that higher file size as well, but at this time it is limited to 500 bytes between Android and iOS.
Related
I would like to build a camera trigger for my phone by simulating a BLE keyboard that sends the Volume Up key to the phone connected by Bluetooth. I want this because I want to trigger the native Camera app, and not an embedded camera view.
I'm agnostic about technology used but ideally for simplicity I'd like it to be a command line utility in my Macbook, with something like Go or Node.js.
I've looked into Noble for Node.js, which doesn't seem to be oriented at emitting, and found projects for arduino, and found a couple of StackOverflow questions asking the same, but nothing definitive yet.
Apparently the Bleno project for Node.js could be better suited, but apparently it's very outdated.
Would someone please point me in the right direction?
Thank you
Edit
I was able to use Bleno to emit 0xEA and 0xE9 (Volume Up and Volume Down apparently), and using the LightBlue app I'm able to inspect that receive those messages, however, connecting to the MacBook through the phone's bluetooth does not increase/decrease volume.
Edit
Found this outdated project written in Swift 3 for reference
Edit Apparently the pybluez project looks like it could be a good option
You should be able to use the terminal for that. Eg. in Windows, you can start the camera app using start microsoft.windows:camera
Something similar should be available even in Mac. Try that out. Otherwise, go to the root directory where the camera app is stored. And then trigger that from code.
You need to create a Bluetooth HID (or HID over GATT) peripheral that your phone can connect to and will receive the key commands from.
There is a project here that did it with a Raspberry Pi:
https://gist.github.com/ukBaz/a47e71e7b87fbc851b27cde7d1c0fcf0#gistcomment-2997623
Unfornately the underlaying Bluetooth library will not move across to your Mac Book.
The HID protocol is documented here: https://github.com/jpbrucker/BLE_HID/blob/master/doc/HID.md
In summary, I think what your saying is that you want to make an cli application which is on your laptop/desktop connect to your phone via Bluetooth and simulate a volume key from your laptop/desktop keyboard.
Android:
To do this you will need:
Python 3.5 or above
PyBluez
Keyboard(Python module/API)
Android Studio
Java Development Kit 8 (preferably 11 or 14)
Android BLE
So in order to do this I would create a cli application with python3 and I would record the key presses on the laptop/desktop machine by using the keyboard module this then gets transmitted(bluetooth) via the PyBluez module to your phone. Your phone then accepts the bluetooth data via Android BLE and then simulates the volume button press.
DISCLAIMER:
This only works when the phone is already paired to your pc and only work on android phones 4.4.4 and above.
Some Links That Could Help You:
Bluetooth lib for python 3 ,
detect key press in python? ,
Create a socket for 4.0 bluetooth transmission
IOS:
To do this you will need:
Python 3.5 or above
PyBluez
Keyboard(Python module/API)
XCode
Swift
Core Bluetooth Module
So in order to do this I would create a cli application with python3 and I would record the key presses on the laptop/desktop machine by using the keyboard module this then gets transmitted(bluetooth) via the PyBluez module to your phone. Your phone then accepts the bluetooth data via Core Blutooth Module in swift and then simulates the volume button press.
DISCLAIMER:
The phone and laptop/desktop must be paired before it runs this might sound obvious but some people might ignore this.
Some Links That Could Help You:
iOS use the volume buttons as input ,
https://developer.apple.com/documentation/corebluetooth/transferring_data_between_bluetooth_low_energy_devices
I'm doing a face recognition project that uses opencv and python to recognize a person's face on a pc. Now, my goal is to use a raspberry pi to access one of my gpio ports, and when One face was detected in my pc then to turn on a led. My problem is how can I connect my pc to a raspberry pi and use the code that runs on my pc to run the raspberry pi gpio?
I would recommend GPIO Zero due to its excellent remote GPIO support.
I recently wrote "mqtt-gpio" which connects MQTT topics to Raspberry Pi GPIO pins. It is a general purpose connector which supports input and output pins; groups of pins; and complex inching. Configurable with YAML, and will be very easy to switch a LED on and off based on a MQTT topic.
There are prebuilt container images on Docker Hub. The docs/source are on GitHub: README.md.
I run it in K3s (but will work on Docker too) on Raspberry Pi OS. The service is built on gpiozero. At present I use it to:
drive relays for my irrigation solenoids and ball valve manipulators,
detect open/closed state of doors/windows,
and remotely press various buttons.
Setting up a MQTT broker and publishing to a MQTT is relatively easy too. You can install Eclipse Mosquitto, or just use EMQ X or other free cloud MQTT providers. Publishing to a MQTT topic from Python is also simple using the paho.mqtt library.
Working with an Adafruit FTDI 232H Breakout assembly. I've already asked at Adafruit and FTDI and I'm still clueless. Writing in Python using the Adafruit-provided libraries and the FTDI libraries. Very new to Python and the FTDI 232H device...
Using Windows 10 Pro
I am able to successfully install the 'drivers' for the Adafruit based on this tutorial (specifically the Windows portion):
https://learn.adafruit.com/adafruit-ft232h-breakout?view=all
In the end, the interface will work, but what happens is that the device seems to be locked to a physical USB port. If I move the device to another USB port on the same machine, it is not recognized.
Based on some reading I've done, it seems like the driver, although installed in Windows, can only associate with the device on one port. Some say that Windows uses the serial number to keep track of what device uses what driver.
I have observed, using USBDView, that this device is not displaying a S/N. I have other devices that do not display a serial number and they can move from port to port without issue. This leads me to believe that the S/N tracking may not be 100% true in Windows. The Adafruit board does have a S/N in the EEPROM, but for some reason that information is not being provided to Windows / USBDView. I've not been able to successfully access the EEPROM via the FTProg utility.
I suspect that this might have something to to with the libusbK library that is installed via Zadig tool (again in the instructions) but I am not sure. FTDI says that there should not be any issue using the libusbK library.
Can anyone out there give me some pointers on:
Is it accurate that Windows uses the S/N to keep track of what driver goes with what device?
If so, how to get the FTDI device to display the S/N?
Is there some other setting in Windows that needs to be changed to allow this device to be used on other physical ports?
Is there any other utility like FTProg that could be used to work with the EEPROM?
Am I just missing something simple, Noob-style?
Thank you in advance,
I seem to recall a similar case related to COM port enumeration and Windows where the COM port enumeration is a hash of assorted variables including the PCI bus #, device #, etc. We witnessed this through the Microsoft devcon utility which is priceless and is a command line version of Device Manager.
https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/devcon
https://blogs.technet.microsoft.com/deploymentguys/2009/12/16/where-to-find-devcon-exe/
If you google around, you can find the compiled version of this invaluable tool. With confidence, believe this tool will assist you to debug your USB port mystery. Good luck.
I have some sensor nodes. they are connected to a Raspberry Pi 2 and send data on it. the data on Raspberry Pi is sending the data to Thingspeak.com and it shows the data from sensor nodes.
now I am developing a Kaa server and wanna see my data (from Raspberry Pi) on Kaa. is there any chance to connect the current programmed Raspberry Pi(in Python) to Kaa?
Many thanks,
Shid
Mashid. From what I know, to use a KAA server, you should utilize the SDK obtained when you create a new application on the KAA server. This SDK also functions as an API key that will connect the device with a KAA server (on a KAA server named with Application Token). The platforms provided for using this SDK are C, C ++, Java, Android, and Objective C. There is currently no SDK for the Python platform.
I am trying to hook up a xbee on arduino and wish to run some algorithms on my linux machine and based on result of algorithmic output i ahve to communicate the commands to xbee connected to my arduino. I know we have API support to read/write xbee from Arduino platform. Does Xbee have a way to be programmed on host machine running Linux/OSx other than x-ctu software.
I wish to know if there is a way to programmatically communicate Xbee using USB dongle adapter from host machine, may be python api
I found this online http://serdmanczyk.github.io/XBeeAPI-PythonArduino-Tutorial/ and it pretty much addresses my need .