Closed thomas374b closed 10 months ago
BTW: It would be nice if frequency and duty could be configured. Depending on the used hardware (there might be capacitors) the buzzer could be at loudest on a certain (frequency,duty) setting
There is some work done and I already have a driver for testing, that should be able to do all of that via Berry. As I could write a prototype driver on top of it in Berry to play arbitrary RTTTL ringtones with user defined volume levels, I suppose this should cover a variety of needs.
The rest of the development is more about how (which API will be „invented“ or if it will be included in an existing module ) this can be integrated, not if it is technical possible.
@staars I think the OP has issues with the standard driver which supports both ESP8266 ans ESP32. As berry only supports ESP32 your solution won't fix the ESP8266 but might fix the OP's issue ;-)
I'll have a look at the standard driver while you are free to add your ESP32 berry solution.
As a workaround on ESP32 set pwmrange to 255 with command PwmRange 255
. This seems to work for me.
Still need to find out why the other pwmranges (511 and 1023) do not work ...
EDIT: I suppose the buzzer just doesn't support higher frequencies and instead just clicks.
EDIT2: Using the gpio as a PWM channel (SO15 0
) the buzzer buzzes between 10 and 1020 so the buzzer should sound as coded by BuzzerSet(). Investigating...
EDIT3: ESP32 needs a different way of accessing analog output as does the PWM driver. This needs a redesign of the buzzer. In the worst case, there is no relation between the GPIO and the analog output channel. Needs a lot of investigation....
The "buzzer" is a standard PC speaker connected via a Transistor and works fine with up to 8kHz when the duty is set to 127. It's not a problem of the hardware.
When using the pin as PWM, different code comes into play as when the pin is used as "Buzzer".
PS: In my code-review I saw another (tasmota-)driver using the same API where the implementor used a fixed constant 127 for duty (not a variable, and probably he knew why)
Pls try latest dev branch and report back.
Yes, I can confirm that the correction from https://github.com/arendst/Tasmota/commit/9e2ae391fc33bca88acdeb3a468912840936bb59 works.
With PwmFrequency command one can change the pitch of the buzzer and it is loud and clear to hear
PROBLEM DESCRIPTION
When using a PWM buzzer (SetOption111 1) the buzzer makes no sound, only silent clicks are to hear
REQUESTED INFORMATION
Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!
Backlog Template; Module; GPIO 255
:Status 0
:TO REPRODUCE
EXPECTED BEHAVIOUR
one second of noise with approx. 977Hz
ACTUAL BEHAVIOUR
two silent clicks with approx. 1 second distance
SCREENSHOTS
If applicable, add screenshots to help explain your problem.
ADDITIONAL CONTEXT
as I already mentioned in issue #8794
It seems to be that the function analogWrite(pin, duty); in method BuzzerSet() in file xrdv_24_buzzer.ino is wrapping the duty to 8 bits.
I verified it with a scope and customized self-compiled firmware with constant duty := 254 I get sound with a 8µs long L-Pulse duty := 255 I get nothing, but one click duty := 256 I get nothing, but one click duty := 257 I get sound with a 4µs long H-pulse duty := 128 I get sound with equal length L- and H- pulse
The argument in the original code id pwm_range/2. But pwm_range is 1023 and 511 folded to 8bit is 255 Thats why, the buzzer is only silent clicking instead of buzzing
(Please, remember to close the issue when the problem has been addressed)