2.2 KiB
2.2 KiB
Getting started
Using LibreTuya is simple, just like every other PlatformIO development platform.
For your own projects
If you're developing your own embedded software, and want it to run on LibreTuya-supported chips, the installation is simple:
- Install PlatformIO
platformio platform install https://github.com/kuba2k2/libretuya- Create a project, build it and upload to the chip
Community projects
LibreTuya was developed with popular community projects in mind. Currently, unofficial ESPHome port is available (the PR will hopefully be merged into upstream at some point).
ESPHome
Because ESPHome does not natively support running on non-ESP chips, you need to use a fork of the project.
Assuming you have PlatformIO, git and Python installed:
- Open a terminal/cmd.exe, create
esphomedirectory andcdinto it. git clone https://github.com/kuba2k2/libretuya-esphome -b platform/libretuya(you need theplatform/libretuyabranch)- Go to Boards & CPU list and choose your board name.
- Create a YAML config file for your device. You can either:
- use
python -m esphome wizard yourdevice.yml- type answers to the six questions the wizard asks - if your board isn't available in the wizard yet, use the manual YAML method below
- write a config file manually:
esphome: name: yourdevice libretuya: board: wr3 logger: api: password: "" ota: password: "" wifi: ssid: "YourWiFiSSID" password: "SecretPa$$w0rd" ap: ssid: "Yourdevice Fallback Hotspot" password: "Dv2hZMGZRUvy"
- use
- Install LibreTuya:
platformio platform install https://github.com/kuba2k2/libretuya. This step is necessary, as otherwise ESPHome will try to use a version from the registry, which is often outdated. - Edit the config file to use your installed LT version:
libretuya: board: wr3 framework: version: latest python -m esphome compile yourdevice.yml- The binary file, ready for uploading, is now in
.esphome/build/yourdevice/.pioenvs/yourdevice/. Refer to your board README to find appropriate flashing instructions.