PlatformIO Community

Espressif 32 platform -> lbernstone/Tone32 @ ^1.0.0 library not work

Egy működő projectem, aktualizálását végeztem el amiben jelzőhang előállítására az lbernstone/Tone32 @ ^1.0.0 könyvtárat használom. Előtte frissitettem az Espressif 32 platformot 3.5-ről, 4.4.0-ra (korábban kipróbáltam a 4.2.0 is ) és még mindíg nem működik vele.
Visszaállítottam a 3.5-re ezzel újra van hang.
Tud valaki segíteni, hogy mi lehet a probléma?
Köszönettel: Steve Barth.

Blockquote
I have updated my working project, which uses the lbernstone / Tone32 @ ^ 1.0.0 library to generate a beep. Before that, I upgraded the Espressif 32 platform from 3.5 to 4.4.0 (I’ve tried 4.2.0 before) and it still doesn’t work with it.
I reset to 3.5 with this sound again.
Can anyone help me with what the problem might be?
Thanks to Steve Barth.

I’m experiencing this issue too. Works fine on PlatformIO 3.5.0 but fails on 4.4.0. Compiles OK, but no audio and serial log reports LEDC is not initialized

The proposed fix is to use ledcSetup(channel, frequency, bits), as reported in the closed issue tracker found here:

In other words, put ledcSetup() into your setup function. This solved the problem for me.

Does it work with the latest development version of Arduino for ESP32? If does not, please report the issue to Issues · espressif/arduino-esp32 · GitHub

Hello
I’m still a beginner, can you explain in more detail what to do?
thanks, Steve

I answer myself:
As a beginner, I could not find a solution to use the Tone32 library under the 4.4.0 framework, so I looked for another solution. (ESP32doit-devkit-1.1)
This: (I can read more about it here)

ledcWriteTone
This function is used to setup the LEDC channel to 50 % PWM tone on selected frequency.

double ledcWriteTone(uint8_t chan, double freq);

  • chan select LEDC channel.
  • freq select frequency of pwm signal.

This function will return frequency set for channel. If 0 is returned, error occurs and ledc cahnnel was not configured.

my own working code:

#include <pitches.h> // sounds definition
#define Sound_drv 13 // sound output GPIO13
#define PWM_ch 0 // use 0 PWM channel GPIO36

void setup(){
ledcAttachPin(13, 0); // (Sound_drv, PWM_ch)
}

void OK_sound(){
ledcWriteTone(0, NOTE_A5); // tone 880 HZ freq (PWM_ch,A5)
delay(100); // pause 100ms
ledcWriteTone(0, NOTE_CS6); // tone 1109 Hz freq (PWM_ch,CS6)
delay(100); // pause 100ms
ledcWriteTone(0, NOTE_FS6); // tone 1480 Hz freq (PWM_ch,FS6)
delay(150); // pause 150ms
ledcWrite(0, 0); // tone off
delay(10);
}

I hope I managed to help someone else with this, happy coding for everyone.
Steve.

thanks Iván, the lbernstone / Tone32 library still doesn’t work above the 3.5.0 framework.