Arduino and Apple HomeKit Integration - Control Your Home From Siri! IoT Is Here

136,455

186

26

About: @arduinoblogger

This Instructable will give you a quick and easy way to add an arduino board to Apple's HomeKit on an iOS device. It opens up all sorts of possibilities including Scripts running on the server, combined with Apples HomeKit "Scenes", it makes for a powerful combo!

This is by no means a complete solution or ready for long term use but it demonstrates what's possible with a bit more work :) Check out my blog for future projects www.arduinoblogger.co.uk

Whats needed:

  • Arduino with Ethernet Shield or WiFi
  • Raspberry Pi or some other server
  • Solid State Relay or Normal relay with control circuit
  • Bread board - optional
  • Project Box
  • Some Time
  • iOS device
  • Extension Lead to carve up

Step 1: Setup the Server

This project requires the use of a server to run the HomeBridge software. I used a Raspberry Pi as I had it readily available but in theory anything that can run Node.Js should work!

You can follow this guide here to get this up and running on a Raspberry Pi. Other instructables are around to build a Raspberry Pi if you need those!

https://github.com/nfarina/homebridge/wiki/Running...

Once installed you need install a plugin and customise the config.json file

Step 2: Config and Plugins

Open your config.json file which should be in ~/.homebridge/config.json using your favourite text editor and add the following

{
"bridge": {

"name": "Homebridge",

"username": "CC:22:3D:E3:CE:30",

"port": 51826,

"pin": "031-45-154"

},

"platforms": [

],

"accessories": [

{

"accessory": "Http",

"name": "Living Room Lamp",

"on_url": "http://192.168.1.201:80/?on",

"off_url": "http://192.168.1.201:80/?off",

"http_method": "GET"

}

]

}

You will also need to install the homebride-http plugin. The HomeBridge software will make HTTP GET requests to the Arduino which will then turn the Solid State Relay on or off. The call looks like this:

http://192.168.1.X:80/?on

http://192.168.1.X:80/?off

To install the plugin type:

npm install homebridge-http

Step 3: Setup the Solid State Relay

I have used quite a heavy duty Solid State Relay. This can be (and will be in future versions of this) replaced for something much smaller. Obviously rate this for the load you intend to run off it.

This is effectively a 'Smart' extension lead now.

The positive Leg of the Solid State relay will connect to pin 5 on the arduino.

The negative will connect to the GND pin.

All usual warnings apply when dealing with 120/ 220 vdc - TAKE CARE.

Step 4: Connect the Solid Sate Relay and Upload the Arduino Code

Open up your arduino environment and upload this sketch.

Customise your IP address as needed.

This should now be ready for testing.

Launch homebridge on the server!

Step 5: Test!

Now that everything is in place its time to test!

Download Elgatu Eve from the App Store on you iOS device.

You should see Homebridge as an accessory available to be connected. Use the pin number 031-45-154, this can be customised in the config.json file.

Once connected you can move this around within the App into the desired Room etc. Give Siri a test! It should be able to control the relay using voice!

Step 6: Next Steps

The plan is to shrink this down and use something like a Nano and embed this in Lightswitches / wall sockets with much smaller Relays and use WiFi for a complete Home Automation system.

Hope someone gets some use out of this! Many thanks to Nick Farina for his work on the Homebridge Software!

A video is coming soon.

Check out my blog:

www.arduinoblogger.co.uk

2 People Made This Project!

Recommendations

  • Big and Small Contest

    Big and Small Contest
  • PCB Contest

    PCB Contest
  • Toys Contest

    Toys Contest

26 Discussions

0
None
Moisesd8

6 months ago

I've done almost everything, but it keeps showing that are no plugins found...

When I install the plugin:

pi@raspberrypi:~ $ sudo npm install homebridge-http

npm WARN pi No description

npm WARN pi No repository field.

npm WARN pi No license field.

+ homebridge-http@0.0.9

updated 1 package in 4.736s

But when I run the homebridge command:

pi@raspberrypi:~ $ homebridge

[2018-6-3 22:48:15] No plugins found. See the README for information on installing plugins.

[2018-6-3 22:48:15] Loaded config.json with 1 accessories and 0 platforms.

[2018-6-3 22:48:15] ---

[2018-6-3 22:48:15] Loading 0 platforms...

[2018-6-3 22:48:15] Loading 1 accessories...

/usr/lib/node_modules/homebridge/lib/api.js:64

throw new Error("The requested accessory '" + name + "' was not registered by any plugin.");

^

Error: The requested accessory 'Http' was not registered by any plugin.

at API.accessory (/usr/lib/node_modules/homebridge/lib/api.js:64:13)

at Server._loadAccessories (/usr/lib/node_modules/homebridge/lib/server.js:264:42)

at Server.run (/usr/lib/node_modules/homebridge/lib/server.js:86:38)

at module.exports (/usr/lib/node_modules/homebridge/lib/cli.js:40:10)

at Object.<anonymous> (/usr/lib/node_modules/homebridge/bin/homebridge:17:22)

at Module._compile (module.js:652:30)

at Object.Module._extensions..js (module.js:663:10)

at Module.load (module.js:565:32)

at tryModuleLoad (module.js:505:12)

at Function.Module._load (module.js:497:3)

pi@raspberrypi:~ $

0
None
MàđhúkêshT

8 months ago

Hello ! i have everything running ! But can we use the same idea on NodeMcu ? it is cheaper and smaller too !!

0
None
bernigibtsschon

1 year ago

Hej, thank you for your great tutorial! What I didn't understand:

- What exactly is the purpose of node.js?

- If I do not want to use a raspberry pi (I do not have any), what are my options? I heard that Homekit devices can be controlled by AppleTV -- can I use the AppleTV for this project, too? And how?

0
None
DolboD

1 year ago

why do you need arduino if you use raspberri bi? it would be cool to use just arduino and run the homekit server there

0
None
PiergentiliA

2 years ago

Hello ... I did it. Only a problem. the pin5 is high for a while and soon low. I checked the code from the web page with out homebridge. I'm afraid that a delay for the links (on and off) are necessary because you activate on and off at the same time. Can you check the code? a request ... How to add more controls ( 2 or more relay)?

3 replies
0
None
bgodsellPiergentiliA

Reply 2 years ago

use this instead. It did the trick for me...

if(readString.indexOf("?on") >0)//checks for on

{...}

if(readString.indexOf("?off") >0)//checks for off

{...}

0
None
GalenW1bgodsell

Reply 2 years ago

thank you that was driving me crazy i spent an hour trying to fix it myself

0
None
andyman5002

1 year ago

I've redone my blog http://www.arduinoblogger.co.uk. Going to start updating it with more projects and post them here too!

0
None
jackwan1

1 year ago

Hi I am 99%, I got the homebridge loaded on Ubuntu and was able to pair the homebridge on Elgato Eve, the only problem is after that homebridge appeared as an accessory, I still have no control of my device. siri does not seem to recognize the command "please open my Garage Door" in the Eve "setup" I saw Accessory Name "Homebridge" Manufacturer: default, Model: default, serial number: default The homebridge is in room garage and the above setup is in the "accessory Info" Am I missing some thing?

Of course, I've changed the ip addresses to a static address. Homebridge also recognized my name change to "My Garage Door" instead of "Living Room Lamp". The arduino code loaded up without a hitch. I am using an Xboard, which is combined Arduino Leonado and two relays. The relays are on D7 and D8 so I made the appropriate changes in the .ino skatch as well. I used ping 7 instead of ping 5 and made the changes throughout the skatch

0
None
SamuelB140

1 year ago

Awesome tutorial! I'm up and running, but am wondering if there's a way I could use an Arduino without using an ethernet connection. Could I somehow use the USB? Maybe using something like this?

https://www.instructables.com/id/Internet-Controlled-Arduino-no-Ethernet-shield/step2/Getting-Started-Arduino-Part/

1 reply
0
None
andyman5002SamuelB140

Reply 1 year ago

yes you could use USB. You would need to parse the commands via the serial interface instead.

0
None
Zavin

2 years ago

Hey. Can it be done vwith arduino and Bluetooth module??

0
None
GabrielC191

2 years ago

Hi, I am a newbie with these stuffs. Very nice post. But I am a little bit confused: why using a raspberry pi and an arduino? I mean, why not to use only a raspberry pi? Thanks

1 reply
0
None
aslater4GabrielC191

Reply 2 years ago

No reason really other than I am more comfortable with the platform! In theory you can use the GPIO pins on the RPi to achieve the same results!

0
None
MoniCris

2 years ago

Nice project. I've done this project only with RPi 2, but not with arduino. As soon I can, i'l make it. Thanks.

0
None
Stoner221

2 years ago

Very well done. Works like a charm.

0
None
GalenW1

2 years ago

Ok i get Homebridge to show up in iOS Home app, but not the "Living Room Lamp" accessory, it is never listed. what am I missing? thanks