esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
416 stars 26 forks source link

Adafruit I2C Stemma QT Rotary Encoder/Quad Rotary Encoder Breakout #2519

Open lboue opened 10 months ago

lboue commented 10 months ago

Adding support for Adafruit I2C Stemma QT Rotary Encoder Breakout

Adding support for Adafruit I2C Stemma QT Rotary Encoder Breakout (4991).

Please describe your use case for this integration and alternatives you've tried:

Additional context

The onboard microcontroller is programmed with our seesaw firmware and will track all pulses and pins for you and then save the incremental value for querying at any time over I2C.

Picture

4991-09

ssieb commented 10 months ago

If it's running seesaw, you could try my seesaw component: https://github.com/ssieb/custom_components/tree/master/components/seesaw You will need to set the i2c address.

lboue commented 9 months ago

If it's running seesaw, you could try my seesaw component: https://github.com/ssieb/custom_components/tree/master/components/seesaw You will need to set the i2c address.

Thank you. I'll try to adapt it to my needs.

ssieb commented 9 months ago

I was thinking it would work right away. You can find me on discord if you need help using it.

lboue commented 9 months ago

I was thinking it would work right away. You can find me on discord if you need help using it.

Thanks. For the encoder module, the I2C address is 0x36 but for yours: https://github.com/ssieb/custom_components/blob/master/components/seesaw/__init__.py#L31 ).extend(i2c.i2c_device_schema(0x49))

Was it for this module Adafruit ATSAMD09 Breakout with seesaw?

ssieb commented 9 months ago

You really should ask about this on discord. For any i2c device, you specify the address using address: 0x36. Put that on the top-level seesaw: component. That's why I said you would need to set it. Don't continue this here.

lboue commented 9 months ago

The problem I'm facing is that the seesaw component only supports a single encoder, whereas it is possible to have a chain of 8 encoders. So it can't work also with Adafruit I2C Quad Rotary Encoder Breakout with NeoPixel.

Using the three on-board address jumpers, you can connect up to 8 of these rotary encoders to a single I2C port. The first will be at address 0x36, the last at 0x3D when all three jumpers are soldered.

Would it be possible to have this type of configuration instead?

seesaw:

sensor:
  - platform: seesaw
    id: encoder0
    type: encoder
    number: 0
    name: "first encoder"
    address: 0x36

  - platform: seesaw
    id: encoder
    type: encoder
    number: 1
    name: "second encoder"
    address: 0x37

  - platform: seesaw
    id: encoder7
    type: encoder
    number: 7
    name: "last encoder"
    address: 0x3D
lboue commented 6 months ago

Here is a test config for Adafruit I2C Quad Rotary Encoder Breakout with NeoPixel - STEMMA QT / Qwiic, Product ID: 5752 :

These are the pin names in the seesaw firmware for each rotary encoder:

Encoder #0
  Switch: pin 12
  Encoder A: pin 8
  Encoder B: pin 9
Encoder #1
  Switch: pin 14
  Encoder A: pin 10
  Encoder B: pin 11
Encoder #2
  Switch: pin 17
  Encoder A: pin 2
  Encoder B: pin 3
Encoder #3
  Switch: pin 9
  Encoder A: pin 4
  Encoder B: pin 5

Config without pins

external_components:
  - source:
      type: git
      url: https://github.com/ssieb/custom_components
    components: [ seesaw ]

seesaw:
  address: 0x49
  # The default I2C address is 0x49. Using the three onboard address jumpers, you can connect up to 8 of these encoders on a single I2C port. The first one will be at address 0x49, the last one at 0x51 when all three jumpers are cut open.
  # https://learn.adafruit.com/adafruit-i2c-quad-rotary-encoder-breakout

sensor:
  - platform: seesaw
    id: encoder0
    type: encoder
    name: "Seesaw encoder #0"

  - platform: seesaw
    id: encoder1
    type: encoder
    name: "Seesaw encoder #1"

  - platform: seesaw
    id: encoder2
    type: encoder
    name: "Seesaw encoder #2"

  - platform: seesaw
    id: encoder3
    type: encoder
    name: "Seesaw encoder #3"

binary_sensor:
  - platform: seesaw
    id: button0
    name: "Seesaw encoder button #0"

  - platform: seesaw
    id: button1
    name: "Seesaw encoder button #1"

  - platform: seesaw
    id: button2
    name: "Seesaw encoder button #2"

  - platform: seesaw
    id: button3
    name: "Seesaw encoder button #3"

light:
  - platform: seesaw
    id: pixel0
    name: "Seesaw neopixel LED#0"

  - platform: seesaw
    id: pixel1
    name: "Seesaw neopixel LED#1"

  - platform: seesaw
    id: pixel2
    name: "Seesaw neopixel LED#2"

  - platform: seesaw
    id: pixel3
    name: "Seesaw neopixel LED#3"

I created this error : [pin] is an invalid option for [binary_sensor.seesaw] #72 to try and find out how to correct it.