Speaker function ?
Moderators: grovkillen, Stuntteam, TD-er
Speaker function ?
Maybe its easy (don't know) to implement to have a speaker function so you get a acknowledge from Domoticz, with some different tones, for different functions.
http://<ESP IP address>/control?cmd=spk,<pin>,1-2-3 etc
http://<ESP IP address>/control?cmd=spk,<pin>,1-2-3 etc
-
- Normal user
- Posts: 40
- Joined: 17 Nov 2015, 15:58
Re: Speaker function ?
Could be done with a piezo like this and pwm:
Ebaybuzzer.
Ebaybuzzer.
Re: Speaker function ?
Yes,..this piezo buzzer (speaker) I mean, is it already working ?
Re: Speaker function ?
Thank you for the lead, http://192.168.50.194/control?cmd=Pulse,14,1,100 did the trick for me, single tone do, but it does the job
With PWM you have to send a off command as well, pulse stops after 100ms, in this case.
With PWM you have to send a off command as well, pulse stops after 100ms, in this case.
Re: Speaker function ?
I add some code to _P001_Switch, now I can play tone with any frequency: http://192.168.3.57/control?cmd=tone,14,330,2000 - on port 14 play E1 two seconds.
and
Or play RTTTL melody: http://192.168.3.57/control?cmd=rtttl,14,Bach - Prelude In C Minor:d=8,o=5,b=180, c6, b, c6, p, g, g-, p, f, b, c6, p, d6, p, g, p, c6, b, c6, p, d6, p, f, g, g-, 4p, g, f, 4d-
and
Or play RTTTL melody: http://192.168.3.57/control?cmd=rtttl,14,Bach - Prelude In C Minor:d=8,o=5,b=180, c6, b, c6, p, g, g-, p, f, b, c6, p, d6, p, g, p, c6, b, c6, p, d6, p, f, g, g-, 4p, g, f, 4d-
Re: Speaker function ?
Hi Marteln,
can you share the code ?I add some code to _P001_Switch
regards
Dominik
Dominik
Re: Speaker function ?
Here it is. There are two new function:
void play_rtttl(uint8_t _pin, char *p )
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
and two if statements:
if (command == F("rtttl"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 16)
{
pinMode(event->Par1, OUTPUT);
char sng[1024] ="";
string.replace("-","#");
string.toCharArray(sng, 1024);
play_rtttl(event->Par1, sng);
setPinState(PLUGIN_ID_001, event->Par1, PIN_MODE_OUTPUT, event->Par2);
log = String(F("SW : ")) + string;
addLog(LOG_LEVEL_INFO, log);
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par1, log, 0));
}
}
if (command == F("tone"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 16)
{
pinMode(event->Par1, OUTPUT);
tone(event->Par1, event->Par2, event->Par3);
setPinState(PLUGIN_ID_001, event->Par1, PIN_MODE_OUTPUT, event->Par2);
log = String(F("SW : ")) + string;
addLog(LOG_LEVEL_INFO, log);
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par1, log, 0));
}
}
In RTTTL definition is used character "#", but it must be encoded in URL, so I use "-".
void play_rtttl(uint8_t _pin, char *p )
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
and two if statements:
if (command == F("rtttl"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 16)
{
pinMode(event->Par1, OUTPUT);
char sng[1024] ="";
string.replace("-","#");
string.toCharArray(sng, 1024);
play_rtttl(event->Par1, sng);
setPinState(PLUGIN_ID_001, event->Par1, PIN_MODE_OUTPUT, event->Par2);
log = String(F("SW : ")) + string;
addLog(LOG_LEVEL_INFO, log);
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par1, log, 0));
}
}
if (command == F("tone"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 16)
{
pinMode(event->Par1, OUTPUT);
tone(event->Par1, event->Par2, event->Par3);
setPinState(PLUGIN_ID_001, event->Par1, PIN_MODE_OUTPUT, event->Par2);
log = String(F("SW : ")) + string;
addLog(LOG_LEVEL_INFO, log);
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par1, log, 0));
}
}
In RTTTL definition is used character "#", but it must be encoded in URL, so I use "-".
- Attachments
-
- _P001_Switch.rar
- (3.51 KiB) Downloaded 423 times
Re: Speaker function ?
I needed a wireless doorbell. The first version was with the UM66, but it meant only one meody ...
Re: Speaker function ?
wonderful addition.
hi dev,
are you listening here?
can it go into the main development branch?
(or someone good in coding make a plugin? moelski? )
hi dev,
are you listening here?
can it go into the main development branch?
(or someone good in coding make a plugin? moelski? )
Re: Speaker function ?
tozett wrote:wonderful addition.
hi dev,
are you listening here?
can it go into the main development branch?
(or someone good in coding make a plugin? moelski? )
Yes, it can. No problem.
Re: Speaker function ?
Hi tozett !
But this is more an Actor and not a Sensor ...
But anyway ... Making a stand alone "tone" plugin should be straight forward ...
Working on my Candle Plugincan it go into the main development branch?
(or someone good in coding make a plugin? moelski? )
But this is more an Actor and not a Sensor ...
But anyway ... Making a stand alone "tone" plugin should be straight forward ...
regards
Dominik
Dominik
Re: Speaker function ?
Great idea,
I wanted to test,
thank.
sorry I do not speak English!
I wanted to test,
it does not compile._P001_Switch.rar
Code: Select all
296 log = String(F("SW : GPIO ")) + String(event->Par1) + String(F(" Set PWM to ")) + String(webreq);
exit status 1
'webreq' was not declared in this scope
sorry I do not speak English!
sorry for my English ! i use google translat.
Re: Speaker function ?
Oh, sorry!rol-rider wrote:Great idea,
I wanted to test,it does not compile._P001_Switch.rar
thank.Code: Select all
296 log = String(F("SW : GPIO ")) + String(event->Par1) + String(F(" Set PWM to ")) + String(webreq); exit status 1 'webreq' was not declared in this scope
sorry I do not speak English!
I sent older version
This is the correct.
- Attachments
-
- _P001_Switch.rar
- (3.5 KiB) Downloaded 451 times
Re: Speaker function ?
Thanks,
I still managed to use "tone"
in rules:
French police siren
but "rtttl" ???
I test the new file.
I still managed to use "tone"
in rules:
Code: Select all
On BP#BP do
tone,14,435,600
tone,14,580,600
tone,14,435,600
tone,14,580,600
tone,14,435,600
tone,14,580,600
tone,14,435,600
tone,14,580,600
endon
but "rtttl" ???
I test the new file.
sorry for my English ! i use google translat.
Re: Speaker function ?
rol-rider,
you have to replace "#" with "-" or urlencode string.
you have to replace "#" with "-" or urlencode string.
Re: Speaker function ?
Great ! it works !
this is the ":" I forgot!
beautiful melody
this is the ":" I forgot!
Code: Select all
http://192.168.0.3/control?cmd=rtttl,14:d=8,o=5,b=180,c6,b,c6,p,g,g-,p,f,b,c6,p,d6,p,g,p,c6,b,c6,p,d6,p,f,g,g-,4p,g,f,4d-
sorry for my English ! i use google translat.
Re: Speaker function ?
Correct syntax is : rtttl, pin,name_of_melody:duration,octave,beat,notes..........rol-rider wrote:Great ! it works !
this is the ":" I forgot!
beautiful melodyCode: Select all
http://192.168.0.3/control?cmd=rtttl,14:d=8,o=5,b=180,c6,b,c6,p,g,g-,p,f,b,c6,p,d6,p,g,p,c6,b,c6,p,d6,p,f,g,g-,4p,g,f,4d-
Somewhere use ":" after beat, somewhere ","... I didnt try ":", maybe work, maybe not.
https://en.wikipedia.org/wiki/Ring_Tone ... r_Language
Re: Speaker function ?
ok, thank you for the clarification.
sorry for my English ! i use google translat.
Re: Speaker function ?
hope this doku finds it way to the wiki ...
Re: Speaker function ?
I needed speaker support myself to build an Alarm system for my home. Needed the alarm to give audio feedback. (e.g. alarm enable/disable tones, window-open notification sounds etc)
I cleaned up the code (identation), and moved the functions to Misc.ino
Its avaiable in v1.1.0-beta7 in the testing plugin-set.
Edwin
I cleaned up the code (identation), and moved the functions to Misc.ino
Its avaiable in v1.1.0-beta7 in the testing plugin-set.
Edwin
Re: Speaker function ?
I have uploaded version dev6
https://github.com/letscontrolit/ESPEasy/releases
It is written in the description
https://github.com/letscontrolit/ESPEasy/releases
It is written in the description
I get the messageImplemented speaker and tone functions from https://www.letscontrolit.com/forum/vie ... r&start=10
Unknown or restricted command!
Re: Speaker function ?
Its in the testing plugin set. So you need the test or dev firmware version.
I just updated the wiki: https://www.letscontrolit.com/wiki/index.php/GPIO
I just updated the wiki: https://www.letscontrolit.com/wiki/index.php/GPIO
Re: Speaker function ?
After being exchanged plugin _P001_Switch forum
https://www.letscontrolit.com/forum/vie ... ?f=4&t=343
melodies work
It seems that in the dev version 6 is a mistake
https://www.letscontrolit.com/forum/vie ... ?f=4&t=343
melodies work
It seems that in the dev version 6 is a mistake
Re: Speaker function ?
uuuhh ...what do you mean?kniazio wrote: ↑14 Mar 2017, 07:00 After being exchanged plugin _P001_Switch forum
https://www.letscontrolit.com/forum/vie ... ?f=4&t=343
melodies work
It seems that in the dev version 6 is a mistake
Re: Speaker function ?
I mean that with version dev6 wrote melodies that have been added.psy0rz wrote: ↑14 Mar 2017, 10:34uuuhh ...what do you mean?kniazio wrote: ↑14 Mar 2017, 07:00 After being exchanged plugin _P001_Switch forum
https://www.letscontrolit.com/forum/vie ... ?f=4&t=343
melodies work
It seems that in the dev version 6 is a mistake
These tunes do not work
I see that RTTTL code is added to the plugin misc.ino but it did not work.
I swapped the old plugin _P001_Switch.ino and melodies work
I did it according to the description of the forum
https://www.letscontrolit.com/forum/vie ... ?f=4&t=343
post 7
Re: Speaker function ?
After sending the command:
I get the answer:
In contrast, using a modified plugin _P001_Switch.ino
After sending the command:
I get the answer:
Code: Select all
http://192.168.0.3/control?cmd=rtttl,14:d=8,o=5,b=180,c6,b,c6,p,g,g-,p,f,b,c6,p,d6,p,g,p,c6,b,c6,p,d6,p,f,g,g-,4p,g,f,4d-
Code: Select all
Unknown or restricted command!
After sending the command:
Code: Select all
http://192.168.0.3/control?cmd=rtttl,14:d=8,o=5,b=180,c6,b,c6,p,g,g-,p,f,b,c6,p,d6,p,g,p,c6,b,c6,p,d6,p,f,g,g-,4p,g,f,4d-
Code: Select all
{
"log": "rtttl,14:d=8,o=5,b=180,c6",
"plugin": 1,
"pin": 14,
"mode": "output",
"state": 0
}
Re: Speaker function ?
You have to use the correct binary.
If you have 4096Mb flash use: ESPEasy_v2.0.0-dev6_dev_4096.bin
If you have 1024MB flash use: ESPEasy_v2.0.0-dev6_dev_1024.bin
Notice the _dev_ at the end, that means: All the plugins that are in testing and development state.
If you have 4096Mb flash use: ESPEasy_v2.0.0-dev6_dev_4096.bin
If you have 1024MB flash use: ESPEasy_v2.0.0-dev6_dev_1024.bin
Notice the _dev_ at the end, that means: All the plugins that are in testing and development state.
Re: Speaker function ?
I do not use ready .bin file alone compile
In the previous post I explained to guess exactly what's going on
Re: Speaker function ?
I still have to adjust the tutorials for that.
If you compile it now, it will not comile the TEST and DEV plugins.
if you add this to ESPEasy.ino it will work, without the other adjustments you made:
#define PLUGIN_BUILD_DEV
#define PLUGIN_BUILD_TESTING
If you compile it now, it will not comile the TEST and DEV plugins.
if you add this to ESPEasy.ino it will work, without the other adjustments you made:
#define PLUGIN_BUILD_DEV
#define PLUGIN_BUILD_TESTING
Re: Speaker function ?
I do not understand what you mean.
I believe that in the file Misc.ino is an error, and therefore tunes do not work.
Why work with a file _P001_Switch.ino?
I believe that in the file Misc.ino is an error, and therefore tunes do not work.
Why work with a file _P001_Switch.ino?
- Attachments
-
- _P001_Switch_z melodyjkami.rar
- (3.5 KiB) Downloaded 367 times
Re: Speaker function ?
I fixed the tutorial and source code.
Use v2.0.0-dev7 , follow this tutorial: https://www.letscontrolit.com/wiki/inde ... are_Upload
make sure you enable the testing plugin set. (in espeasy.ino)
Edwin
Use v2.0.0-dev7 , follow this tutorial: https://www.letscontrolit.com/wiki/inde ... are_Upload
make sure you enable the testing plugin set. (in espeasy.ino)
Edwin
Re: Speaker function ?
Unknown or restricted command!
Who is online
Users browsing this forum: No registered users and 3 guests