esphome / feature-requests

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

Add support for Shelly Plus Addon #2034

Open raidr1 opened 1 year ago

raidr1 commented 1 year ago

Describe the problem you have/What new integration you would like

Add support for Shelly Plus Addon

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

it would be nice to integrate with all Shelly Plus devices

Additional context

nagyrobi commented 1 year ago

The addon is just a galvanic isolated adapter for GPIO pins. It's transparent to ESPHome.

DHowett commented 1 year ago

I don’t believe it’s a simple passthrough. It connects to the serial/debug header on the Plus devices and expands the host device with support for 1-Wire, one additional ADC and one additional GPIO. Those aren’t exposed via that header.

In addition, Shelly documents the addon as using a …

Shelly proprietary serial interface to connect to a Shelly Plus device source

jtricerolph commented 1 year ago

I opened mine up and the pins trace through to seperate pins on the isolator chip, I'm pretty sure it's not using uart based on the chip model number. The first chip in addon from pins is a NSi8120 which is just optoissolator. I tried tracing put the tiny tracks and components and as far as I could tell it did indeed seem to just passthough. I mean the tx and rx pins on esp presumeably are also gpio if repourposed. My conserne on simplicity was with the old addon you still need a custom component to use the 1wire probes which included an additional pin definition. Perhaps enable? As pretty sure addon needs enabling and reboot in stock firmware I beleive.

DHowett commented 1 year ago

Thanks for tracing these out! That makes sense. Yeah, RX0/TX0 can be re-muxed to be I/O, and then we have IO19 and IO0 on the pin header. Good call.

I'm interested in the extra analog input. None of those four pins seem (according to the datasheet; I don't know if they do in practice) to support ADC... 🤷🏻

jtricerolph commented 1 year ago

Thanks for tracing these out! That makes sense. Yeah, RX0/TX0 can be re-muxed to be I/O, and then we have IO19 and IO0 on the pin header. Good call.

I'm interested in the extra analog input. None of those four pins seem (according to the datasheet; I don't know if they do in practice) to support ADC... 🤷🏻

Don't quote me on the above tracing but the following 😅 But one I put that I think is the analoge trace goes through a seperate chip labeled 3PEAK 393a BQLh and although can't find an exact match on Google maybe it's doing some pre processing for that?

jowgn commented 1 year ago

0CF3BC53-1468-4A15-A742-52045F2A8AF8 5F66C44A-66F3-4552-949A-E2C755C303D9 6944DD18-D6B2-432A-A344-1ECA459CBBC8 82947CAB-0ECB-4161-A0E0-192E71057F1D 0E139053-EBFA-4AAC-9191-E0CF10464CB7 2DE34DD5-E433-4D7B-8C60-3F1D16235760 The biggest ic is a small transformer (https://www.lcsc.com/product-detail/Power-Transformer_VPSC-VPT87BB-01B_C2846914.html). Additional Infos may be sourced here: https://github.com/mongoose-os-apps/shelly-homekit/issues/1146

OldSilvaRanga commented 1 year ago

Any movement on the use of the Addon within ESPHome? Would be a great addition to the existing shelly gear.

pdw-mb commented 1 year ago

But one I put that I think is the analoge trace goes through a seperate chip labeled 3PEAK 393a BQLh and although can't find an exact match on Google maybe it's doing some pre processing for that?

It's this one - LM393A datasheet

andypnz commented 1 year ago

Is there any possibility of using the addon with ESPHome? Thanks you!

pdw-mb commented 1 year ago

I've spent some time figuring out how the ADC works on this. It actually appears as the duty cycle on the RX pin (GPIO3). This config appears to read it correctly:

sensor:
  - platform: duty_cycle
    pin: 3
    name: Duty Cycle Sensor
    update_interval: 5s

The board is generating a sawtooth input to one pin of the comparator, with the analog input on the other, giving a digital output with duty cycle representing the analog input. I don't fully understand the circuit, as it appears that the frequency and amplitude of the signal vary according to the resistors.

I think the other pins are: GPIO19 - digital input, GPIO0 1-wire TX, GPIO1 1-wire RX. I've not tried, but I think that https://github.com/esphome/esphome/pull/1346 would allow you to use the DS18B20 sensors with it, if you set pin: 1, pin_a: 0. It looks like the PR needs some work to sort out some compilation issues.

ashp8i commented 1 year ago

I have the dht working https://github.com/ashp8i/esphome-configs/tree/main/my_external_components/test4/shelly_dht

using the following config: -

sensor:
  - platform: shelly_dht
    pin: GPIO1
    pin_a: GPIO0
    temperature:
      name: "Living Room Temperature"
    humidity:
      name: "Living Room Humidity"
    update_interval: 60s

I need to find a way how to leave the original component alone but add ifdef or new methods for the shelly that uses two pins, same goes for the dallas, my plan for the dallas side is to add support for 1-Wire via RMT peripheral (ESP32's) and make the bitbanging more robust for the ESP8266, and support Switch and I2C bridge, sorry not high-jacking thread, trying to give this some direction.

amzaldua commented 9 months ago

Is it possible to integrate a CT sensor with the Shelly 1 Plus using the add-on module? Currently, my Shelly Plus 1PM, connected to my boiler, is experiencing issues with overheating. Could using a Shelly Plus 1 with a dry contact potentially resolve this problem?

yasapl commented 8 months ago

I've spent some time figuring out how the ADC works on this. It actually appears as the duty cycle on the RX pin (GPIO3). This config appears to read it correctly:

sensor:
  - platform: duty_cycle
    pin: 3
    name: Duty Cycle Sensor
    update_interval: 5s

The board is generating a sawtooth input to one pin of the comparator, with the analog input on the other, giving a digital output with duty cycle representing the analog input. I don't fully understand the circuit, as it appears that the frequency and amplitude of the signal vary according to the resistors.

I think the other pins are: GPIO19 - digital input, GPIO0 1-wire TX, GPIO1 1-wire RX. I've not tried, but I think that esphome/esphome#1346 would allow you to use the DS18B20 sensors with it, if you set pin: 1, pin_a: 0. It looks like the PR needs some work to sort out some compilation issues.

Hi, would you be able to suggest a configuration for an NTC resistor to use it as a temperature sensor (underfloor heating, 10Kohm at 25deg C)? Seems that the original shelly fw does support it so the hardware should be OK. I know I could use dallas sensor but the ntc is already buried in the floor.

Thank you in advance! Yasa

pdw-mb commented 8 months ago

Hi, would you be able to suggest a configuration for an NTC resistor to use it as a temperature sensor (underfloor heating, 10Kohm at 25deg C)? Seems that the original shelly fw does support it so the hardware should be OK. I know I could use dallas sensor but the ntc is already buried in the floor.

This is actually exactly what I use my Shelly add-ons for :smiley:

  - platform: ntc
    sensor: resistance_sensor
    calibration:
      - 11.4kOhm -> 26.6°C
      - 13.17kOhm -> 24°C
      - 16.17kOhm -> 18.8°C
    name: Floor Temperature
    id: floor_temperature

  - platform: resistance
    id: resistance_sensor
    sensor: add_on_adc
    configuration: DOWNSTREAM
    resistor: 10kOhm
    name: Resistance Sensor

  - platform: duty_cycle
    pin: 3
    id: add_on_adc
    name: "Add-on ADC"
    update_interval: 5s
    unit_of_measurement: "V"
    filters:
      - offset: -2.0
      - multiply: 0.033

The calibration was based on measuring the existing NTC and taking readings from the existing floor controller.

I can't remember how I arrived at the offset value for the duty cycle filter. The 0.033 is to transfer 100% duty to 3.3V.

yasapl commented 8 months ago

Thank you @pdw-mb. I will definitely try in once my add-on arrives.

larsskogshusabf commented 8 months ago

Me too. My Addon arrives on Friday.

KaufDirEins commented 5 months ago

Any news on using dallas ? My addon arrived today. And i cant get it to work

JKoss2 commented 3 months ago

Does anyone think it would be possible to run a PWM signal on GPIO19 of the add-on? Perhaps in combination with a DHT22 (since that uses GPIO1 according to this comment )? The PWM signal would be to adjust the speed of a fan. I know its possible to control a PWM fan in ESPHome, but I am unsure if the galvanic isolation of the add-on would affect the signal.

Edit (11Jul2024): After testing that the PWM signal correctly controls a fan via the 7 pin female header on the back of a Shelly Plus 1PM, I've concluded that the galvanic isolation in the Shelly Plus Add-On prevents the PWM signal from passing through to the add-on terminals.

m1k3f15h commented 1 month ago

Hy @KaufDirEins

Any news on using dallas ? My addon arrived today. And i cant get it to work

Did you already get them to work?

Mike