Wemos D1 Mini DHT HomeKit setup


The tutorial below is based primarily on work done by Aditya Tannu (see here and here) and tries to make things easier for beginners by reducing the setup to the bare essentials and providing clean and simple examples.

So, you might have gotten the iOS 10 beta and seen the Home app but don't wan't to spend an inordinate amount on commercial solutions and nowadays ESP8266 solutions are ubiquitous and cheap and those can be made to work with HomeKit.

You'll need three things running to actually make that work: a bridge for your sensors, an MQTT broker and the sensor itself. While you can certainly use a Raspberry Pi for the first two I chose a Mac mini since I have that already running anyway. Sadly, that solution is Node-based but I haven't seen any other solution that works out there.

The server

You should now be able to add the Node bridge in your HomeKit management application and see the fake sensors which are present in accessories. Once everything is running smoothly, you can run these as system services with an unprivileged user. See the project root for plist examples, just add your user name where necessary. I had some issues with calling node directly for HAP so I just made a one-liner bash script which then runs 'node BridgedCore.js' in the relevant directory.


The sensor

We can program the sensor with the NodeMCU stack but in my experience the Arduino one is far less volatile (for now).

You can now flash something onto the Wemos which will periodically send your data to the server. You can use my ino templates as a starting point. You still need set your Wifi SSID, password and the IP of the server you are sending data to.

Now that you are sending your results to the broker you still need the bridge to tell your HomeKit application about the accessory you wish to use and update its data when an update comes along. You can start with my accessory templates for humidity and temperature. You will only need to update those with the server IP, if you did not change anything else in the Arduino templates.



Hardcoding the channels for each accessory in the js template and the Arduino sketch is inefficient at best. If someone has a good tutorial for HAP-Nodejs that does that right, let me know.

I've noticed that the default of 10 minutes until the next update is a bit much and the accessory can be shown as timed out or zero out. Also let me know if you have a good default here or recommendations on power optimisation.