مشاركات عشوائية

How to Make a DIY Motion Sensor for Apple HomeKit

By adding your own motion sensor to your Apple HomeKit network, you can detect intruders or activate lights when motion is detected.


Smart home devices compatible with Apple HomeKit are often expensive. However, you can build your own unofficial smart home sensors, such as those for detecting motion, using an inexpensive ESP8266 board like a D1 Mini with a PIR or microwave radar-based motion sensor for less than $5 – no soldering required.


You can then add the smart motion sensor in the Apple Home app or the Eve app for HomeKit and set up the automation to trigger a smart light switch or receive notifications on Apple devices, such as an iPhone.


Things you will need

We will build a DIY motion sensor for this Apple HomeKit which is recognized as an Elgato Eve motion sensor. To build a smart motion sensor for HomeKit, you will need the following components:

  • D1 Mini or NodeMCU board
  • HC-SR501 or SR602 infrared PIR, or RCWL-0516 microwave radar motion sensor
  • A few connecting wires
  • PC or laptop
  • Micro USB cable
  • 5V micro USB power supply

A PIR motion detector has a limited detection area that requires a clear line of sight: it cannot detect motion behind objects. A microwave radar motion sensor can detect motion through objects or a solid wall and provides greater coverage. Additionally, a microwave radar sensor is more sensitive than a PIR-based passive motion sensor.

Flash firmware

For the D1 Mini card, we will use the firmware in HomeChild. Additionally, you will need a Windows or macOS system and a micro USB cable.

Connect the D1 Mini board to the system using the micro USB cable, then follow these instructions to flash the firmware.

On Windows:

  1. Download and extract the Espressif Flash download tools.
  2. Open the extracted folder and run it flash_download_tool_xx.exe program.
  3. In chip typeChoose ESP8266 and click OKAY.
  4. Check the first three boxes as shown in the image below, then,
    1. Type 0x0000 and click three dots to choose the rboot.bin case.
    2. Type 0x1000 and choose the blank_config.bin case.
    3. Type 0x2000 and choose the main tray case.
  5. Choose the following options in the ESP8266 Flash Download Tools window.
    1. Baud rate: 115200.
    2. Flash size: 4MB.
    3. Flash mode: DIO or QIO.
    4. SPI speed: 40MHz.
  6. Select the COM port to which the D1 Mini is connected and click To start up. This may take up to two minutes.
    flash firmware on d1 mini

On macOS:

  1. Download and launch it NodeMCU-PyFlasher.dmg on your macOS system.
  2. Connect the D1 Mini to your Mac system, then choose the serial port.
  3. Click on Browse and select the main tray case.
  4. In Baud rate, choose 115200.
  5. Choose Quad I/O (QIO).
  6. To select clear flash and yes, it erases all data.
  7. Click on Flash Node MCU.
  8. After the NodeMCU is flashed, reconnect it to reboot, then follow the next instructions.

After the firmware is successfully flashed, you need to connect the device to your Wi-Fi network.

Connect to Wi-Fi network

Close the Espressif Flash Download Tools Windows and reconnect the D1 Mini to your system.

  • Take out your iPhone or other iOS device and open Wi-Fi settings.
  • Login to Homekid-XXXX Wi-Fi hotspot using password 12345678.
  • A login window will appear on your device. Tap on your Wi-Fi network and enter the password.

  • Faucet Rejoin. The device will disconnect from your smartphone and connect to the Wi-Fi network using the provided password.

If the entered password is wrong, the device will start the AP after a while. You can then reconnect to the hotspot and enter the correct password.

Connect the components

Refer to the wiring diagram below to connect the HC-SR501 PIR motion sensor to the D1 Mini or NodeMCU board.

connect the pir motion sensor to the d1 mini

If you plan to use an SR602 PIR or RCWL-0516 microwave radar motion sensor, connect the Out pin to the D6 pin, Vin to the 5V pin, and the Ground pin to the G pin on the D1 Mini or NodeMCU .

Add an accessory to the Home app

On your iOS device or a macOS device like MacBook, open the Home app, then follow these steps to add the motion sensor we created as an accessory. The device will be added as an unofficial accessory, but will function the same as an official Elgato Eve motion sensor for Apple HomeKit.

  1. In the Home app, tap the + icon and choose Add an accessory.
  2. Faucet More actions… then press the Movement-XXXX accessory.
  3. Faucet Add anyway then enter the code 1180-3193. Faucet To continue.
  4. Choose the location where you will install the motion detector and press To continue.
  5. Edit or change the name of the motion detector. This is important for keeping track of multiple motion sensors. Faucet To continue > Do.
  6. You can now see the motion sensor as an accessory under the room name. If you tap on the accessory, it opens a control panel where you can change the properties of the sensor.

You can also install the Eve for HomeKit app for more options and control the DIY motion sensor. This app provides a more intuitive user interface, making it easier for you to manage your official and unofficial HomeKit DIY accessories, such as a DIY HomeKit WS2812B NeoPixel RGB Strip.

Repair

You will need to re-flash the firmware in the event of the following issues:

  1. If the wireless access point is not visible in your smartphone’s Wi-Fi settings.
  2. If the device is not visible in the Apple HomeKit app.

Before re-flashing the microcontroller board, be sure to clear the memory using the Wipe off button then click To start up to flash the microcontroller board with firmware.

Automate lights and switches

You can use this inexpensive DIY HomeKit-enabled motion sensor for security or to automate lights, switches, or any other smart device in your home. For example, you can configure automation in the homepage app to trigger a smart switch or smart light when motion is detected in a particular area, such as a staircase or hallway.

You can also set up an automation to receive notifications on your iPhone whenever motion is detected. However, you will need an Apple HomePod or Apple TV (4th generation or later) installed on your network or premises to create the automation. Otherwise, you can only use the sensor for motion detection.

Post a Comment

0 Comments