Post your best Lua script examples here

User avatar
By jmccoy555
#23087 Hi,

Have I lost the plot here......

I'm trying to get the button code to work and have managed to get it to publish a message when the button is pressed, which is great........ but then it stops!

If I press the button again notthing happens, no error, no crash, no publish, even if i wait a while.

Any idea??

Thanks.


****** EDIT ******

Sussed it, a pull up is needed to bring the pin up again after it has been pulled down by pressing the switch.

Well that works anyway, would be good to know if that's the correct way of doing it.

Thanks again.
User avatar
By rutierut
#23418
jmccoy555 wrote:Hi,

Have I lost the plot here......

I'm trying to get the button code to work and have managed to get it to publish a message when the button is pressed, which is great........ but then it stops!

If I press the button again notthing happens, no error, no crash, no publish, even if i wait a while.

Any idea??

Thanks.


****** EDIT ******

Sussed it, a pull up is needed to bring the pin up again after it has been pulled down by pressing the switch.

Well that works anyway, would be good to know if that's the correct way of doing it.

Thanks again.


Hey,

Sorry for my long absence but that is indeed how to code is designed, thanks for updating your question with a solution? If you read this, do you happen to know what version of NodeMCU you are running?

Tnx
User avatar
By rutierut
#23419
bubnikv wrote:Dear Rutierut,

I am in a need for a remote tuning knob for a software defined radio running on the other side of the house. I would like to transmit the state of the rotary encoder with low latency over WiFi.

Would you please elaborate on why the immediate reporting of the rotary encoder state is not stable? Does the WiFi processing block the reading of the rotary encoder state? If so, would it then help to let an external low cost controller handle the rotary encoder and let the Lua script poll the external low cost controller for the state of the rotary encoder?

Thanks, Vojtech


The problems is that the esp tries to send too many MQTT messages at a time, the poor esp just needs a little break in between :D. Though if someone would design another script from scratch implementing a system where a maximum messages per second are send this would be possible.