Bill of Materials: Raspberry PI 4B display LED light Dupont line several

1 Install Raspbian for microSD

1.1 Downloading the Startup tool ETcher and image
  • Download address
Etcher:https://www.balena.io/etcher/ raspbian:https://downloads.raspberrypi.org/raspios_full_armhf/images/raspios_full_armhf-2021-01-12/2021-01-11-raspios-bu ster-armhf-full.zipCopy the code
1.2 Use Ether to install raspbian on microSD

Select download img image select your microSD card and click Flash

2 pin test procedure

  • Python installation
sudo apt-get install python3
Copy the code
  • Install gpiozero package
pip install gpiozero
Copy the code
  • The test program
vi test.py
Copy the code
from gpiozero import LED
from time import sleep

led = LED(3)

while True:
    led.on()
    sleep(1)
    led.off()
    sleep(1)
Copy the code
  • The wiring diagram

  • Run the test program
python ./test.py
Copy the code
  • Result: The light starts flashing regularly

3 Siri controls lights

  • Install NodeJS and NPM
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
Copy the code
  • Install Homebridge, Homebridge UI, and Homebridge-GPIO-Device
sudo npm install -g --unsafe-perm homebridge homebridge-config-ui-x homebridge-gpio-device
Copy the code
  • Setting up the Startup service
sudo hb-service install --user homebridge
Copy the code
  • Login page localhost:8581, account admin Password admin
  • Set json data for the plugin Homebridge-gpio-device to
{
			"accessory": "GPIODevice"."name": "Lamp"."type": "Lightbulb"."pin": 3
}

Copy the code
  • Save the Settings and restart the HomeBridge service.

  • Open the home phone, scan the TWO-DIMENSIONAL code on the interface, and join

  • Set a scene such as “home”, “I’m gone”, Siri can control the switch

end ….