This project aims to implemenent something like homebridge, but for ESP32 devices. You can write your own plugins to expose the sensors to Homekit. Homebridge is no longer needed. Fakegato History support is currently available for temperature, humidity and pressure as well as for power consumption characteritics.
It uses arduino-esp32 v1.0.4.
esp-idf v3.2 (7dd492319) is also required.
- Expose accessories with sensors to Homekit, like homebridge
- Easy to add your own plugins
- Fakegato history support builtin (temperature, humidity and pressure, and power consumption)
- HTTPS Webserver and a small rest api
- Configuration via a json file
- Updates via Arduino OTA and HTTP download
This is a application to be used with Espressif IoT Development Framework (ESP-IDF)
and arduino-esp32
.
Please check ESP-IDF docs for getting started instructions and install instructions.
Espressif IoT Development Framework
Then install arduino-esp32 as esp-idf component as described here
Once the ESP-IDF and arduino-esp32 is installed:
$ git clone https://github.com/An00bIS47/Homekit
$ cd Homekit
$ git submodule update --init --recursive
$ make -j4
$ make flash monitor
If you encounter errors regarding compiling the components, add a file called components.mk
to the affected directory and specify where to find the source files.
For example the components.mk
for the SSD13XX
component it would look like tnis:
COMPONENT_SRCDIRS:=.
COMPONENT_ADD_INCLUDEDIRS:=.
There seems to be a bug with Enable hardware MPI (bignum) acceleration
so you have to disable it when working with mbedtls srp
Add the following defines to $(IDF_PATH_)/components/mbedtls/port/include/mbedtls/esp_config.h
to fix linker errors regarding HDFK and POLY1305CHACHA20.
#define MBEDTLS_HKDF_C
#define MBEDTLS_POLY1305_C
#define MBEDTLS_CHACHA20_C
#define MBEDTLS_CHACHAPOLY_C
Add a file called WiFiCredentials.hpp
in the main
folder and edit the settings:
//
// WiFiCredentials.hpp
// Homekit
//
// Created on:
// Author:
//
#ifndef WIFICREDENTIALS_HPP_
#define WIFICREDENTIALS_HPP_
#define WIFI_SSID "SSID"
#define WIFI_PASSWORD "PASSWORD"
#endif /* WIFICREDENTIALS_HPP_ */
Have a look at the file main/HAP/HAPGlobals.hpp
in order to change some configs to your needs. There you can enable the plugins you want to use.
Change plugin section in the file main/HAP/HAPGlobals.hpp
to this
/**
* Plugins
********************************************************************/
#define HAP_PLUGIN_USE_DHT 0
#define HAP_PLUGIN_USE_LED 0
#define HAP_PLUGIN_USE_SWITCH 0
#define HAP_PLUGIN_USE_MIFLORA 0
#define HAP_PLUGIN_USE_BME280 1
#define HAP_PLUGIN_USE_INFLUXDB 0
#define HAP_PLUGIN_USE_SSD1331 0
#define HAP_PLUGIN_USE_PCA301 0
#define HAP_PLUGIN_USE_NEOPIXEL 0
Either connect an BME280 sensor to your board or you can use also a dummy with random values.
If you choose to use a dummy sensor, then change the define in the file plugins/BME280/HAPPluginBME280.hpp
to this
#define HAP_PLUGIN_BME280_USE_DUMMY 0 // if 0 then use real sensor,
// if 1 then use random values without any real sensor connected
The hostname is generated using a prefix e.g. esp32-
and the last 3 bytes of the mac address.
The prefix can be configured in the file main/HAP/HAPGlobals.hpp
. Have a look at the value of HAP_HOSTNAME_PREFIX
.
A https webserver is available for a more convenient way of pairing your iOS device with a QR code. Just call https://hostname
(see above) and scan the QR code.
If you connect an SSD1331 OLED Display and enable the SSD1331 plugin, a QR code will be shown on the display until the device is paired.
Otherwise the default pin code to pair is 031-45-712
.
Pairings will be stored in the nvs.
A partitions.csv
is included in the project and should be compiled and flashed once.
Use make partition_table
to create the partition table bin.
Use make partition_table-flash
to flash only the partition table.
make flash
will flash everything including the partition table.
The partition table is defined as follows:
Name | Type | Subtype | Offset | Size |
---|---|---|---|---|
otadata | data | ota | 0xD000 | 8K |
phy_init | data | phy | 0xF000 | 4K |
ota_0 | app | ota_0 | 0x10000 | 1958K |
ota_1 | app | ota_1 | 1958K | |
nvs_key | data | nvs_keys | 4K | |
nvs | data | nvs | 32K | |
---------- | ------- | ---------- | ----------- | ----------- |
Plugins are meant to provide services and characteristics for the Homekit Bridge.
Have a look at the plugins available in this folder main/HAP/plugins/
.
There are several plugins available like
Exposes a temperature, humidity and pressure sensor with fakegato history support.
Exposes mutliple PCA301 outlets to Homekit with fakegato history for power consumption.
Exposes a temperatue, humidity and a (dummy) pressure sensor with fakegato history support.
Uploads every x seconds the values of each characteristics to an influxdb server.
View the QR code for pairing and the sensor values on an SSD1331 OLED Display.
Connects MiFlora Flower bluetooth devices to Homekit. This plugin exposes a temperature, moisture, fertility and light itensity sensor with fakegato history support
Exposes one NeoPixel to Homekit as a LED bulb.
This project uses by default mbedtls and libsodium for cryptography. WolfSSL is also support but commented out in the makefile.