Introduction: Sonoff B1 With Native Apple Home Kit Make by Arduino

This insctuctables give you a quite easy way how to integrate Sonoff B1 lamp into your Apple home kit without any additional bridges

Intro: Sonoff B1 is a quite cheap but powerfull lamp which contains three types of Led's

1. White Led "Warm"

2. White Led "Cool"

3. RGB Led

Therefore they can be used by different combination and we can get in theory any possible effect by combining of brigthness of those Led's

Step 1: Prepare Lamp for Firmware Update

To update firmware we need a little soldering skills

Ok let's start

Unscrew the plastik cap and find contacts, we need to solder any wires or shield to be easy connect USB-UART convertor.

In my case i have used male header, hovewer any simple wires or wires with pins can be used. If you are going ton play a few time with the lamps wires should be short to be sure that plastic cap be screwed

That's all. Now you can update firmware very easy buy just unscrew a cap

Step 2: Connect a Lamp to USB UART

The wires is simple, but please be aware of two things:

1. ! Lamp should be disconnected from power voltage 220 v

2. ! Use USB UART with the setting 3.3 v, otherwise you will destroy device

Ok, let's connect


3.3V --> 3.3V


RX --> TX

TX --> RX

To GPIO 0 of the lamp just connect simple wire. Next will be explained a reason

Step 3: Prepare Arduino IDE

1. You need to have ready enviropment for programming ESP8266 chips. I will not detail there, because there are lot's of internet publication, have a look

2. Download the library and unzip it into the Arduino library folder. For Windows, this is usually C: \ Users \ \Documents \ Arduino \ libraries

3. From the attached archive unpack wolfSSL_3_13_0.rar into the same folder of the Arduino libraries. (C: \ Users \ \Documents \ Arduino \ libraries\wolfssl) . Please be sure that it's not duplicated root. Means files should be under (C: \ Users \ \Documents \ Arduino \ libraries\wolfssl)

4 . Download or install the library

Now we are ready to programm your ESP8266

Open the sketch

And set proper board setting on Arduino, see the pictures with the right setting

Step 4: Flashing Firmware

Connect your USB UART to computer. your lamp is ready to flash. In Arduino IDE choose proper COM port

There is a trick mentioned before. to switch chip into the flash mode GPIO 0 should be connected to GND during the power on or resetting

It can be done by two ways:

If USB UART with the reset button, then press the firmware upload button on Arduino IDE, wait for the upload message and connect wires from GPIO 0 to GND of Sonoff than press the USB UART Reset button, wait for the upload to start, after that wires can be disconnected Sonoff

If USB UART without the Reset button, then remove the USB from the computer, connect wires from GPIO 0 to GND Sonoff, insert the USB and click "download". After the download starts . All this is necessary to put Sonoff in boot mode (GPIO0 on GND at the time of power-up)

In my case I just simple touch wires from GPIO 0 to GND of USB UART, thera are enought rooms in GND

Ok, Upload should be started and you should see success message

You Lamp is ready to use, is better to reset that after flashing.

Step 5: Setup Lamp and Pairing With Apple

In my case I have continued setup and pairing process by still connecting Lamp to the USB UART to control a serial monitor what is happening

First we need to connect/configure lamp to your home WiFi

After rebooting Lamp will start in Access point Mode. You need to connect your computer to WiFi network named "ES". After connection you will be redirected to the captive portaal. If not, open a browser and put you should see a configuration portal

Select your wifi home network or input manually , enter a password and confirm. Lamp will be rebooted and in case of success you should see a logs like this

*WM: Connection result:
*WM: 3 *WM: IP Address:


WiFi connected IP address:

>>> Home Integration: homekit_is_paired 0


>>> HomeKit: Configuring mDNS
>>> HomeKit: MDNS.begin: ES-5AC5, IP: >>> HomeKit: Init server over

>>> HomeKit: Init server over Web server is NOT SET, waiting for pairing

Lamp is ready to pair ! Let's do

1 . Open the phone -> Apple home -> add device.

2. Do a choise to add manually and we see something like ES ....... available,

3 . Select that it and agree of course that it is not certified, input password 11111111 and let's go .....

As a rule, everything will pass the first time and you will immediately see it in the devices and you can turn it on and off.

In theory that is all, you can assembly your lamp connect and play...

If not, see troubleshoot section

Step 6: Troubleshooting

If something went wrong , Pairing process is the most capricious, and my testing and experience it can take up to maximum 3 attempts.

You need to reset your device and try again,

If device is not appeared in the list of pairings, probably device already stores pair information but Apple Not :(

We need to remove pairing information from device..

Pairing data is saved on the SPIFFS file system "/pair.dat". and you need open a browser

enter http://ip/browse and you will be accessed to your SPIFFs file system.

Where ip is IP address of your device

Just delete the file pair.dat, reset device and start pairing again