Skip to content
This repository was archived by the owner on Jul 22, 2026. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kitchen HomeKit Devices

IMG_3577 IMG_3576

Two ESP8266 firmwares for an Apple-HomeKit kitchen setup:

  • radar_kitchen/ — a LD2410B mmWave presence radar on a D1 Mini that exposes a HomeKit OccupancySensor, and acts as the ESP-NOW hub for a separate CO2 desk-lamp monitor (relaying its temp/humidity/CO2 into HomeKit and forwarding HomeKit light on/off commands back to it).
  • light_relay/ — an ESP-01S relay that exposes a HomeKit Switch to drive a light. One codebase, two build variants: kitchen and workdesk.

Both are working. Presence-driven lighting is done with HomeKit automations (Apple Home), not direct device-to-device control: the radar publishes occupancy, the relay exposes a switch, and Home ties them together.

System picture

          ┌──────────────────────────┐         ESP-NOW (ch 6)
          │  radar_kitchen (D1 Mini) │◄───────────────────────────┐
          │  LD2410B mmWave radar    │                            │
          │  HomeKit OccupancySensor │      ┌─────────────────────┴─────────┐
          │  + ESP-NOW hub           │      │  CO2 desk lamp (ESP32)         │
          │   • relays CO2 sensors   │      │  SCD41 + BME280 + NeoPixel     │
          │   • forwards light cmds  │─────►│  (separate repo: CO2)          │
          └────────────┬─────────────┘      └────────────────────────────────┘
                       │ HomeKit (Wi-Fi / mDNS)
                       ▼
                 Apple Home  ──automation──►  light_relay (ESP-01S) → relay → light

The CO2 desk-lamp monitor that pairs with radar_kitchen over ESP-NOW lives in its own repository (it's an ESP32 project). radar_kitchen is the HomeKit bridge for it: the lamp has no Wi-Fi/HomeKit of its own.

Note: light_relay is independent — it has no ESP-NOW or MQTT link to the radar. It's a plain HomeKit switch; the radar→light behaviour is an Apple Home automation.


radar_kitchen — presence radar + ESP-NOW hub

Board: D1 Mini (ESP8266) · Lib: Arduino-HomeKit-ESP8266

Hardware / pins

Signal GPIO D-pin
LD2410B RX (SoftwareSerial) 4 D2
LD2410B TX (SoftwareSerial) 5 D1

LD2410B runs at 115200 baud (firmware force-switches it on boot via the radar's config command, sent at 256000 then 115200).

HomeKit accessory (sensor category)

Service Source
OccupancySensor "Kitchen Presence" local LD2410B radar
TemperatureSensor / HumiditySensor CO2 lamp, via ESP-NOW
AirQualitySensor + CO2 level CO2 lamp, via ESP-NOW
Switch "CO2 Light" forwards on/off to the CO2 lamp

Setup code: 382-95-164 (change in src/my_accessory.c).

ESP-NOW link (channel 6)

  • Receives CO2Packet { int16 co2, float temp, float hum, uint8 lightOn } from the lamp; peer MAC is learned at runtime.
  • Sends TimePacket (Unix time for the lamp's clock, throttled ≤ once/60 s) and LightCommand (on/off) when HomeKit toggles the switch.

Notable logic

  • 700 ms presence debounce on the radar signal.
  • HomeKit pushes throttled: occupancy every 3 s / on change; sensor data ≤ every 30 s (4 notifies every 3 s was overloading the HomeKit TLS sessions).
  • ESP-NOW receive callback only memcpy's + sets flags; all WiFi/ESP-NOW/HomeKit calls are deferred to loop() (calling them in the ISR context crashes ESP8266).
  • On WiFi reconnect the device reboots — calling arduino_homekit_setup() twice leaks heap and crashes.
  • NTP timezone hardcoded to CET-1CEST (the clock is sent on to the CO2 lamp).

Build

cd radar_kitchen
pio run -e d1_mini -t upload          # USB
pio run -e d1_mini_ota -t upload      # OTA → upload_port in platformio.ini

light_relay — HomeKit relay switch

Board: ESP-01S (ESP8266, 1 MB) · Lib: Arduino-HomeKit-ESP8266

A minimal HomeKit Switch: the ON characteristic drives a relay on GPIO0 (D3). Includes a 5 s WiFi watchdog that reconnects and re-advertises HomeKit after a dropout.

Two build variants

Env Device name HomeKit setup code setupId
kitchen Kitchen Light 681-18-397 KL01
workdesk Workdesk Light 527-31-846 WD01

Selected at compile time via -DDEVICE_KITCHEN / -DDEVICE_WORKDESK.

cd light_relay
pio run -e kitchen  -t upload
pio run -e workdesk -t upload

Relay polarity: both variants are currently defined active-HIGH in main.cpp (RELAY_ON = HIGH). The platformio.ini comment calling workdesk "active-LOW" is stale — flip RELAY_ON/RELAY_OFF for that variant if your relay module is active-LOW.


Credentials

WiFi credentials are kept out of git. Each firmware reads src/secrets.h (gitignored). Before building, copy the template in each subfolder:

cp radar_kitchen/src/secrets.example.h radar_kitchen/src/secrets.h
cp light_relay/src/secrets.example.h  light_relay/src/secrets.h

HomeKit setup codes are left in my_accessory.c (they require local-network access and an unpaired device to be useful) — change them for your own units.

License

No license specified — personal/reference projects.

About

Two ESP8266 HomeKit firmwares for a kitchen: an LD2410B mmWave presence radar (+ ESP-NOW hub for a CO2 lamp) and an ESP-01S relay light switch.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages