Can i connect a Grove (non-M5stack) rotary encoder to m5core2 with battery bottom2?



  • Hello,
    I want to have a rotary knob in my project. Can i use this?
    I cant use the M5stack encoder as i already use the only I2C Port (Port A) for a Dlight unit.

    Thanks
    Aaron



  • Hello @AEisele55

    I tried to compile the libraries source code (Encoder / TimerOne) of that rotary knob for ESP32 and it fails with lib/TimerOne/TimerOne.h:39:10: fatal error: avr/io.h: No such file or directory. I think the reason is that the source code is meant for Arduino AVR boards which are different from ESP32 boards. While you might be able to physically connect this rotary knob to an M5Core2 you need to be prepared to adapt the library to work with ESP32 on your own.

    That said, are you aware that I2C is a bus system which allows multiple devices to be connected in parallel? The two devices can be controlled by the M5Core2 using their respective I2C address: Encoder: 0x40; Dlight: 0x23. You'll need a hub like this one.

    Thanks
    Felix



  • @felmue: i think this rotary encoder works like any "normal" one. AFAIK, it doesn't use I2C but a kind of "If turned one step right, first pin A high, the Pin B high, then both Low".
    My concerns were that i heard somewhere about the m5stack not being 5V-tolerant (that means if you put 5v on an input pin, it destroys the pin forever)
    Is it physically safe to connect it?
    I already thought of some code how to read it , which just uses the "dual button" unit in UIflow and compares the RTC times the A high or B high.

    Thanks

    Aaron



  • Hello @AEisele55

    most M5Stack devices (including M5Core2) use the ESP32 and yes, the GPIOs of the ESP32 are not 5 V tolerant. I am sorry for not thinking of that. So if the outputs of the rotary encoder are 5 V you would need to add some kind of level shifters.

    Note: the power supply on the Groove port is 5 V, but the two GPIOs are only 3.3 V.

    Thanks
    Felix



  • @felmue: Thanks for your help