Xiaomi Sherlock Smartlock


red wire goes to 3.3v pin in raspberry pi
brown wire goes to ground wire in raspberry pi
Orange wire goes to GPIO4 pin in raspberry pi you should use 10k resostor in series with the button .

then you follow configuration as in athe attached file

doorlock.yaml (1.4 KB)

sorry for my unorganized work but simply take the pcb from the keyfob and solder these wires and you are good to go.


You can find my simple work in the last comment


Thanks a lot. FANTASTIC!!! Now need a cleaner solution (a box ?) where to fit all in.

I am sure the same can be achieved with an ESP8266. Anyone can help with what to upload on the ESP8266?


I have done it with a ESP8266 directly in the lock. I will upload how I did it in a few days!


Eagerly waiting. With power supply or battery? As I know esp8266 consumes a lot of power


Wonder if possible to use a Shelly or a Tasmota flashed Sonoff


I also look forward to your story about how you hooked up esp8266!


Hi, I am trying to open the keyfob, hoping to do no damage, but having a hard time. May you explain how you did it?


Remove battery cover first then remove battery . The front face of the keyfob is glued to the back , try to use sharp cutter and try to disjoint the face of the back .
I will share a video trying to discribe it


is there way to make sherlock s2 to work with mihome ?


I red somewhere that will be added, but was not an official voice/post. Until yesterday was not. I wrote to Sherlock asking from them an integration to Internet (Mi home or any other way of using BLE through the iuinternet). If enough users write, maybe they will isten.

I wrote here

[email protected]


Hi guys, I’ll explain you how I got to control the lock with an esp8266.

  1. I disassembled the lock trying to find some wires or some possibility to control the motor with MQTT protocol.

  2. I found four wires going from the main board to the touch switch. (You can see them in the photo from zanerv)

  3. I checked the wires and I realized about the code color: red -> positive, ground -> negative, withe -> data and yellow -> data. After this I tried to decode the protocol connecting the data wires from the touch switch to a ftdi usb adapter. I realized that when I pushed the switch to open it sent an 0 and when I pushed it to 1 it sent an 0 too, so I was confused.

  4. After I have tried with serie protocol, I used a logic analyzer, and I realized that when I pushed to open, the switch down pulse from the yellow wire during 19 ms and when I pushed to close the pulse was down during 43 ms. So I discovered how it worked.

  5. Knowing how it worked, I got a ESP8266 and I developed a program with arduino IDE to send both pulses to one pin depending of an mqtt message. This is the code: Xiaomi Sherlock MQTT code

  6. I added also to the code the possibility to continue detecting the touch switch. So the pinout of the esp8266 will be the next:

  7. I put the esp8266 out from the lock and the wires over the plastic case:

  8. Take attention that it’s necessary to connect the positive and negative directly to the lock battery.

  9. I attach also two photos with circuit finished and with the case closed:

  10. And finally the project is finished, I tried to be as much specific as I can, if you need some more details just tell me and I’ll explain you! I don’t know if this one is the best solution but I have done it some days ago and until now it’s working really good :slight_smile:



The worry is about battery consumption. Usually WiFi consumes a lot. How is your experience on it?
Also can you transmit the state (locked /unlocked)?

Need to decide between this solution and the keyfob hack


It’s totally true that it have incremented battery consumption, I have used it during one week and I have chargued it one time. It’s not too much at least for me, I’ll tell you all when I will experiment more chargue cycles.

For sure, I know all time the lock state because touching the phisical switch or doing it over MQTT, it goes across the esp8266.

I have tested it only for a week but it’s working really good, as soon as I connect the battery it connects to the wifi. I’ll update it using node-red and sensors as touch sensor, bluetooth beacons and wifi tracker.

The key solution it’s maybe easier but as much as I know, it is not compatible with all the lock versions, just with the last.


Hello guys, I have a vertical lock but i’m not able to mount the system vertically (no space with my door). Is there any solution so the key comes back in the vertical position by default after it finishes to close the door? (so i can open it from outside with my key?) Something like a configuration from the sherlock smartlock? Thanks


I asked sane question to a YouTuber, he said no.

That’s why the instructions specifically say to mount it as shown in the manual only.
But if you apply the keyfob hack, you open with your cellular


I think that the best solution it’s change the cylinder, using one with double clutch. It allows you to use one key inside and one key outside. It’s not expensive, it’s easy to install and it provides you safety because if the battery is out or for some reason the lock is not working, you will be able to open the door.


I’m currently trying to bypass the default horizontal detection by cutting a new corner on the last plastic circle so it will stop vertically instead of horizontally, I will come back here to show you the result


I forget to take photos but i successfully manged to make the sherlock S2 work with vertifical lock by stop up the 2 whole from the last mechanism circle which contains the metal part (the key). After removing the 2 whole, i have created one at 90° so the system stops vertically


Trying but having really a hard time