Article Preview
Buy Now
FEATURE
A Household Light Controller
Raspberry Pi Part 8
Issue: 22.4 (July/August 2024)
Author: Eugene Dakin
Author Bio: Eugene works as a Senior Oilfield Technical Specialist. He holds university degrees in the disciplines of Engineering, Chemistry, Biology, Business, and a Ph.D. in Chemical Engineering. He is the author of dozens of books on Xojo available on the xdevlibrary.com website.
Article Description: No description available.
Article Length (in bytes): 11,150
Starting Page Number: 20
Article Number: 22403
Resource File(s):
project22403.zip Updated: 2024-07-01 10:15:25
Related Web Link(s):
http://abyz.me.uk/lg/lg.zip
Excerpt of article text...
This article demonstrates how to control a 120-volt light by switching a relay with the Raspberry Pi 5 or Raspberry Pi 4. A word of caution: Since this project can work with household voltage of 120 or 240 volts, please be careful, as household electricity can be dangerous. Please ensure that you know what you are doing.
Warning: I would suggest that the person constructing this project should use an ohm-meter instead of house current to prove that the circuits work fully before using large wattage appliances. It is exhilarating to be able to program a Raspberry Pi that takes the programming code and can control the real world, such as light bulbs, garage door openers, and other items around the house. This project includes parts that protect the Raspberry Pi GPIO pins while allowing control of a large power source from your house to power a light bulb.
This example works with a Raspberry Pi 4 or the newest Raspberry Pi 5. To make the example work on the Raspberry Pi 5, change the opening line of code from
lgGpiochipOpen(0)
tolgGpiochipOpen(4)
, where4
is the latest chipset. A strong suggestion is to not use the 120-volt power supply. An Ohm-Meter can be used instead of the alternating current power supply to ensure that the relay is switching properly. This example uses the Raspberry Pi OS in 64-bit mode.
...End of Excerpt. Please purchase the magazine to read the full article.