Running commands on a RPi

Posted on
Tue Aug 10, 2021 7:58 pm
rustyhodge offline
Posts: 54
Joined: Nov 11, 2016

Running commands on a RPi

I need to run some commands on a remote RPi (do do things like play audio, adjust volume, etc). It would be trivial to do this by SSH'ing from a Python script to the RPi in question, but it seems like kind of a gross way to do it. I don't want to implement a full on JSON over HTTP kind of solution either.

Any thoughts on a cleaner way to do this?

Posted on
Wed Aug 11, 2021 1:03 am
rhanson offline
Posts: 192
Joined: Apr 30, 2013

Re: Running commands on a RPi

Nothing wrong with ssh, it gets the job done. You don't get a nice way to handle failures or errors, so you'll have to build that in.

Another approach is an HTTP microframework like Flask (python). If you can handle ssh commands, Flask is trivial. You would have some python code running on the Pi waiting for your http commands, and then it would execute the shell commands locally. You could handle errors and return a friendly http response code and/or success/error message.

Yet another approach is MQTT. You could just have the Pi communicate with an MQTT broker on your network, and have Indigo send it commands and process responses. There are plugins to handle this, but there's a lot of configuration and you can probably do it easier by just coding scripts to send and receive messages.

Depends on what you're trying to accomplish. If it's just simple stuff with no feedback needed, go for the simple ssh route. If you need request-response style communication, use http. And if you just want to send the Pi messages and have it send status messages back, then MQTT is the ticket.

Karl's PiBeacon plugin also lets you execute commands on a remote Pi, and can also play sound files. That can all be done via Indigo. But it might be way more than you need for something simple.

Posted on
Wed Aug 11, 2021 8:50 am
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: Running commands on a RPi

if you want to switch gpios on/off (the pins on the RPI) you can do that w remote gpio
you need to enable it in
sudo raspi-config
on the RPI
Karl

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest