Jump to content

Hiya, 

 

I'm currently in the process of getting a light system ready for use in a school that I work in. I have three Raspberry Pi's running Rasbian that have to do exactly the same job, except, for that fact that they will all be situated in very different areas of the school. 

 

I have the Python code currently working from the Pi's themselves however I am stuck on how to control the lighting from another computer in one go. The Pi's will be networked individually but ideally I'd like them to be controlled through simply running a script on another computer. I'd rather not have a web interface as this involves a whole set of other things that I'd have to put in place since we don't want the kids accessing the page. Sure, VNC works but it would mean that a member of the IT team such as me has to remote into each of the Pi's separately and run the desired scripts that I've made. It would be great if a non-IT member could change this hence why I ask. 

 

Is there a way I can run a single script (such as on a users desktop) to change the lights of the Pi's all at once? Sorry for the long winded question and back story. 

 

Cheers, Brennan. 

IT Manager working in the Education sector. 

Link to comment
https://linustechtips.com/topic/1155088-raspberry-pi-led-control/
Share on other sites

Link to post
Share on other sites

Only have one Raspberry Pi myself, and all I wanted was to keep built-in LEDs turned off... you probably mean some external connected lights? I personally think we have way too many shinning stuff around us already...

I believe you get more control if you network boot all the client Raspberry Pi SBC's from single master computer, sure makes updating easier...

https://raspberrypi.stackexchange.com/questions/87262/netbooting-multiple-workers-rpi-from-a-master-rpi

 

Quote
  1. Create a JavaScript web UI.
  2. Modify the Raspberry Pi code to take the values from the web UI to control LEDs in realtime.                                                                         https://www.pubnub.com/blog/building-raspberry-pi-smart-house-part-2/                                                                                                        https://github.com/pubnub/pi-house/blob/gh-pages/python/pwm-led-gpio.py

 

Link to post
Share on other sites

4 hours ago, Brennan Price said:

Hiya, 

 

I'm currently in the process of getting a light system ready for use in a school that I work in. I have three Raspberry Pi's running Rasbian that have to do exactly the same job, except, for that fact that they will all be situated in very different areas of the school. 

 

I have the Python code currently working from the Pi's themselves however I am stuck on how to control the lighting from another computer in one go. The Pi's will be networked individually but ideally I'd like them to be controlled through simply running a script on another computer. I'd rather not have a web interface as this involves a whole set of other things that I'd have to put in place since we don't want the kids accessing the page. Sure, VNC works but it would mean that a member of the IT team such as me has to remote into each of the Pi's separately and run the desired scripts that I've made. It would be great if a non-IT member could change this hence why I ask. 

 

Is there a way I can run a single script (such as on a users desktop) to change the lights of the Pi's all at once? Sorry for the long winded question and back story. 

 

Cheers, Brennan. 

You're using python, right? Make those devices listen continuously to something on firebase, like a single document with a single field that has the status of the lights, and have your desktop script to be able to edit this field to on or off.

FX6300 @ 4.2GHz | Gigabyte GA-78LMT-USB3 R2 | Hyper 212x | 3x 8GB + 1x 4GB @ 1600MHz | Gigabyte 2060 Super | Corsair CX650M | LG 43UK6520PSA
ASUS X550LN | i5 4210u | 12GB
Lenovo N23 Yoga

Link to post
Share on other sites

On 2/13/2020 at 1:56 PM, RageTester said:

Only have one Raspberry Pi myself, and all I wanted was to keep built-in LEDs turned off... you probably mean some external connected lights? I personally think we have way too many shinning stuff around us already...

I believe you get more control if you network boot all the client Raspberry Pi SBC's from single master computer, sure makes updating easier...

https://raspberrypi.stackexchange.com/questions/87262/netbooting-multiple-workers-rpi-from-a-master-rpi

 

 

Hiya, 

 

Thanks for the response. I have LED's attached to my Pi's separately so they are not on the Pi's themselves, I can send pictures of how they are set up if need be. As for network boot, I am not sure if it will work as I am using two different types of Pi :/ 

 

Cheers, Brennan. 

IT Manager working in the Education sector. 

Link to post
Share on other sites

On 2/13/2020 at 5:18 PM, igormp said:

You're using python, right? Make those devices listen continuously to something on firebase, like a single document with a single field that has the status of the lights, and have your desktop script to be able to edit this field to on or off.

Hiya, 

 

This sounds like a great idea... Although I'm not entirely sure how I'd go about doing this... I've opened up FireBase but am not entirely sure where to begin if I'm honest :/ 

 

Cheers, Brennan. 

IT Manager working in the Education sector. 

Link to post
Share on other sites

53 minutes ago, Brennan Price said:

Hiya, 

 

This sounds like a great idea... Although I'm not entirely sure how I'd go about doing this... I've opened up FireBase but am not entirely sure where to begin if I'm honest :/ 

 

Cheers, Brennan. 

This link should be helpful.

FX6300 @ 4.2GHz | Gigabyte GA-78LMT-USB3 R2 | Hyper 212x | 3x 8GB + 1x 4GB @ 1600MHz | Gigabyte 2060 Super | Corsair CX650M | LG 43UK6520PSA
ASUS X550LN | i5 4210u | 12GB
Lenovo N23 Yoga

Link to post
Share on other sites

  • 3 weeks later...

Hi there, just two ideas:

Are the python scripts controlling the lights just called if something shall change?

 

e.g.:

light.py on
light.py off
light.py disco

You could use a shell script and ssh (batch file and putty on Windows ? ) to send the commands to the Raspberry Pi's.

Something like:

$> cat remotelight.sh
#! /usr/bin/env bash
shh user@Pi_one "light.py $1" &
shh user@Pi_two "light.py $1" &
shh user@Pi_three "light.py $1" &


$> remotelight.sh on

At this point it's handy to have look at 'passwordless login' with ssh. Then you will not need to type in the password three times, just distribute the key file along with the script. ( I cannot quite remember, but it is (was?) a little bit more complicated with putty (location of the key file? format of the key file?), but still possible).

Maybe add an extra 'lightuser' that runs the scripts and ssh's into the Raspberry Pi's.

 

Or...

...are the python scripts controlling the lights running constantly in the background (daemons)?

Then you could "add a python socket sever" to the scripts that listens for remote commands.

A simple implementation is not very difficult, just "learned" it myself for a home project.

But it's not as secure as an ssh connection. If you " [...] don't want the kids accessing [the page.]" but someone with a port scanner gets intrigued by what might be hiding behind that open port, you might end up with 'light.py disco' all the time.

SSH tunneling, an authentication back-end and/or encryption for the python socket sever might be a little over the top for this project.

 

Cheers.

"There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here,

it will instantly disappear and be replaced by something even more bizarre and inexplicable.

 

There is another theory which states that this has already happened."

― Douglas Adams, The Restaurant at the End of the Universe

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×