arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.24k stars 4.81k forks source link

Buzzer remains active when pin unconfigured (ESP32) (minor issue) #20732

Closed vic42 closed 9 months ago

vic42 commented 9 months ago

PROBLEM DESCRIPTION

A clear and concise description of what the problem is.

The "buzzer" function remains active on a GPIO pin configured as "buzzer" after that pin gets unconfigured while a different GPIO pin is configured as "buzzer".

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

- [ ] If using rules, provide the output of this command: `Backlog Rule1; Rule2; Rule3`:
```lua
  Rules output here:

N/A

18:16:36.488 RSL: STATUS = {"Status":{"Module":1,"DeviceName":"Tasmota","FriendlyName":["Tasmota"],"Topic":"tasmota_661178","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0,"InfoRetain":0,"StateRetain":0,"StatusRetain":0}} 18:16:36.523 RSL: STATUS1 = {"StatusPRM":{"Baudrate":115200,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://ota.tasmota.com/tasmota32/tasmota32.bin","RestartReason":"Software reset CPU","Uptime":"0T00:07:48","StartupUTC":"2024-02-15T17:08:48","Sleep":50,"CfgHolder":4617,"BootCount":9,"BCResetTime":"2024-02-15T17:49:20","SaveCount":23}} 18:16:36.558 RSL: STATUS2 = {"StatusFWR":{"Version":"13.4.0.1(tasmota32)","BuildDateTime":"2024-02-15T09:44:35","Core":"2_0_14","SDK":"4.4.6.240105","CpuFrequency":160,"Hardware":"ESP32-D0WD-V3 v3.0","CR":"406/699"}} 18:16:36.572 RSL: STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"MqttLog":0,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["o_2ghz",""],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00008009","2805C80001000600003C5A0A192800000000","00000080","20006000","00004000","00000000"]}} 18:16:36.609 RSL: STATUS4 = {"StatusMEM":{"ProgramSize":1908,"Free":971,"Heap":147,"StackLowMark":3,"PsrMax":0,"PsrFree":0,"ProgramFlashSize":4096,"FlashSize":4096,"FlashChipId":"164068","FlashFrequency":40,"FlashMode":"DIO","Features":["0809","9F9AD7DF","0015A001","B7F7BFCF","05DA9BC4","E0360DC7","480840D2","20200000","D4BC482D","810A80B1","00000004"],"Drivers":"1,2,!3,!4,!5,7,!8,9,10,11,12,!14,!16,!17,!20,!21,24,26,!27,29,!34,!35,38,50,52,!59,!60,62,!63,!66,!67,!68,82,!86,!87,!88,!121","Sensors":"1,2,3,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,22,26,31,34,37,39,40,42,43,45,51,52,55,56,58,59,64,66,67,74,85,92,95,98,103,105,109,127","I2CDriver":"7,8,9,10,11,12,13,14,15,17,18,20,24,29,31,36,41,42,44,46,48,58,62,65,69,76,77,82"}} 18:16:36.678 RSL: STATUS5 = {"StatusNET":{"Hostname":"tasmota-661178-4472","IPAddress":"172.23.0.170","Gateway":"172.23.0.254","Subnetmask":"255.255.255.0","DNSServer1":"31.12.7.254","DNSServer2":"1.1.1.1","Mac":"94:B9:7E:66:11:78","IP6Global":"","IP6Local":"fe80::96b9:7eff:fe66:1178%st1","Ethernet":{"Hostname":"","IPAddress":"0.0.0.0","Gateway":"0.0.0.0","Subnetmask":"0.0.0.0","DNSServer1":"31.12.7.254","DNSServer2":"1.1.1.1","Mac":"00:00:00:00:00:00","IP6Global":"","IP6Local":""},"Webserver":2,"HTTPAPI":1,"WifiConfig":4,"WifiPower":16.0}} 18:16:36.724 RSL: STATUS6 = {"StatusMQT":{"MqttHost":"","MqttPort":1883,"MqttClientMask":"DVES%06X","MqttClient":"DVES_661178","MqttUser":"DVES_USER","MqttCount":0,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30,"SOCKET_TIMEOUT":4}} 18:16:36.742 RSL: STATUS7 = {"StatusTIM":{"UTC":"2024-02-15T17:16:36Z","Local":"2024-02-15T18:16:36","StartDST":"2024-03-31T02:00:00","EndDST":"2024-10-27T03:00:00","Timezone":"+01:00","Sunrise":"07:59","Sunset":"18:09"}} 18:16:36.775 RSL: STATUS10 = {"StatusSNS":{"Time":"2024-02-15T18:16:36"}} 18:16:36.785 RSL: STATUS11 = {"StatusSTS":{"Time":"2024-02-15T18:16:36","Uptime":"0T00:07:48","UptimeSec":468,"Heap":149,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":0,"Berry":{"HeapUsed":4,"Objects":46},"Wifi":{"AP":1,"SSId":"o_2ghz","BSSId":"B4:FB:E4:11:20:B7","Channel":1,"Mode":"11n","RSSI":56,"Signal":-72,"LinkCount":1,"Downtime":"0T00:00:04"}}}

- [x] Set `weblog` to 4 and then, when you experience your issue, provide the output of the Console log:
```lua
  Console output here:

18:17:37.606 CMD: buzzer 2,3,4
18:17:37.608 SRC: WebConsole from 172.23.0.254
18:17:37.610 CMD: Grp 0, Cmd 'BUZZER', Idx 1, Len 5, Pld 2, Data '2,3,4'
18:17:37.613 BUZ: Count 2(4), Time 3/4, Tune 0x00000000(0x00000000), Size 0, Mode 1
18:17:37.615 RSL: RESULT = {"Buzzer":"Done"}

TO REPRODUCE

Steps to reproduce the behavior: 1) connect a speaker (and/or Oscilloscope) to GPIO27 2) configure GPIO27 as "Buzzer" 3) SO111 1 4) Issue buzzer command 5) configure GPIO27 as "none" 6) configure GPIO0 (or probably any other GPIO) as "Buzzer" 7) Issue command buzzer 2,3,4

RESULT: The buzzer waveform appears both on GPIO27 and GPIO0

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen.

The buzzer waveform should only appear on GPIO0

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

(Please, remember to close the issue when the problem has been addressed)

sfromis commented 9 months ago

Testing with a LED, I'm also seeing this with ESP32-D0WDQ6 v1.0, but not on ESP32-C3.

arendst commented 9 months ago

Is it only GPIO27 as original GPIO and then any other GPIO or does it happen with any two GPIOs?

You might want to try GPIOViewer and see if it also pops up with unexpected changing GPIO's.

vic42 commented 9 months ago

Tried it with GPIO25 and GPIO5 -> same result. So it seems like it's happening with any two (or more?) GPIOs. GPIO Viewer does not seem to show any signs of what's happening Screenshot_20240216_165044

sfromis commented 9 months ago

My testing was with yet another pair of gpio pins (12,13), and the GPIO viewer only shows the pin configured as Buzzer, while both LED outputs are blinking.

Not sure what "see if it also pops up with unexpected changing GPIO's" means.

vic42 commented 9 months ago

In my case (25,5) the unconfigured pin did not show any signs of activity in GPIO viewer. I went on configuring one after another 27, 25, 0 as buzzer. The waveform was present on both 25 and 27 while GPIO0 was the only pin currently configured as buzzer.

arendst commented 9 months ago

Not sure what "see if it also pops up with unexpected changing GPIO's" means.

GPIO Viewer initially shows configured GPIO's and after that only new changing GPIO's. If they do not change between sampling time (default 100mS) they won't pop up as active GPIO.

arendst commented 9 months ago

Ah verified! Great fun. What's happening here. For some reason the PWM channel is not released.

A reset releases the PWM channel.

Investigating.....

arendst commented 9 months ago

It's also a problem with moved PWM channels; The GPIO's, once a PWM now set to None are still performing like PWM GPIO's.

arendst commented 9 months ago

Thie may lead to a solution https://github.com/micropython/micropython/issues/5737 ...

arendst commented 9 months ago

OK. I have a fix. Need to further test where to use and what the impact will be.

void analogDetach(void) {
  for (uint32_t pin = 0; pin < SOC_GPIO_PIN_COUNT; pin++) { 
    if (pin_to_channel[pin] > 0) {
      ledcDetachPin(pin);
    }
  }
}
arendst commented 9 months ago

This will fix the GUI Module Config. Still need to fix Template Config and command line GPIO config changes.

Give it a try.

sfromis commented 9 months ago

Now the Buzzer from the previous boot seems to be gone for good.

sfromis commented 9 months ago

Just tested on the updated precompiled ESP32-S3 build, and am seeing the previous Buzzer pin joining the party. "Version":"13.4.0.1(tasmota32)","BuildDateTime":"2024-02-16T19:16:03"

arendst commented 9 months ago

Thx. The fix only solved the issue on esp32. I'll make it work for all AND on every restart.