A relay module is an electronic switch that allows a low-power signal (like from a Raspberry Pi) to control a high-power device (like a lamp or fan) safely.
Click to reveal answer
beginner
Why do we use a relay module instead of connecting devices directly to the Raspberry Pi?
Because the Raspberry Pi's pins provide low voltage and current, which can't power high-voltage devices directly. The relay safely switches the high voltage on and off without damaging the Pi.
Click to reveal answer
beginner
Which Python library is commonly used to control GPIO pins on a Raspberry Pi?
The RPi.GPIO library is commonly used to control the Raspberry Pi's GPIO pins for tasks like switching relays.
Click to reveal answer
beginner
What is the purpose of setting a GPIO pin as output when controlling a relay?
Setting a GPIO pin as output allows the Raspberry Pi to send signals (HIGH or LOW) to the relay to turn connected devices on or off.
Click to reveal answer
beginner
How do you ensure safety when working with relay modules and high voltage devices?
Always disconnect power before wiring, use insulated wires, avoid touching live circuits, and double-check connections to prevent electric shock or damage.
Click to reveal answer
What does a relay module do in a Raspberry Pi home automation setup?
ASwitches high voltage devices on/off using low voltage signals
BIncreases the Raspberry Pi's processing speed
CStores data from sensors
DConnects the Raspberry Pi to the internet
✗ Incorrect
A relay module acts as a switch controlled by the Raspberry Pi to safely turn high voltage devices on or off.
Which GPIO pin mode should you use to control a relay?
AOutput
BAnalog
CPWM
DInput
✗ Incorrect
GPIO pins must be set as output to send signals that control the relay.
Why should you never connect a high voltage device directly to a Raspberry Pi GPIO pin?
AIt will make the device run faster
BIt will improve Wi-Fi signal
CIt can damage the Raspberry Pi and cause safety hazards
DIt will increase battery life
✗ Incorrect
High voltage can damage the Raspberry Pi and cause electric shock or fire hazards.
Which Python library is commonly used to control Raspberry Pi GPIO pins?
ANumPy
BRPi.GPIO
CPandas
DMatplotlib
✗ Incorrect
RPi.GPIO is the standard library for controlling GPIO pins on Raspberry Pi.
What is a safe practice when wiring a relay module?
ATouch live wires to check connections
BUse bare wires without insulation
CWork with power connected
DDisconnect power before wiring
✗ Incorrect
Always disconnect power before wiring to avoid electric shock or damage.
Explain how a Raspberry Pi controls a home appliance using a relay module.
Think about how a small signal can control a big device safely.
You got /4 concepts.
List safety precautions to follow when working with relay modules and high voltage devices.
Safety first! What keeps you safe from electric shock?
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of using a relay module with a Raspberry Pi in home automation?
easy
A. To increase the Raspberry Pi's processing speed
B. To safely control high-power devices using low-power GPIO signals
C. To store data from sensors
D. To provide internet connectivity
Solution
Step 1: Understand relay module function
A relay module acts as a switch controlled by the Raspberry Pi's GPIO pins to turn devices ON or OFF safely.
Step 2: Identify the purpose in home automation
It allows the Pi to control high-power devices without directly handling high voltage or current.
Final Answer:
To safely control high-power devices using low-power GPIO signals -> Option B
Quick Check:
Relay modules = safe device control [OK]
Hint: Relays switch big power with small signals [OK]
Common Mistakes:
Thinking relay speeds up the Pi
Confusing relay with data storage
Assuming relay provides network access
2. Which of the following Python code snippets correctly sets GPIO pin 17 as output and turns the relay ON (assuming active LOW)?
easy
A. GPIO.setup(17, GPIO.OUT)
GPIO.output(17, GPIO.LOW)
B. GPIO.setup(17, GPIO.OUT)
GPIO.output(17, GPIO.HIGH)
C. GPIO.setup(17, GPIO.IN)
GPIO.output(17, GPIO.LOW)
D. GPIO.setup(17, GPIO.IN)
GPIO.output(17, GPIO.HIGH)
Solution
Step 1: Set GPIO pin mode
Pin 17 must be set as output to control the relay, so GPIO.setup(17, GPIO.OUT) is correct.
Step 2: Turn relay ON with active LOW
For active LOW relay, sending GPIO.LOW activates the relay, so GPIO.output(17, GPIO.LOW) is correct.
Final Answer:
GPIO.setup(17, GPIO.OUT) followed by GPIO.output(17, GPIO.LOW) -> Option A
Quick Check:
Active LOW means LOW signal turns relay ON [OK]
Hint: Active LOW relay ON means output LOW [OK]
Common Mistakes:
Setting pin as input instead of output
Using HIGH to turn ON active LOW relay
Confusing pin numbers
3. What will be the output of this Python code controlling a relay on GPIO pin 22?
A. Calling GPIO.output after GPIO.cleanup causes an error
B. GPIO.setup should be called after GPIO.cleanup
C. GPIO.setmode must be called twice
D. GPIO.output cannot use GPIO.HIGH
Solution
Step 1: Understand GPIO.cleanup() effect
GPIO.cleanup() resets all GPIO pins, releasing resources and resetting pin states.
Step 2: Check GPIO.output after cleanup
Calling GPIO.output after cleanup without re-setup causes a runtime error because pin 18 is no longer configured.
Final Answer:
Calling GPIO.output after GPIO.cleanup causes an error -> Option A
Quick Check:
Use GPIO.setup after cleanup before output [OK]
Hint: Don't use GPIO.output after cleanup without setup [OK]
Common Mistakes:
Thinking cleanup only clears pin states but allows output
Believing setup order is flexible
Assuming GPIO.HIGH is invalid
5. You want to control two relays connected to GPIO pins 5 and 6 to turn ON a fan and a light respectively. The relays are active LOW. Which Python code correctly turns ON the fan and turns OFF the light?
hard
A. GPIO.setup(5, GPIO.OUT)
GPIO.setup(6, GPIO.OUT)
GPIO.output(5, GPIO.HIGH)
GPIO.output(6, GPIO.HIGH)
B. GPIO.setup(5, GPIO.OUT)
GPIO.setup(6, GPIO.OUT)
GPIO.output(5, GPIO.HIGH)
GPIO.output(6, GPIO.LOW)
C. GPIO.setup(5, GPIO.IN)
GPIO.setup(6, GPIO.IN)
GPIO.output(5, GPIO.LOW)
GPIO.output(6, GPIO.HIGH)
D. GPIO.setup(5, GPIO.OUT)
GPIO.setup(6, GPIO.OUT)
GPIO.output(5, GPIO.LOW)
GPIO.output(6, GPIO.HIGH)
Solution
Step 1: Setup pins 5 and 6 as outputs
Both pins must be outputs to control relays: GPIO.setup(5, GPIO.OUT) and GPIO.setup(6, GPIO.OUT).
Step 2: Apply active LOW logic for relays
To turn ON the fan (pin 5), output LOW; to turn OFF the light (pin 6), output HIGH.
Final Answer:
Setup pins as output, output LOW on 5, HIGH on 6 -> Option D
Quick Check:
Active LOW ON = LOW, OFF = HIGH [OK]
Hint: Active LOW ON means output LOW, OFF means HIGH [OK]
Common Mistakes:
Setting pins as input instead of output
Reversing HIGH and LOW for active LOW relay
Turning both devices ON or OFF incorrectly
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.