Using VNC on a PC to remotely control things with a Raspberry Pi including switching relays
Virtual Network Computing (VNC) enables a computer to remotely view another computer’s desktop and transmit keyboard input and mouse movements and clicks etc. I have come rather late to this particular party but it seems a very good way to easily set up a remote control system.
Simply put, A Raspberry Pi running a Python program can control stuff using its GPIO pins via the usual transistors, relays etc. If the Python program runs a graphical interface such as Tkinter, then remote control can be easily achieved through VNC.
VNC window showing desktop of Raspberry Pi running Tkinter which controls the boiler.
VNC window which allows various remote desktops to be opened with a double click.
In a new project, I want to control the heating in our guest bedroom. Specifically I want to be able to control the (hot water) radiator, the hot towel rail, the local hot water supply and supplementary electric heating which may be necessary when the weather is particularly cold. A Raspberry Pi with three or four relays and an I2C temperature sensor should, I hope, do the trick.
The picture below show a bread board arrangement with a Python program running on an old(Ish) Pi. The Pi’s GPIO 4 (Broadcom numbering scheme) is driving a relay via one element of a ULN2003 Darlington transistor array.
The Pi is running “headless” (with no monitor -
The Python program to control this system is next…
When running headless, the desktop defaults to a small size (800 by 600 as I remember). If you are running a program that needs more space, you need to edit config.txt on the Pi. (See RPI documentation for details.)
Open a terminal window then:
sudo nano /boot/config.txt
That will bring up the config.txt file in nano for editing.
Set the following:
The hit F3 to save and F2 to quit nano.
Finally sudo reboot to reboot and make the changes effective.