{"id":649,"date":"2025-08-26T17:32:45","date_gmt":"2025-08-26T17:32:45","guid":{"rendered":"https:\/\/t3x.co.uk\/?p=649"},"modified":"2025-08-26T18:23:16","modified_gmt":"2025-08-26T18:23:16","slug":"turn-on-pc-remotely","status":"publish","type":"post","link":"https:\/\/t3x.co.uk\/?p=649","title":{"rendered":"Turn on PC remotely"},"content":{"rendered":"\n<p>I have a Raspberry Pi that is always on for connectivity to my security equipment while I am away from home.&nbsp; Occasionally it would be useful to turn my PC on remotely and as the Pi is always on, I could use that.&nbsp; Initially I thought of using a relay switch, but I saw an article on using a Light Dependent Resistor (LDR) and a Light Emitting Diode (LED) to close a circuit.&nbsp; I thought was neat with no moving parts and compatible with low voltages found on the Pi, so I investigated.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>The first step was to connect a LED to the Pi and turn it on and off.<\/p>\n\n\n\n<div class=\"wp-block-cover alignfull is-light\" style=\"min-height:304px;aspect-ratio:unset;\"><span aria-hidden=\"true\" class=\"wp-block-cover__background has-background-dim-100 has-background-dim\" style=\"background-color:#ffffff\"><\/span><div class=\"wp-block-cover__inner-container is-layout-flow wp-block-cover-is-layout-flow\">\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile is-vertically-aligned-center is-image-fill-element\" style=\"grid-template-columns:44% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"774\" src=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/IMG_20250820_173327142_HDR-1024x774.jpg\" alt=\"\" class=\"wp-image-650 size-full\" style=\"object-position:50% 50%\" srcset=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/IMG_20250820_173327142_HDR-1024x774.jpg 1024w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/IMG_20250820_173327142_HDR-300x227.jpg 300w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/IMG_20250820_173327142_HDR-768x580.jpg 768w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/IMG_20250820_173327142_HDR-1536x1160.jpg 1536w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/IMG_20250820_173327142_HDR-2048x1547.jpg 2048w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p>The Pi has a set of pins put known as the GPIO header.&nbsp; However, the pin numbers are not the same as the GPIO numbers.<\/p>\n\n\n\n<p>More info here: <a href=\"https:\/\/pinout.xyz\/\">https:\/\/pinout.xyz\/<\/a><\/p>\n\n\n\n<p>I used pin 9 which is ground and has no GPIO number (White lead) and pin 11 aka GPIO 17 (Red lead) as shown in the picture.&nbsp; The GPIO number will be used in the program&nbsp;&nbsp; later.<\/p>\n\n\n\n<p>I connected the other end to croc clips to test.<\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-cover alignfull is-light\" style=\"min-height:304px;aspect-ratio:unset;\"><span aria-hidden=\"true\" class=\"wp-block-cover__background has-background-dim-100 has-background-dim\" style=\"background-color:#ffffff\"><\/span><div class=\"wp-block-cover__inner-container is-layout-flow wp-block-cover-is-layout-flow\">\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile is-vertically-aligned-center is-image-fill-element\" style=\"grid-template-columns:43% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"971\" src=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/clips-1024x971.jpg\" alt=\"\" class=\"wp-image-676 size-full\" style=\"object-position:50% 50%\" srcset=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/clips-1024x971.jpg 1024w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/clips-300x284.jpg 300w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/clips-768x728.jpg 768w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/clips-1536x1457.jpg 1536w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/clips-2048x1942.jpg 2048w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p>I wrote a Python program to turn the LED on, wait 4 seconds, then turn it off.<\/p>\n\n\n\n<p>You can also do this with a BASH script.<\/p>\n\n\n\n<p>The resistor is not essential for the test, but an appropriate resistor will enhance LED life.<\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"562\" height=\"302\" src=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/Picture3.jpg\" alt=\"\" class=\"wp-image-652\" style=\"width:674px;height:auto\" srcset=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/Picture3.jpg 562w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/Picture3-300x161.jpg 300w\" sizes=\"auto, (max-width: 562px) 100vw, 562px\" \/><\/figure>\n\n\n\n<p>Note: The GPIO pin mentioned earlier is specified in the pinLED variable.<\/p>\n\n\n\n<p>So that\u2019s the Pi side of the project.&nbsp; For the switch to be activate by the LED I need to wire the Light Dependant Resistor to the PC power switch.&nbsp; You could use a motherboard power pin splitter.&nbsp; Many types are available, such as the one shown here.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"486\" height=\"88\" src=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/Untitled-3.jpg\" alt=\"\" class=\"wp-image-656\" srcset=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/Untitled-3.jpg 486w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/Untitled-3-300x54.jpg 300w\" sizes=\"auto, (max-width: 486px) 100vw, 486px\" \/><\/figure>\n<\/div>\n\n\n<p>However, access to the switch on the PC, I want to use is accessible and it was easy to solder the wires directly.<\/p>\n\n\n\n<p>LDRs are used to detect light levels. Their resistance decreases as the light intensity increases.<\/p>\n\n\n\n<div class=\"wp-block-media-text is-stacked-on-mobile\" style=\"grid-template-columns:15% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"190\" height=\"172\" src=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/Picture4.jpg\" alt=\"\" class=\"wp-image-657 size-full\"\/><\/figure><div class=\"wp-block-media-text__content\">\n<p>The LDR connects to the power switch, and the LED is used to activate it by bringing down the resistance. So, we need to keep the two together and block the outside light which might inadvertently activate it.<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-media-text has-media-on-the-right is-stacked-on-mobile\" style=\"grid-template-columns:auto 25%\"><div class=\"wp-block-media-text__content\">\n<p>I first tried wrapping the two components in Blue Tack which worked ok but was easy to squash blocking or reducing the LED intensity.<\/p>\n<\/div><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"373\" height=\"259\" src=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/Picture5.jpg\" alt=\"\" class=\"wp-image-658 size-full\" srcset=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/Picture5.jpg 373w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/Picture5-300x208.jpg 300w\" sizes=\"auto, (max-width: 373px) 100vw, 373px\" \/><\/figure><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"324\" src=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/pic-1024x324.jpg\" alt=\"\" class=\"wp-image-659\" srcset=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/pic-1024x324.jpg 1024w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/pic-300x95.jpg 300w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/pic-768x243.jpg 768w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/pic.jpg 1071w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>In the end I stripped a piece of insulation off a suitable cable and poked them in together as shown.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"534\" height=\"213\" src=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/diagram-1.jpg\" alt=\"\" class=\"wp-image-670\" style=\"width:600px;height:auto\" srcset=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/diagram-1.jpg 534w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/diagram-1-300x120.jpg 300w\" sizes=\"auto, (max-width: 534px) 100vw, 534px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"has-text-align-center\"><strong>Basic Diagram<\/strong><\/p>\n\n\n\n<p><strong>Components<\/strong><\/p>\n\n\n\n<p>LDR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5539 Light Dependent Resistor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Amazon<\/p>\n\n\n\n<p>LED&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; My Junk Box<\/p>\n\n\n\n<p>LED Polarity shown below:<\/p>\n\n\n\n<div class=\"wp-block-media-text is-stacked-on-mobile\" style=\"grid-template-columns:23% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"250\" height=\"269\" src=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/led-polarity.png\" alt=\"\" class=\"wp-image-661 size-full\"\/><\/figure><div class=\"wp-block-media-text__content\">\n<p>A white LED is best<br>82R resistor or appx (100R would be OK)<br>Cables with suitable connector can be found online if needed<br>Search for Front Panel Connectors<\/p>\n<\/div><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"427\" height=\"179\" src=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/pic2.jpg\" alt=\"\" class=\"wp-image-662\" style=\"width:553px;height:auto\" srcset=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/pic2.jpg 427w, https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/pic2-300x126.jpg 300w\" sizes=\"auto, (max-width: 427px) 100vw, 427px\" \/><\/figure>\n<\/div>\n\n\n<p>I have used Wake On LAN software previously but I found it a bit hit and miss.<\/p>\n\n\n\n<p>Most of these components come in packs of 10 or more so I have spares, just need another project or two.<\/p>\n\n\n\n<p>To access the Pi from outside your own network is another story.&nbsp; Look up PiVPN.<\/p>\n\n\n\n<p><strong>Downloads<\/strong> <\/p>\n\n\n\n<p><strong>Python Code<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/python\n\nimport RPi.GPIO as GPIO         # Import Raspberry Pi GPIO library\nfrom time import sleep          # Import the sleep function\n\npinLED = 17                     # LED GPIO Pin LED\n\nGPIO.setmode(GPIO.BCM)          # Use GPIO pin number\nGPIO.setwarnings(False)         # Ignore warnings in our case\nGPIO.setup(pinLED, GPIO.OUT)    # GPIO pin as output\n\n# Turn on LED for 4 Seconds\nGPIO.output(pinLED, GPIO.HIGH)\nprint (\"ON\")\nsleep(4)                         # Pause 4 seconds\n# Turn off LED\nGPIO.output(pinLED, GPIO.LOW)    # Turn off\nprint(\"OFF\")\nsleep(2)<\/code><\/pre>\n\n\n\n<p><strong>This article as PDF<\/strong><\/p>\n\n\n\n<div data-wp-interactive=\"core\/file\" class=\"wp-block-file\"><object data-wp-bind--hidden=\"!state.hasPdfPreview\" hidden class=\"wp-block-file__embed\" data=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/Remote-Switch-1.pdf\" type=\"application\/pdf\" style=\"width:100%;height:280px\" aria-label=\"Embed of Remote Switch.\"><\/object><a id=\"wp-block-file--media-9bad73c3-e2b1-4d22-a486-c60fd475513c\" href=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/Remote-Switch-1.pdf\">Remote Switch<\/a><a href=\"https:\/\/t3x.co.uk\/wp-content\/uploads\/2025\/08\/Remote-Switch-1.pdf\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-9bad73c3-e2b1-4d22-a486-c60fd475513c\">Download<\/a><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a Raspberry Pi that is always on for connectivity to my security equipment while I am away from home.&nbsp; Occasionally it would be useful to turn my PC on remotely and as the Pi is always on, I could use that.&nbsp; Initially I thought of using a relay switch, but I saw an &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/t3x.co.uk\/?p=649\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Turn on PC remotely&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[67,66],"tags":[68,69],"class_list":["post-649","post","type-post","status-publish","format-standard","hentry","category-electronics","category-raspberry-pi","tag-pi","tag-project"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3XT9c-at","_links":{"self":[{"href":"https:\/\/t3x.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/t3x.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/t3x.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/t3x.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/t3x.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=649"}],"version-history":[{"count":10,"href":"https:\/\/t3x.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/649\/revisions"}],"predecessor-version":[{"id":677,"href":"https:\/\/t3x.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/649\/revisions\/677"}],"wp:attachment":[{"href":"https:\/\/t3x.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/t3x.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/t3x.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}