DIY Projects

Integrate Arduino / ESP8266 + Blynk IoT to iOS with Homebridge and HomeKit

6 homekit homebridge blynk ready

Blynk consists of a server and an application for iOS. If you have your own Blynk private server (read this article to learn how), you can make your connected objects developed using Blynk accessible from the internet without having to expose your hardware to the internet through the Homebridge project. For this you will need an Apple TV (4th generation at least) or an iPad (iOS 8 minimum) to communicate with your objects outside your home. The other advantage of exposing Blynk objects to HomeKit is to have a much better integration with iOS. You can order by voice or view your data from an Apple Watch.

Install Node.js on Raspberry Pi

This tutorial is adapted to Raspbian Pixel. First, make sure that Node.js is not already installed on your distribution. If so, you can proceed to the next step.

pi@raspberrypi:~ $ node -v
v6.3.1
Warning. Check the impact on other projects that use Node.js before you start.

If Node.js is not at least version 6.3.1, it is necessary to install it. Start by updating your system

sudo apt-get update
sudo apt-get upgrade

Then install Node.js and its dependencies

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install libavahi-compat-libdnssd-dev

Finally install Homebridge and the homebridge-blynk plugin (GitHub repository page)

sudo npm install -g --unsafe-perm homebridge hap-nodejs node-gyp homebridge-blynk

We will create a directory that will contain the configuration file

mkdir ~/.homebridge

At first we will configure the bridge to make it detectable by iOS. Although this does not seem to be mandatory, I prefer to know the Raspberry Pi’s MAC address. By doing this, iOS immediately discovers the Homebridge Bridge. Run ifconfig  and note the MAC address that corresponds to the connection mode (eth0 in Ethernet, and wlan0 in Wi-Fi).

Open the configuration file with a text editor

sudo nano ~/.homebridge/config.json

Paste this database (source) by adapting it to your configuration: server IP, HTTPS port, accessories.

{
    "bridge": {
        "name": "Homebridge",
        "username": "C8:28:EB:14:31:27",
        "port": 51826,
        "pin": "031-45-154"
    },

    "description": "This is an example configuration file. You can use this as a template for creating your own configuration file.",

    "platforms": [
            {
            "platform": "Blynk",
            "name": "Blynk",
            "server": "BLYNK_SERVER_IP",
            "httpsPort": "9443",
            "token" : "yourTOKEN",
            "dashboardName": "Blynk Sensors",
            "accessories": [
                {
                    "name":             "Temperature",
                    "widget":           "TemperatureSensor",
                    "caption":          "Temperature",
                    "pin":              "V0"
                },
                {
                    "name":             "Humidity",
                    "widget":           "HumiditySensor",
                    "caption":          "Humidity",
                    "pin":              "V1"
                }
            ]
        }
    ],
    "accessories": [
    ]
}

Here, I took again the example presented in this article which made it possible to recover the measurement of temperature and humidity of a probe DHT22. The plugin is documented very briefly. To retrieve measurements, the parameters

Save the configuration with CTRLM + X then O. Launch Homebridge

pi@raspberrypi:~ $ homebridge
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>
[2017-03-09 15:02:29] Loaded plugin: homebridge-blynk
[2017-03-09 15:02:29] Registering platform 'homebridge-blynk.Blynk'
[2017-03-09 15:02:29] ---
[2017-03-09 15:02:29] Loaded config.json with 0 accessories and 1 platforms.
[2017-03-09 15:02:29] ---
[2017-03-09 15:02:29] Loading 1 platforms...
[2017-03-09 15:02:29] [Blynk] Initializing Blynk platform...
[2017-03-09 15:02:29] [Blynk] Loading accessories...
[2017-03-09 15:02:29] [Blynk] Found: Temperature
[2017-03-09 15:02:29] [Blynk] Found: Humidity
[2017-03-09 15:02:29] [Blynk] Initializing platform accessory 'Temperature'...
[2017-03-09 15:02:29] [Blynk] Initializing platform accessory 'Humidity'...
[2017-03-09 15:02:29] Loading 0 accessories...
Scan this code with your HomeKit App on your iOS device to pair with Homebridge:
                       
    ┌────────────┐     
    │ 031-45-154 │     
    └────────────┘     
                       
[2017-03-09 15:02:29] Homebridge is running on port 51826.

Start Home on your iPhone or iPad, click Start

Then add an accessory

In order for Home to find the gateway, you must be connected to the same WiFi network.

Enter the PIN that appears in the Terminal

Pairing is in progress

It’s over

Home then offers to add devices connected to Homebridge. Here we start with the humidity sensor.

Then temperature

You can now enjoy your Blynk objects within the House application

Blynk objects are also available from the locked screen

Now, you can follow this tutorial to complete the Homebridge configuration and start it automatically at system startup

Click to rate this post!
[Total: 0 Average: 0]
Exit mobile version