thomasdc
Posts: 4
Joined: Thu Feb 19, 2015 10:05 am

using Multiple pi's as slaves

Thu Feb 19, 2015 10:19 am

hi!

i'm working on a home automation project but im pretty new to the rpi world..

i have 1 pi working, where i have some relays connected on, those i can acces by a webpage ( i only have really basic html knowledge)

this works all very well (nothing complicated, just some buttons to control the relays)

but now i want to expand this... I want to use different pi's on different locations in the house
but i want to be able to access them all from just one webpage

i'm used to work with PLC's and i want to use some kind of master (also a rpi) that controls the other pi's as slave.
so i only have to run the one webserver on the master and that way i can control all the pi's from the one master pi webpage

(for people who are familiar with profinet, i'm kinda looking for this system: 1 io-controller, several io devices, the controller controls them all over tcp/ip)

kind regards,
Thomas

User avatar
joan
Posts: 15038
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: using Multiple pi's as slaves

Thu Feb 19, 2015 10:29 am

My pigpio Python module allows control of multiple Pis from one script over TCP/IP. The module can run on Windows, Macs, or Linux (including the Pi).

User avatar
emgi
Posts: 357
Joined: Thu Nov 07, 2013 4:08 pm
Location: NL

Re: using Multiple pi's as slaves

Thu Feb 19, 2015 11:42 am

joan wrote:My pigpio Python module allows control of multiple Pis from one script over TCP/IP. The module can run on Windows, Macs, or Linux (including the Pi).
You don't happen to have a C-version of that module which works with PiFace Digital :?:
Would be enough if it works on a single Pi. :mrgreen:

/emgi

User avatar
joan
Posts: 15038
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: using Multiple pi's as slaves

Thu Feb 19, 2015 11:54 am

emgi wrote:
joan wrote:My pigpio Python module allows control of multiple Pis from one script over TCP/IP. The module can run on Windows, Macs, or Linux (including the Pi).
You don't happen to have a C-version of that module which works with PiFace Digital :?:
Would be enough if it works on a single Pi. :mrgreen:

/emgi
I don't know anything about PiFace Digital. pigpio only works on the Pi's gpios. You'd need something like wiringPi and its extensions to work with PiFace Digital.

That said there is http://abyz.co.uk/rpi/pigpio/pdif.html which is a C I/F to the pigpio daemon modelled on the Python module (one Pi only though).

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: using Multiple pi's as slaves

Fri Feb 20, 2015 3:04 pm

thomasdc wrote:hi!

i'm working on a home automation project but im pretty new to the rpi world..

i have 1 pi working, where i have some relays connected on, those i can acces by a webpage ( i only have really basic html knowledge)

this works all very well (nothing complicated, just some buttons to control the relays)

but now i want to expand this... I want to use different pi's on different locations in the house
but i want to be able to access them all from just one webpage

i'm used to work with PLC's and i want to use some kind of master (also a rpi) that controls the other pi's as slave.
so i only have to run the one webserver on the master and that way i can control all the pi's from the one master pi webpage

(for people who are familiar with profinet, i'm kinda looking for this system: 1 io-controller, several io devices, the controller controls them all over tcp/ip)

kind regards,
Thomas
I do something similar with my home automation project. No web page, but one master node controlling (reading sensors, etc) other Pis around the house. I set it up to SSH into each other Pi, do what it needs, and log back out.
If you can get your web page to run a script at the command line, you can do it. Look up the following topics:
Running remote commands via SSH (You'll get the command's result back just as if you ran the command locally, so you can use it to read sensors, too.)
Setting up SSH public/private key pairs (So that you don't need a password each time.)

Have fun!

User avatar
DougieLawson
Posts: 39788
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: using Multiple pi's as slaves

Fri Feb 20, 2015 4:38 pm

thomasdc wrote:... i want to use some kind of master (also a rpi) that controls the other pi's as slave.
so i only have to run the one webserver on the master and that way i can control all the pi's from the one master pi webpage
Looks like a job for MQTT.

http://MQTT.org
http://Mosquitto.org
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

richrarobi
Posts: 271
Joined: Sun Feb 08, 2015 1:13 pm

Re: using Multiple pi's as slaves

Fri Feb 27, 2015 9:58 pm

I have one pi running lighttpd (pi-00), and ruby is enabled for cgi (among other languages) - currently a single experimental web page is being used to control an mpc/mpd radio on a second pi (pi-01). The only hack I needed was to add www-data into the sudoers list using sudo visudo (I wouldn't recommend this for a public facing system in case it opened a security risk!) The web page has a few forms and buttons, including stop for the mpd, they are sent back to the same web page that checks for POST or normal (note the web page runs on pi-00 NOT pi-01).
scrnshot panel m.png
scrnshot panel m.png (41.89 KiB) Viewed 8609 times
Here's your magic key in the POST section (note it is Ruby code) it will work the same in python, Perl, etc (back ticks for system command and note the -u pi (this is user www-data acting as user pi):-

Code: Select all

  elsif cgi.has_key? ( 'down' )
    output = `sudo -u pi ssh pi-01.local "mpc volume -5"`
It does work - I can sit at my windows laptop, hit the button on the web page, and pi-00 tells pi-01 to turn the volume down. I removed shutdown - didn't like it there!
RichR
p.s. I plan to use one pi as central control for the others, running sensors, etc.
P.p.s I also have public / private keys setup between pi's
Last edited by richrarobi on Sun Mar 01, 2015 2:39 pm, edited 4 times in total.

KenT
Posts: 758
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
Contact: Website

Re: using Multiple pi's as slaves

Fri Feb 27, 2015 10:03 pm

How about Open Sound (System) Control (OSC), in particular pyOSC. Its a lightweight flexible protocol working over UDP or TCP. I think there is already an OSC to GPIO controller somewhere.
Pi Presents - A toolkit to produce multi-media interactive display applications for museums, visitor centres, and more
Download from http://pipresents.wordpress.com

thomasdc
Posts: 4
Joined: Thu Feb 19, 2015 10:05 am

Re: using Multiple pi's as slaves

Fri Mar 06, 2015 4:30 pm

thanks for all the reactions!

now im just using a java based gpio control webpage on the one Rpi (webIOPI) this is really simple to use.

but I can also let it run some macro's on this pi thanks to webIOPI...
so it must be possible to make a macro with code to connect to a remote pi over ssh
and then it executes on that remote pi some code to control the io pins?

I dont think this should be hard to create.

is there someone that can help me with the code i should use in my macro?
or give me a link to a good tutorial for this?

so the code should do something like this I think:

make connection over ssh to the remote Rpi and log in to it,
and then run the code to set a gpio high or low on this remote Rpi
close the connection again

this should work to control a remote output I supose?

this is extra:
and what should i do for inputs? (example i want to see the temperature from a sensor on the remote Rpi on the webpage from the first Rpi) let this remote Rpi connect to the 1ste Rpi every 5 minutes over ssh and send the temperature to a variable on the first Rpi, a variable that i can use in my webpage? or isn't this the right way to do?


kind regards,
Thomas

scotty101
Posts: 4052
Joined: Fri Jun 08, 2012 6:03 pm

Re: using Multiple pi's as slaves

Fri Mar 06, 2015 6:33 pm

Domoticz (A home automation program) supports slave devices.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

richrarobi
Posts: 271
Joined: Sun Feb 08, 2015 1:13 pm

Re: using Multiple pi's as slaves

Wed Mar 18, 2015 8:13 pm

ssh <remote system> <command>
This will attach just for the duration of the command. With this you could run a program with a parameter for your options.
If you setup your remote ssh keys, you will not need to supply passwords
RichR

thomasdc
Posts: 4
Joined: Thu Feb 19, 2015 10:05 am

Re: using Multiple pi's as slaves

Wed Mar 18, 2015 9:09 pm

thanks for al the reactions!

I just started using domoticz and its really simple and can still do complex things (running scripts) with it if you want

thanks for the tip!
scotty101 wrote:Domoticz (A home automation program) supports slave devices.

HappyEngg
Posts: 1
Joined: Sun Sep 24, 2017 1:28 am

Re: using Multiple pi's as slaves

Thu Oct 05, 2017 7:17 am

Is it possible to connect two raspberry pi's GPIO remotely through some cloud and pigpio?
Like I give input to one raspberry pi and get output on another raspberry pi.
But both raspberry pi's should be connected on different network.
Please help me!!

Return to “Automation, sensing and robotics”