简体   繁体   English

带有笔记本电脑输入和 Raspberry Pi 输出的远程 GPIO (Pigpio)

[英]Remote GPIO (Pigpio) with input from laptop and output from Raspberry Pi

I'm working on an object detection project for IoT using a webcam and servo.我正在使用网络摄像头和伺服器进行物联网对象检测项目。 In short, when the object detected by the webcam matches the data in the system, the servo will move.简而言之,当网络摄像头检测到的物体与系统中的数据匹配时,舵机就会移动。 Can the webcam be connected to the laptop, and the servo on the Raspberry Pi?网络摄像头可以连接到笔记本电脑和树莓派上的伺服系统吗? So the input is from the laptop and the output is on the Raspberry Pi using pi-gpio (Remote GPIO).因此输入来自笔记本电脑,输出在使用 pi-gpio(远程 GPIO)的 Raspberry Pi 上。 How to?如何? Thanks.谢谢。

A quick way is to use the Python socket library.一种快速的方法是使用 Python套接字库。 Both devices need to be connected to the same network, and the sender needs to know the IP address of the receiver.两台设备需要连接到同一个网络,发送方需要知道接收方的IP地址。

This link shows the GPIO Zero library being used with pigpio to allow remote control of the GPIO pins, from either another raspberry pi - or a PC.链接显示了与 pigpio 一起使用的 GPIO Zero 库,以允许从另一个树莓派或 PC 远程控制 GPIO 引脚。 Once you configure GPIO Zero to use the pigpio library and connect, I believe you can just use the GPIO Zero libraries as per normal to control the Servo.一旦您将 GPIO Zero 配置为使用 pigpio 库并进行连接,我相信您可以正常使用 GPIO Zero 库来控制伺服。 (though I have not tried this myself!) (虽然我自己没有试过这个!)

However I would probably use MQTT to decouple the two systems.但是我可能会使用 MQTT 来解耦这两个系统。 If you run an MQTT broker on the Raspberry Pi (eg. Mosquitto) then the webcam software can publish a message to the MQTT broker, and the raspberry pi software can subscribe and act accordingly.如果您在 Raspberry Pi(例如 Mosquitto)上运行 MQTT 代理,则网络摄像头软件可以向 MQTT 代理发布消息,并且 Raspberry Pi 软件可以订阅并采取相应的行动。

You can also run this with a cloud based MQTT system (eg. HiveMQ ) so the Raspberry Pi and the PC with the Webcam don't even have to be in the same location.您还可以使用基于云的 MQTT 系统(例如HiveMQ )运行它,这样 Raspberry Pi 和带有网络摄像头的 PC 甚至不必位于同一位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM