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

305 views Asked by At

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). How to? Thanks.

2

There are 2 answers

0
cguk70 On BEST ANSWER

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. 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. (though I have not tried this myself!)

However I would probably use MQTT to decouple the two systems. 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.

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.

0
elbashmubarmeg On

A quick way is to use the Python socket library. Both devices need to be connected to the same network, and the sender needs to know the IP address of the receiver.