pythonraspberry-piwirelessserial-communication

How would I open and run a python program on a raspberry pi from a main python program on a windows pc?


I am running a main python program on a Windows PC that is hooked to equipment that cannot be ran on an Raspberry pi. At a certain point in the main program, I want to call/execute a Rpi program to run. I need the GPIO pins from the Rpi to turn on a relay/s. Is there a way to wirelessly(or serially) open and run the program on the raspberry pi from the main program already running on the Windows PC?

Maybe I am not thinking of something, is there an easier and just as cheap solution to turn on a relay from the Windows PC program?

Any points in the right direction would be greatly appreciated.


Solution

  • The easiest way to do this is with Remote GPIO which is all documented at that link. However, the gist of it is pretty simple as follows.


    On the Raspberry Pi, run these steps:


    On the Windows PC, run these steps:


    Your script on Windows PC would then look like this:

    from gpiozero import LED
    from time import sleep
    
    red = LED(17)
    
    while True:
        red.on()
        sleep(1)
        red.off()
        sleep(1)