From 9e2ae391fc33bca88acdeb3a468912840936bb59 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:38:12 +0100 Subject: [PATCH] Fix ESP32 piezo ceramic buzzer Fix ESP32 piezo ceramic buzzer doesn't buzz (#20118) --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + tasmota/tasmota_xdrv_driver/xdrv_24_buzzer.ino | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2609fcd7f484..4f1887cb2d1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file. ### Fixed - Matter Contact sensor was not triggering any update (#20232) - CVE-2021-36603 Cross Site Scripting (XSS) vulnerability (#12221) +- ESP32 piezo ceramic buzzer doesn't buzz (#20118) ### Removed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 2d809a33aa54..8953e82645e5 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -130,6 +130,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ### Fixed - CVE-2021-36603 Cross Site Scripting (XSS) vulnerability [#12221](https://github.com/arendst/Tasmota/issues/12221) +- ESP32 piezo ceramic buzzer doesn't buzz [#20118](https://github.com/arendst/Tasmota/issues/20118) - Matter Contact sensor was not triggering any update [#20232](https://github.com/arendst/Tasmota/issues/20232) ### Removed \ No newline at end of file diff --git a/tasmota/tasmota_xdrv_driver/xdrv_24_buzzer.ino b/tasmota/tasmota_xdrv_driver/xdrv_24_buzzer.ino index 81dcc1dc70ef..9a54076d5d28 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_24_buzzer.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_24_buzzer.ino @@ -52,7 +52,14 @@ void BuzzerSet(uint32_t state) { if (last_state != state) { // Set 50% duty cycle for frequency output // Set 0% (or 100% for inverted PWM) duty cycle which turns off frequency output either way +#ifdef ESP8266 analogWrite(Pin(GPIO_BUZZER), (state) ? Settings->pwm_range / 2 : 0); // set duty cycle for frequency output +#else + int32_t pin = Pin(GPIO_BUZZER); + if (analogAttach(pin, Buzzer.inverted) >= 0) { + analogWritePhase(pin, (state) ? Settings->pwm_range / 2 : 0, 0); + } +#endif last_state = state; } } else {