As the title says... Chat on...

User avatar
By sbma44
#70877 I've got two rotary encoders wired to a Wemos D1 mini, but only the one attached to rotary channel 0 works. If I swap assignments so that the pins associated with the first rotary encoder go to channel 1 and the second rotary encoder goes to channel 0, then the second rotary encoder is the only one that works. This is demonstrated in the commented-out lines below. I can only get one of the two encoders working, but either will work if it is the one that gets assigned to channel 0. This makes me think that my hardware setup is not the problem.

Code: Select allfunction rotary_status(type, pos, when)
    print("0 / Position=" .. pos .. " event type=" .. type .. " time=" .. when)
end

function rotary_setup()
    --rotary.setup(0, 5, 6, 3)
    --rotary.setup(1, 1, 2, 7)
    rotary.setup(0, 1, 2, 7)
    rotary.setup(1, 5, 6, 3)

    rotary.on(0, rotary.ALL, rotary_status)
    rotary.on(1, rotary.ALL, rotary_status)

    print("# rotary setup complete")
end


I'm hesitant to assume a bug in the module, but I'm having a hard time seeing what else could be going on. I've tried using the dev branch, flashing with integer vs float, changing the order in which I call setup() and on() -- no dice.

Has anyone else run into this? I'm also seeing some unstable system behavior, but am chalking that up to static discharge reaching the RST pin (for now).
User avatar
By rudy
#71074
philbowles wrote:What language is that code? What do you mean by "channel" ? Where does rotary(... etc come from - a library?

I have a fair amount of experience with encoders and Wemos D1, but I'm a C++ chap...If I could see the docs on those functions, I might be able to suggest something


The forum is Lua NodeMCU.com/Random Lua Chat so one should assume that the language is Lua.

https://nodemcu.readthedocs.io/en/maste ... es/rotary/