how to remotely control raspberry pi gpio - python

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.

Related

Remote bluetooth camera trigger for phone

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

Pulling specific MAC/IP-addresses from Wi-fi router and directed them to a Raspberry Pi?

The purpose of our project is to “sniff” for specific MAC/IP-addresses so we can use the MAC/IP-addresses to turn off or on the alarm system.
The idea is to automate the alarm system in “our house”. We have one raspberry Pi with installed Linux Mate that we are going to use to monitor the network with, one Raspberry Pi to turn on and off the alarm and a router for WLAN for the devices to connect.
We would have rather used MAC addresses over IP addresses as it probably is more secure, but MAC addresses are probably harder to manage.
We are using a TP-Link tl-wr841nd.
Does anyone have tips on how we can progress in this matter?

How I should access webcam connected to raspberry pi in my laptop (python) via web(wifi)?

Hi? I'm making some camera-based application using raspberry pi.
Since rpi is not as powerful as I had expected, I decided to process the image in my laptop.
Unfortunately, it is unable to connect the camera and my laptop directly.
I would like to read an image from camera on rpi, and send the image to my laptop (via web server using wifi) and process the image on my laptop (in python programming, opencv or some related libraries are preferable).
How should I do this? I could find some related examples, but all of them did not fit perfect with my application...

how to connect a programmed raspberry pi to a Kaa platform?

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.

Communicate between iOS app and Raspberry Pi via Bluetooth

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.

Categories

Resources