Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to connect the raspberry pie to the relay

Shulou Source: shulou.com Published: 2022-06-01 22:43:24 10月02日 Update

This article mainly introduces the raspberry pie how to connect the relay, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to know it.

Prepare materials

Zero wh for raspberry pie.

One relay (model JQC-3FF-S-Z)

Disassembled USB cabl

LED lamp

The relay is connected to the raspberry pie line

Relay VCC connects to raspberry pie 5v5

Relay GND connects to raspberry pie GND

Relay IN connects to raspberry pie GPIO18

Pay attention to distinguish between VCC and GND, do not connect backwards!

Relay, LED lamp and power line connection

Relay NO connected to LED positive electrode

Relay COM connected to positive pole of power supply

LED negative electrode connected to power supply negative electrode

As shown in the following figure

Physical connection diagram

The code runs vim jdq.py

Write the following

#-*-coding: utf-8-*-import RPi.GPIO as GPIOimport time # BCM numbering mode GPIO.setmode (GPIO.BCM) # set [GPIO port with BCM number 18] as output mode GPIO.setup (18, GPIO.OUT) # enable GPIO.output (18, GPIO.HIGH) time.sleep (5) # close GPIO.output (18, GPIO.LOW) GPIO.cleanup ()

Execute jdq.py code

Python3 jdq.py

When you hear a click, the LED light will be on, and when you hear the click, the LED light will go out.

Knowledge expansion

Relay schematic diagram

Thank you for reading this article carefully. I hope the article "how to connect relays with raspberry pie" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Relay relay raspberry article power code positive knowledge circuit negative sound value interest content principle at the same time model physical object data data line Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi NVidia MySQL Xiaomi Linux