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
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
- Name: this name does not seem important. It seems to be just used for the Homebridge newspaper
- Widget: defines the type of service HomeKit. For example TemperatureSensor for publication of temperature, HumiditySensor for moisture. All types of services supported by HomeKit are defined in the HAP-Node project here. Here is a non-exhaustive list of services managed by HomeKit. By assigning the appropriate service, Maison will be able to display the pictogram and the corresponding unit:
- AirPurifier
- AirQualitySensor
- BatteryService
- CameraControl
- CameraRTPStreamManagement
- CarbonDioxideSensor
- CarbonMonoxideSensor
- ContactSensor
- Door
- Doorbell
- Fan
- FanV2
- GarageDoorOpener
- HeaterCooler
- HumidifierDehumidifier
- HumiditySensor
- LeakSensor
- LightSensor
- Lightbulb
- LockManagement
- Microphone
- MotionSensor
- OccupancySensor
- SecuritySystem
- Slat
- SmokeSensor
- StatefulProgrammableSwitch
- StatelessProgrammableSwitch
- TemperatureSensor
- Thermostat
- Window
- WindowCovering
- Caption: the label that will be displayed in the House application (can be modified directly in House)
- Pin: the pin on which the information is retrieved or on which Homekit can send a command (for example to light a lamp …).
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
- Get Started with HC-SR04, measure distance by ultrasound. Arduino code example
- ESP32, GPIO pins and associated functions. I/O, PWM, RTC, I2C, SPI, ADC, DAC
- ESP32-CAM pinout and equipments. ESP-EYE, AI Thinker, TTGO T-Camera, M5Stack Timer Camera …
- ESP32-CAM. Which model to choose? ESP-EYE, AI Thinker, TTGO T-Camera, M5Stack Timer Camera …
- M5Stack Atomic GPS. ESP32 TinyGPS++ tracker, GPX export on SD card, visualization on Google Maps or VSCode
- Home Assistant. Install the snap on Synology NAS on an Ubuntu Virtual Machine