using joystick on one raspberry pi to control input on second raspberry pi

93 Views Asked by At

I have a raspberry pi 4(let's call it server) that's operating servos and motors on a boat. I've managed to control the boat using another raspberry pi 4( let's call it client) and connect via SSH. First remote control was via touchscreen and gui that ended up pretty useless. I wanna try control by joystick which I've placed on client side. My problem is how do I implement the signal from joystick that I get from script on client as input signal on server side? Is there a way to do that via SSH or something else? In longterm there will be a camera, radar and sensors placed on the boat. Is the websocket best solution for that type of remote control?

1

There are 1 best solutions below

0
Mark Setchell On

Personally, I think I'd set up MQTT for this which is ideal for transferring short messages and doesn't require absolute "lock-step" communication back and forth. That means you can start in any order and the second half doesn't need to necessarily be present.

I'd install mosquitto on either RasPi, and then:

  • let RasPi with devices attached subscribe to a "joystick" topic so it gets all joystick movements, and
  • let RasPi with joystick attached publish each movement on that topic.

Enter [mqtt] in the StackOverflow search box for examples.


Alternatively, you could use Redis "pub/sub" just the same.

Enter [redis] in the StackOverflow search box for examples.