Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Waveshare

Waveshare Relay HAT: Control AC Loads from Raspberry Pi

Waveshare Relay HAT: Control AC Loads from Raspberry Pi

April 1, 2026 /Posted by / 0

The Waveshare Relay HAT adds high-voltage switching to Raspberry Pi. With optically isolated relays rated for 250V AC at 5A, you can control lights, fans, and appliances from Python code.

Table of Contents

  • Features
  • Safe Wiring
  • Python Control
  • Projects
  • Safety
  • MQTT Integration
  • FAQ

Features

  • 2-8 relay channels (most common: 3-channel board)
  • 250V AC / 5A or 30V DC / 5A per relay
  • Optocoupler isolation
  • SPDT contacts (NO, NC, COM)
  • Direct GPIO control or I2C
Recommended: Waveshare DIN Rail ABS Case for Raspberry Pi 5

Safe Wiring Guide

Warning: Mains voltage (230V AC in India) is dangerous. Hire a licensed electrician for AC wiring if unsure.

  1. Disconnect mains power before wiring.
  2. Connect live wire to COM terminal.
  3. Connect NO terminal to load’s live input.
  4. Neutral goes direct to appliance.
  5. Use 1.5 mm2 minimum wire for 5A loads.
  6. Insulate all connections with heat shrink.

Python Control

import RPi.GPIO as GPIO
RELAYS = [26, 20, 21]
GPIO.setmode(GPIO.BCM)
for p in RELAYS:
    GPIO.setup(p, GPIO.OUT); GPIO.output(p, GPIO.HIGH)
def on(ch): GPIO.output(RELAYS[ch], GPIO.LOW)
def off(ch): GPIO.output(RELAYS[ch], GPIO.HIGH)
on(0)  # Light on
import time; time.sleep(10)
off(0)  # Light off

Automation Projects

  • Scheduled lights: On at sunset, off at bedtime.
  • Temperature fan: DHT22 reading triggers fan relay above 30C.
  • Water pump timer: 15 minutes every 6 hours.
  • Security siren: PIR motion triggers relay + Telegram notification.
Recommended: Waveshare Industrial Metal Case (D) for Pi 5

Electrical Safety

  • Never exceed relay rated current.
  • Use MCB for overcurrent protection.
  • Enclose high-voltage wiring in IP-rated junction box.
  • Use DIN rail case for professional installations.
  • Maintain earth/ground connections.

MQTT Integration

import paho.mqtt.client as mqtt
def on_message(client, userdata, msg):
    ch = int(msg.topic.split('/')[-1])
    GPIO.output(RELAYS[ch], GPIO.LOW if msg.payload==b"ON" else GPIO.HIGH)
client = mqtt.Client()
client.on_message = on_message
client.connect("localhost", 1883)
client.subscribe("home/relay/#")
client.loop_forever()

Frequently Asked Questions

Can I switch 230V AC?

Yes, rated for 250V AC at 5A. Follow all safety guidelines.

NO vs NC?

NO = off by default (recommended for home automation). NC = on by default.

Interference issues?

Optocoupler prevents it. Add flyback diode for inductive loads.

Works with Pi 5?

Yes. Use gpiozero or lgpio library instead of RPi.GPIO.

Conclusion

The Waveshare Relay HAT bridges low-voltage Pi intelligence with the high-voltage real world. With MQTT and Home Assistant, it becomes a powerful home automation building block.

Browse the full Waveshare collection at Zbotic.in with fast shipping across India.

Tags: home automation, Raspberry Pi, relay, waveshare
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Waveshare Motor Driver HAT: Ra...
blog waveshare motor driver hat raspberry pi robot control 614032
blog sma antenna connector rf cable assembly guide 614036
SMA Antenna Connector: RF Cabl...

Related posts

Svg%3E
Read more

Waveshare Firmware Update: Flash Latest Software Guide

April 1, 2026 0
Many Waveshare products contain updatable firmware. Keeping firmware current fixes bugs and adds features. Table of Contents Which Products Need... Continue reading
Svg%3E
Read more

Waveshare Troubleshooting: Common Issues and Fixes

April 1, 2026 0
Even reliable hardware encounters issues. This guide addresses the most common Waveshare problems and their solutions. Table of Contents Display... Continue reading
Svg%3E
Read more

Waveshare Education Kit: Classroom Raspberry Pi Pack

April 1, 2026 0
The Waveshare education kit is designed for STEM classrooms, with structured lessons from basic to advanced. Table of Contents Kit... Continue reading
Svg%3E
Read more

Waveshare Industrial Kit: RS485, CAN, and 4G Bundle

April 1, 2026 0
The Waveshare industrial kit combines RS485, CAN bus, and 4G for connecting legacy factory equipment to modern cloud platforms. Table... Continue reading
Svg%3E
Read more

Waveshare Weather Kit: Environmental Monitoring Bundle

April 1, 2026 0
The Waveshare weather kit bundles environmental sensors for building a complete weather monitoring station. Table of Contents Sensors Included Setup... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now