Hi everyone,
I’m trying to configure a rotary encoder as a dimmer for PWM LEDs. When testing on a protoboard everything was just fine, but when moving to the actual LEDs and encoders in a room, it fails.
In the “real world” condition, when I turn the encoder, the clockwise/counterclockwise logs seem random, no matter how I turn the encoder pin. I did test the same encoders with the protoboard setting and they work fine.
I’m guessing this might be an issue with the wiring (noise). I used about 7 m of unshielded CAT6 cable to connect the encoders in the room to the ESP32 in the attic. Switches using the same cable/controllers work fine; line integrity is OK, measured using a cable tester.
As I’m using on_clockwise / on_anticlockwise to dim the lights, using a filter does not affect the result, so debounce is useless.
It’s either noise or the distance or both really. How are you placing components in your configuration? For example, is the esp and encoder together and then your trying to control a light 7m away? Are the encoders and esp 7m away from each other? You should be able to send the encoder signals further if you step the voltage up but the pwm signals for the mosfet are a different story, those need to be fairly close or you need to likewise use a higher voltage which would require another mosfet
I started to do something similar but got distracted with my outside lighting. This is how i was doing the same thing. I found it better than using the dim_relative function and it allows you to send 0-255 values from elsewhere to adjust the lights. I prefer to have a way to control things in the event HA goes down or the hardware HA is on goes down. This way you could send number values via REST or MQTT. If you use multiple boards, it’s 100% doable but it will not be the same way.