- A Mind for Numbers
- Accelerate
- Agile Project Management for Dummies
- Algorithms to Live By
- Atomic Habits
- AWS Certified Cloud Practitioner Study Guide
- Banking on It
- Brexitland
- Build Your Dream Network
- Bulletproof SSL and TLS
- Business Analysis
- Collapse
- CompTIA Security+ Practice Tests
- CompTIA Security+ Study Guide
- Corporate Rebels
- Countdown to Zero Day
- Creative Acts for Curious People
- Creative DIY Microcontroller Projects with TinyGo...
- Cryptanalysis
- Crypto Trader
- Cryptography
- Culture Code
- Daniel Goleman Omnibus
- Deep and deliberate delegation
- Dhl
- Drive
- Effective Python
- Every Tool's a Hammer
- Exam Ref AZ-900 Microsoft Azure Fundamentals
- Expert Scripting and Automation for SQL Server...
- Fifty Quick Ideas to Improve Your User Stories
- Fixing Your Scrum
- Fundamentals of ServiceNow Administration and...
- Future Leader
- Future of Violence - Robots and Germs, Hackers and...
- GCHQ Puzzle Book
- Getting Things Done
- Harvard Business Review manager's handbook
- Hooked
- How Google Works
- How to Take Smart Notes
- How to Win Friends and Influence People
- HTML and CSS
- I Think, Therefore I Am
- Itsm Value Streams : Transform Opportun
- JavaScript and jQuery
- Kill It with Fire
- Leaders Eat Last
- Leading change
- Leading Without Authority
- Lean Thinking
- LONDON'S UNDERGROUND.
- Managing Successful Projects Prince2
- Managing Successful Projects with PRINCE2
- Measure What Matters : OKRs
- Meteorology today
- Mindf*ck
- Modern Cryptanalysis
- Modernist cuisine at home
- Money Revolution
- Never Split the Difference
- New One Minute Manager
- Open Circuits
- Oversubscribed
- Permanent Record
- PHP 5 advanced
- Practical Docker with Python: Build, Release and...
- Practical electronics for inventors
- PRINCE2 for dummies
- Pro Python 3: Features and Tools for Professional...
- Pro SQL Server Always On Availability Groups
- Pro SQL Server on Linux: Including Container-Based...
- Professional Scrum Master Guide
- Project to Product
- Radical Simplicity
- Rules of People
- SAFe 5.0 Distilled
- Sapiens
- SEARCH INSIDE YOURSELF- TPB
- Secret Barrister
- Securing SQL Server: DBAs Defending the Database
- Site Reliability Engineering
- SQL Server 2017 Administration Inside Out
- Start with Why
- System Center Configuration Manager Current Branch...
- T-SQL Fundamentals
- Teach Yourself Electricity and Electronics,...
- Teach Yourself Setting Up a Small Business (Teach...
- Team Topologies
- The Art of Deception
- The art of invisibility
- The Chimp Paradox How Our Impulses And Emotions...
- The coaching habit
- The code book
- The Courage To Be Disliked
- The DevOps handbook
- The Epic Guide to Agile
- The Five Dysfunctions of a Team: A Leadership...
- The Go Programming Language
- The Golden Ratio
- The Introvert's Guide to the Workplace
- The Manager's Path
- The New Silk Roads: The Present and Future of the...
- The outward mindset
- The Phoenix Project
- The Professional Product Owner
- The Unicorn Project
- Turn The Ship Around!
- Visual Thinking
- Weapons of Math Destruction
- Who Moved My Cheese?
- Work Rules!
- Working Out Loud
- Writing An Interpreter In Go
- Wrong Fit, Right Fit
Raspberry Pi Controlled Lights Using Relays
We’ve had USB powered lights in our lounge for several years and every year I seem to slightly improve the wiring and relay boards. The Raspberry Pi below controls the lights behind our TV and are switched on using a Google AIY Voice Kit on another Pi mounted under our coffee table. (Voice Kit available here)
It’s this Raspberry Pi that I am adding two more lights to. These new lights were purchased in the Souks in Marrakech and look great when lit up inside.
The lights that I use were from Amazon and came in a plastic light bulb shaped case. The relay board is also sold by many sellers and has proved to be reliable over the years.
The AdaFruit Micro-B Breakout Board is a simple way to add a professional 5 volt power connector to your project.
Using an inline USB power meter, we can see these lights draw just over 1 amp at 5 volt. The lights get rather warm so I’ll be running them for a while whilst monitoring their temperature. I use a good quality power supply, usually a 6 port 60 watt Anker USB power supply.
Controlling the lights is relatively simple in Python. After installing the rpi.GPIO Python module using…
apt-get update; apt-get install python-dev python-rpi.gpio
…the lights can be switched on and off using the following code. This assumes that the relay board input pins are connected to pins 19 and 26.
Switch Lights On
#!/usr/bin/python
import RPi.GPIO as RPIO
RPIO.setmode(RPIO.BCM)
RPIO.setwarnings(False)
RPIO.setup(19, RPIO.OUT)
RPIO.setup(26, RPIO.OUT)
RPIO.output(19, False)
RPIO.output(26, False)
Switch Lights Off
#!/usr/bin/python
import RPi.GPIO as RPIO
RPIO.setmode(RPIO.BCM)
RPIO.setwarnings(False)
RPIO.setup(19, RPIO.OUT)
RPIO.setup(26, RPIO.OUT)
RPIO.output(19, True)
RPIO.output(26, True)
Interestingly, the relay board switches on when the pin is set to low. This took me a while to work out as I assumed they switched at high so thought they didn’t work. I believe this is because some boards will default to high when they power on, which would trigger the relay. On boot, the pins are floating so it doesn’t trigger the relay but may dimly illuminate the LEDs on the board.