Simple translation to english with Vivaldi's translate with American amazon links.
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.
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 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.
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)