Some HomeKit-based IoT experiments. An ESP32 board is required to run the code.
All projects have the following common requirements:
- Arduino IDE
- An ESP32 board (mine is:
ESP32-WROOM-32
)
As well, all projects are built on the top of the HomeSpan library. Therefore, once flashed on a board, they should be connected to WiFi and paired following HomeSpan Getting Started and Command-Line Interface docs.
Before any project can be compiled and flashed to an ESP32 board, you must prepare your Arduino IDE with the following:
- Install the ESP32 board tools: read Espressif tutorial
- Install the HomeSpan library: read HomeSpan tutorial
The goal of this project is to convert a traditional portable air conditioning unit (that can cool and heat) into a connected AC that can be controlled from HomeKit. The AC unit was opened and the ESP32 was interfaced with the logic board using an infrared emitter.
The retrofit performed is very simple, as no AC components have to be modified, the ESP32 is basically simulating the IR remote controller that is provided with the AC unit, emitting mocked IR signals to the IR receiver PCB contained in the AC unit.
A small custom board should be built, with an IR emitter diode mounted on it, connected to the ESP32. The ESP32 manages a state machine of which state the AC unit is in, and which IR signals should be sent to change its current state to any desired state. The temperature sensor used is a DHT11.
The following libraries are being used, and should be installed from the Arduino IDE:
IRremote
(library here)DHT Sensor Library
from Adafruit (library here)EEPROM
The goal of this project is to measure the water level in a tank used for plant watering, using an ultrasonic sensor. The water level is periodically reported via a battery service to HomeKit (as there is no water level service, as of 2022).
This project requires an HC-SR04 ultrasonic sensor to be attached to the ESP32 board, with the following pin connections:
- Sensor
TRIG
to ESP32PIN 22
- Sensor
ECHO
to ESP32PIN 21
- Sensor
GND
to ESP32GND
- Sensor
VCC
to ESP32VCC
The following resistance values are used to obtain the ECHO
value:
R1
of 330 ohmsR2
of 470 ohms
The custom board that should be built follows the same schematics as described here.
The CAD files for the sensor casing parts are also provided in this project. They should be 3D printed on a SLA printer (mine is: Formlabs Form 3).