generate pulse by mqtt
Moderators: grovkillen, Stuntteam, TD-er
generate pulse by mqtt
Hello,
First of all thanks to everyone for help.
i have a wemos D1 mini device with EspEasy firmware.
Now i want to send a pulse about 5000 ms by mqtt, but i dunno how to do it. I know that by http is posible with this instruction:
http://[IP_device]/control?cmd=pulse,0,0,5000
That for 5 seconds GPIO 0 turn on (i send 0 because a have a relay that works with inverse logic) in logs of esp, only i saw this:
GPIO 0 Pulsed for 5000 mS
Anyone knows how to translate and send this instruction by mqtt?
thanks
First of all thanks to everyone for help.
i have a wemos D1 mini device with EspEasy firmware.
Now i want to send a pulse about 5000 ms by mqtt, but i dunno how to do it. I know that by http is posible with this instruction:
http://[IP_device]/control?cmd=pulse,0,0,5000
That for 5 seconds GPIO 0 turn on (i send 0 because a have a relay that works with inverse logic) in logs of esp, only i saw this:
GPIO 0 Pulsed for 5000 mS
Anyone knows how to translate and send this instruction by mqtt?
thanks
Re: generate pulse by mqtt
May use rules for Timer? Look rules up on the Wiki ...?!
Re: generate pulse by mqtt
You can send the entire command as payload to ../cmd topic.
So if your template is
/%sysname%/#
and your system name is
espdemo
you should send payload
pulse,0,0,5000
to topic
/espdemo/cmd
So if your template is
/%sysname%/#
and your system name is
espdemo
you should send payload
pulse,0,0,5000
to topic
/espdemo/cmd
Re: generate pulse by mqtt
coool, should go into wiki ...


Re: generate pulse by mqtt
Hello to everyone,
Thanks for help.
Sorry tozett, but wiki have many pages, so maybe you can attach the rules for timer where it says this? because i don't see it. I red wiki about EasyESP and i didn't find this page.
Martinus, thanks for help, i did it and worked perfect. If you know where is link of wiki where explain this, i think i will be happy and tozett too:).
thanks to every one.
Thanks for help.
Sorry tozett, but wiki have many pages, so maybe you can attach the rules for timer where it says this? because i don't see it. I red wiki about EasyESP and i didn't find this page.
Martinus, thanks for help, i did it and worked perfect. If you know where is link of wiki where explain this, i think i will be happy and tozett too:).
thanks to every one.
Re: generate pulse by mqtt
timer are mentioned/explained in the RULES-section here:
http://www.esp8266.nu/index.php/Tutorial_Rules#Timer
does this help?
http://www.esp8266.nu/index.php/Tutorial_Rules#Timer
does this help?
Re: generate pulse by mqtt
Hi tozett,
Perfect with this link.
Really, in the wiki is too difficult to find this link, because in main page, table content doesn't appear, and in other sub-pages also i didn't find it.
I read about rules and maybe it's good for about one thing that i want to use it.
Please do you know if in wiki exist a link, about "device page" : http://www.esp8266.nu/index.php/ESPEasy, more extensive?, because i created a counter in my device, and i wanted to share this variable or value to mqtt.
Other thing, and thanks to your link, maybe is doing a rule for this.
thanks
Perfect with this link.
Really, in the wiki is too difficult to find this link, because in main page, table content doesn't appear, and in other sub-pages also i didn't find it.
I read about rules and maybe it's good for about one thing that i want to use it.
Please do you know if in wiki exist a link, about "device page" : http://www.esp8266.nu/index.php/ESPEasy, more extensive?, because i created a counter in my device, and i wanted to share this variable or value to mqtt.
Other thing, and thanks to your link, maybe is doing a rule for this.
thanks
Re: generate pulse by mqtt
did not fully understand what variable you have, and where,
but you can send values to mqtt with rules.
use cmd: "Publish" fully explained here:
http://www.esp8266.nu/index.php/Tutoria ... nd_Publish
i do this too, its working..
but you can send values to mqtt with rules.
use cmd: "Publish" fully explained here:
http://www.esp8266.nu/index.php/Tutoria ... nd_Publish
i do this too, its working..

Re: generate pulse by mqtt
Hi tozett,
I was reading Rules#Timer on wiki, and about part of publish i have a doubt/problem and as you can see in wiki this part is not completed.
Well i follow the example at the end of chapter Rules#Timer where explain to create a rule for a led that after 10 sec led is switched on, etc. This works well.
A part of this, i create in menu device a counter, that says how many times led is switched on Inside task 1 in device menu, you can see 2 values or variables (Count, Total) Well, by rules, i want to publish these 2 values or variables to mqtt. As i told you, i follow wiki, but doesn't work as i want. By rules, i would like to publish by rules this:
/nodemcu/prueba/Count, (content_of variable_Count) and
/nodemcu/prueba/Total, (content_of variable_Total)
But i dunno, how to obtain the content of variable Total. So i try to do it by constant like:
Publish /%sysname%/%tskname%/%valname2%,5 But when i see topic in mqtt, i see this: so not correspond with /nodemcu/prueba/Total payload:
do you know where i mistake please?
really thinks about your help
I was reading Rules#Timer on wiki, and about part of publish i have a doubt/problem and as you can see in wiki this part is not completed.
Well i follow the example at the end of chapter Rules#Timer where explain to create a rule for a led that after 10 sec led is switched on, etc. This works well.
A part of this, i create in menu device a counter, that says how many times led is switched on Inside task 1 in device menu, you can see 2 values or variables (Count, Total) Well, by rules, i want to publish these 2 values or variables to mqtt. As i told you, i follow wiki, but doesn't work as i want. By rules, i would like to publish by rules this:
/nodemcu/prueba/Count, (content_of variable_Count) and
/nodemcu/prueba/Total, (content_of variable_Total)
But i dunno, how to obtain the content of variable Total. So i try to do it by constant like:
Publish /%sysname%/%tskname%/%valname2%,5 But when i see topic in mqtt, i see this: so not correspond with /nodemcu/prueba/Total payload:
do you know where i mistake please?
really thinks about your help
Re: generate pulse by mqtt
after a very quick look at your post, my (working) example of a mqtt-publish:
so in your case, i think you should publish (with leading slash! or without!) something like:
what looks like (as one publish-task for each, maybe?):
may give this a try? (besides that: what is your (interesting) idea to generate a pulse and count it. what is your need?)
Code: Select all
// ** MQTT use additional topic for node-red **
publish ESP/01/Haustuer/Key/[rfid#tag]
Code: Select all
publish /YOURTOPICTEXT/[PAYLOAD-is-DEVICEname-and#VALUEname]
Code: Select all
/nodemcu/[prueba#Count]
Code: Select all
/nodemcu/[prueba#Total]
Re: generate pulse by mqtt
Hi tozett,
I tried this as you told me and didn't work with variable Count or Total. in mqtt i received value 0.00 The idea to generate a pulse counter of a GPIO concretely is because i want to control 1 rollershutter at home by 1 relay. The rollershutter only have 1 wire to control the UP and the DOWN.
When i give 220V to this wire, then rollershutter move to one side, if i take it from 220V, then stop, if i give again 220V, then turn to other side.
So the idea is to count how many time i switch on this GPIO, and then about even or odd number (counter) know which is the state of rollershutter if UP or Down, to then generate the oposite.
Do you understand me?
thanks
I tried this as you told me and didn't work with variable Count or Total. in mqtt i received value 0.00 The idea to generate a pulse counter of a GPIO concretely is because i want to control 1 rollershutter at home by 1 relay. The rollershutter only have 1 wire to control the UP and the DOWN.
When i give 220V to this wire, then rollershutter move to one side, if i take it from 220V, then stop, if i give again 220V, then turn to other side.
So the idea is to count how many time i switch on this GPIO, and then about even or odd number (counter) know which is the state of rollershutter if UP or Down, to then generate the oposite.
Do you understand me?
thanks
Re: generate pulse by mqtt
ok, thanks for explanation.
your rules look like you have a space in your topic before your [event#variable] statement..
you might check this..
how do you subscribe your topic? may try some other mqtt-client to test?
and may subscribe to "/topic/#" (general example, i.e. for you: "/nodemcu/#" ) and see for debugging what is all coming in as payload?
your rules look like you have a space in your topic before your [event#variable] statement..
you might check this..
how do you subscribe your topic? may try some other mqtt-client to test?
and may subscribe to "/topic/#" (general example, i.e. for you: "/nodemcu/#" ) and see for debugging what is all coming in as payload?
Re: generate pulse by mqtt
Hi,
thanks again really.
I use a software called mqtt-spy to subscribe to topic in PC and see payload. Always i subscribe to /nodemcu/#, just that i not send you this part in attached files Yes, i need to see serial logs in nodemcu. Today i want try it.how do you subscribe your topic? may try some other mqtt-client to test?
and may subscribe to "/topic/#" (general example, i.e. for you: "/nodemcu/#" ) and see for debugging what is all coming in as payload?
Hi, i was reading how to compile files and hope today or tomorrow try to compile R113 and upload it. Maybe, before i will try with R112, because now i have installed R110.Please check r113, possible Bug?
thanks again really.
Re: generate pulse by mqtt
i tried to re-build you setting on my device. never played pulsecounter before..
1) still on version r111...
i hat count and total at the same value. the error was, to left out the idx-value.
in your screenshot it is the same.
please give the idx-field a value and check,
if count and total now behave like expected.

1) still on version r111...
i hat count and total at the same value. the error was, to left out the idx-value.
in your screenshot it is the same.
please give the idx-field a value and check,
if count and total now behave like expected.
Re: generate pulse by mqtt
Hi tozett,
but didn't worked, because i didn't know how to send by mqtt variable "cont".
Tonight i saw your reply, and i modify my device configuration adding IDX number as you said, and worked!
So thank you very much for all your help!
Just one doubt about code that i attached if in rule i create a variable like:
There is any way to send this variable (cont) by mqtt? i was reading few websites and didn't say anything to send the content of variable by mqtt...
Well, i will continue reading if i find something, and really thanks very much!
well sorry for delay, but i was doing some test with R113 and create a rule like this:1) still on version r111...
i hat count and total at the same value. the error was, to left out the idx-value.
in your screenshot it is the same.
please give the idx-field a value and check,
if count and total now behave like expected.
Code: Select all
On System#Boot do
gpio,2,0
timerSet,1,10
cont=0
endon
On Rules#Timer=1 do
if [E1SW1#Switch]=1
gpio,2,0
else
gpio,2,1
cont=cont+1
endif
Tonight i saw your reply, and i modify my device configuration adding IDX number as you said, and worked!
So thank you very much for all your help!
Just one doubt about code that i attached if in rule i create a variable like:
Code: Select all
On System#Boot do
gpio,2,0
timerSet,1,10
cont=0
endon
On Rules#Timer=1 do
if [E1SW1#Switch]=1
gpio,2,0
else
gpio,2,1
cont=cont+1
endif
Well, i will continue reading if i find something, and really thanks very much!
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 13 guests