Taming a Wild Animal: Adding Homekit Support to the Redmond SkyPlug RSP-100S Smart Socket


For the first time I learned about this outlet from the article Smart Redmond SkyPlug RSP-100S article Analysis of the design and the electrical circuit diagram. Identify flaws . I remember that after reading it, first of all I became interested in the circuit of a transformerless power source and how compactly the elements are placed in the housing of the outlet, despite the fact that there is a full-fledged relay inside, and not, say, a triac.

There were no speeches about any attempts to reprogram the Bluetooth module, since the programming of BLE devices has historically been a very difficult task. Here is an example: Developing IoT devices using Bluetooth LE is clearly not a DIY level.

However, over the past year the situation has radically changed ...

It all started with the fact that the Indian programmer Sandeep Mistry (pictured) ...


... ported Wiring, aka the Arduino framework, it’s just “Arduino” to the Nordic Semiconductor nRF51822 and nRF52832 chips, writing the BLEPeripheral library to create on the above-mentioned peripheral chips with BLE4.x support

Then Arduino AG (ex-arduino.org) joined the collaboration with Nordic and released the Arduino Primo board ...


... based on the nrf52832 chip. I wonder how quickly you find the nRF52832 itself on the board (hint: the big one on the left is not him). For compatibility with Arduino, the board uses the code created by Sandip, and he himself was taken to the state. The story repeats with espressif, esp8266 and Ivan Grokhotkov (igrr), where it all began in the same way with "folk" developments.

Adafruit and Sparkfun were also soon marked by the release of boards on the nRF52.

In general, it seems that the nRF5 family (nRF51822 and nRF52832) is now the most "fashionable" chip among all the majors that define the electronic DIY market. By “major” I mean Arduino, Adafruit and Sparkfun. Asians in the face of ITEAD or SEEED are still lagging behind, but I think this is not for long. At least, noname Chinese with Ali are punching the modules on these chips with might and main, and if the modules on nRF51822 were pretty awkward, then the modules on nRF52832 are excellent.

What kind of chip is so remarkable and why, apparently, does it have big chances to finally replace the famous atmega328 in DIY crafts?

nRF5 SoC


general description

The nRF52832 is a new, powerful, low-power and flexible “system on a chip” with support for Bluetooth Smart, ANT protocols and proprietary user-designed stacks in the 2.4GHz frequency band.

The nRF52832 is built on a 32-bit ARM Cortex-M4F processor core with 512kB Flash and 64kB RAM memory. According to the work protocol, nRF52832 is fully compatible with the previous nRF51, nRF24L and nRF24AP series manufactured by Nordic Semiconductor.

This is also very important, for example, I have all home automation done on nRF24L01 and this backward compatibility makes it easy to replace the atmega328 + nRf24 combination with one nRF5

Improved processor performance

The nRF52832 contains the powerful ARM Cortex-M4F processor core, which meets the requirements of many computationally demanding performance, but at the same time compact applications capable of running on a single chip. The core is able to solve the problems of digital signal processing, perform floating point operations, perform multiplexing and accumulation operations within one working cycle, and hardware supports an energy efficiently implemented division operation in real and complex forms.

Multiprotocol radio part

The 2.4 GHz radio part is compatible with Bluetooth Smart, ANT protocol stacks and any proprietary stacks. The radio has a built-in high-resolution RSSI register with the possibility of automatic operation in EasyDMA mode for direct memory access at the time of receiving and transmitting data over the air. Nordic provides Bluetooth Smart, ANT and Gazel (2.4GHz) protocol stacks as downloadable content on its official website.

The Bluetooth stack in the Nordic version is called SoftDevice, remember this word, it will meet us today.

Energy efficiency

nRF52832 is a super-low-power on-chip system capable of using power in the range from 1.7V to 3.6V. All peripherals and clock generators can be quickly switched off automatically in order to reduce power consumption to a minimum level. The integrated processor core has an automated adaptive power management system. Power consumption is automatically adjusted depending on the operations currently performed by the processor core when accessing peripheral devices so that only those components of the system that are necessary to perform the current task are working.

Add: the ability to reassign pins, support for up to 8 interrupts, and so on, and so forth. Almost perfect chip :)

The transformation begins

But back to our outlet. As it turned out, it is ideally suited for DIY, no worse than the cult Sonoff modules from ITEAD. The programming connector is kindly rendered and labeled XP1:


The order of the pins, of course, is not signed, but it does not matter, because we have a scheme . It has one small inaccuracy, the correct order of the pins is (from left to right):

Debug Interface - SWD. So, let's go:

At this, the programming of the socket itself can be considered complete and it ALREADY works. How to check it?

Part Two Add support for Homekit

Unfortunately, there is not yet a generally available way to tie Homekit support to a BLE device directly. This requires Apple's certification under the Mfi program, so support is only possible through a pad in the form of a Homekit server, the most famous of which is Homebridge.

Installing homebridge yourself

My homebridge is successfully working on Raspberry pi 2, but for the purposes of this publication, I put another one on Raspberry Pi Zero W (I will not go into details, if interested, I am ready to answer the questions in the comments)

sudo apt-get install npm sudo npm install -g --unsafe-perm homebridge node-gyp 

Install the BLE plugin

1) We put the javascript library NOBLE from the already known to us Sandip Mistry, and he noted here:

 sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev sudo npm install -g noble 

2) Put the actual plugin

 sudo npm install -g homebridge-bluetooth 

Configuring Homebridge

Edit config.json in the .homebridge folder. If you have a Raspberry Pi 2, then it is in the home directory / home / pi

 nano /home/pi/.homebridge/config.json 

And we replace its contents with

"Bridge": {
"Name": "igrushkin",
"Username": "CC: 22: 3D: E3: CE: 30",
"Port": 51826,
"Pin": "314-15-926"
"Description": "Raspberry Pi Homebridge-Bluetooth Lightbulb Example",
"Platforms": [
"Platform": "Bluetooth",
"Accessories": [
"Name": "Arduino",
"Address": "ff: 86: 91: c7: 50: 66",
"Services": [
"Name": "LED",
"Type": "Lightbulb",
"UUID": "19b10000e8f2537e4f6cd104768a1214",
"Characteristics": [
"Type": "On",
"UUID": "19b10001e8f2537e4f6cd104768a1214"

We start homebridge in debug mode (key -D, letter CAPTURE):

 sudo homebridge -D 

closely monitor the messages. Find the line “LED - Ignored” and write out the BLE address of our outlet (analogous to the MAC address).

Alternative option: we start hcitool (the utility for work with BLE devices)

 sudo hcitool lescan 

and find the address in the list of devices.

Exit by pressing Ctrl-C. Change the address in config.json to the correct one:

 nano /home/pi/.homebridge/config.json 

Run homebridge again. This time everything should be OK, and Homebridge will happily recognize our outlet.


I think it makes no sense to write how to add a new device to Homekit, much has been written about it, including information on the Apple website itself. I can only say that for this it is more convenient to use the program Elgato Eve , and not the native Home application.


Used materials:

  1. Smart Redmond SkyPlug RSP-100S Socket Analysis of the design and the electrical circuit diagram. Identifying deficiencies
  2. Arduino Core for Nordic Semiconductor nRF5 based boards
  3. homebridge-bluetooth plugin
  4. noble A Node.js BLE (Bluetooth Low Energy) central module.
  5. NRF52832 Bluetooth smart solution

Source: https://habr.com/ru/post/407683/

All Articles