Skip to content

bittles/esp32switchbotlock

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Control SwitchBot smart lock with ESP32 (M5 Atom S3 Lite) BLE

Simple translation to english with Vivaldi's translate with American amazon links.

About this repository

It is a program that controls SwitchBot smart locks using ESP32's BLE (Bluetooth Low Energy) protocol.

I am using an ESP32 Arduino on PlatformIO.

By default, this code allows you to open and close smart locks via BLE. Under src/Switchbots, there are also codes for SwitchBot products other than smart locks, so if you modify them a little, you can operate other devices (for example, smart light bulbs, tape lights, etc.) with BLE.

動作中動画 Press the M5 Atom S3 Lite button to lock, and press and hold the button to unlock.

For more information, I have also written an explanatory article on my blog ''Tech Landlord''. The protocol details are also organized in the article, so it should be helpful when using the code in this repository.

SwitchBot BLE API (About protocol)

There is documented information about the BLE API for SwitchBot products on the following sites.

However, although the above API specifications include commands for some SwitchBot products, there is no mention of SwitchBot smart locks.

On the other hand, smart lock BLE operations are implemented as an implementation of the following library written in TypeScript that uses NodeJS.

Therefore, the code in this repository is a port of the necessary parts from the node-switchbot (Github) TypeScript code for ESP32 Arduino.

Payload encryption

Payload encryption is required to operate SwitchBot smart locks with BLE.

The KeyId and EncryptionKey required for encryption must be set appropriately in src/DeviceAddr_example.h (). If used, src/DeviceAddr.h must be renamed

This value is obtained by the following program.

To use it, you will need your SwitchBot cloud login information.

(Or Danielhiversen/pySwitchbot is also available)

Regarding KeyId and EncryptionKey, a little information is written in the setKey() description of the node-switchbot library.

The cipher uses AES 128bit CTR mode.

Dependencies

It relies on the following libraries.

  • m5stack/M5Unified@^0.1.16
  • fastled/FastLED@^3.7.0
  • m5stack/M5AtomS3@^1.0.0
  • h2zero/NimBLE-Arduino@^1.4.0
  • janelia-arduino/Vector@^1.2.2

(BLE uses lightweight NimBLE](https://github.com/h2zero/NimBLE-Arduino)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 96.9%
  • C 3.1%