esphome / feature-requests

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

Add support for Adafruit_DS3502 #1216

Open paracetamol32 opened 3 years ago

paracetamol32 commented 3 years ago

Describe the problem you have/What new integration you would like Add support for the Adafruit DS3502 I2C Potentiometer library ,Thank you for your excelent job with ESPHome.

Please describe your use case for this integration and alternatives you've tried: Use the DS3502 I2C Potentiometer to control Viridian EV EPC (cf: http://evbitz.uk/EVSE_Kit_-_Type_2_files/EPC%20Manual%20V1.2_050816.pdf ). Viridian use a variable resistor to control output power for charging electic car

Additional context

spec here : https://github.com/adafruit/Adafruit_DS3502

boozeman commented 2 years ago

Any progress for this?

DS3502 is handy sensor for voltage controlled EC-fans (0-10v with 10K pot)

pascaltippelt commented 2 years ago

I would also really appreciate an DS3502 integration.

lordratner commented 1 year ago

Adding my name to the list of people wanting support for this. Thanks for everything you do!

inspectorgrowadmin commented 1 year ago

Also would like this integrated

inspectorgrowadmin commented 1 year ago

+1

gryzli133 commented 1 year ago

very useful component to control 0-10V. By now I use it with mysensors and arduino for my 0-10V Fans, look forward to move to esphome as soon as it will be supported 👍

Lou-Menz commented 1 year ago

Yes, please add this.

I need to control a whole house filter fan by a variable resistance through the controller board.

PWM directly to fan motor won't work.

Thanks

lordratner commented 1 year ago

Yes, please add this.

I need to control a whole house filter fan by a variable resistance through the controller board.

PWM directly to fan motor won't work.

Thanks

very useful component to control 0-10V. By now I use it with mysensors and arduino for my 0-10V Fans, look forward to move to esphome as soon as it will be supported 👍

Just a heads up, I have this working on ESPHome with this: https://community.home-assistant.io/t/issues-running-two-custom-i2c-components-adafruit-ds3502/478025

It's quite simple to adapt to your needs, until there is native support.

Lou-Menz commented 1 year ago

Thank you lordratner!

UserRS232 commented 1 year ago

@lordratner Thanks, i have trouble getting them work. Can you please write a short guide on how to do this? I'm fairly new to the ESPHome universe

lordratner commented 1 year ago

Put his file, DS3502.h in /config/esphome

#include "esphome.h"
#include <Adafruit_DS3502.h>

#define WIPER_VALUE_PIN A0

class DS3502_Component : public Component, public FloatOutput
{
public:

    int I2C_Address;
    Adafruit_DS3502 ds3502;

    DS3502_Component(int address = DS3502_I2CADDR_DEFAULT) {
        I2C_Address = address;
        ds3502 = Adafruit_DS3502();
        ESP_LOGI("custom", "Initializing <%i>", I2C_Address);
    }

    void setup() override {
        if (!ds3502.begin(I2C_Address))
        {
            ESP_LOGI("custom", "<0x%X> Couldn't find DS3502 chip", I2C_Address);
            while (1);
        }
        ESP_LOGI("custom", "<0x%X> Found DS3502 chip", I2C_Address);
    }

    void write_state(float state) override {
        int mappedState = map(int(state*100), 0, 100, 0, 127);
        ESP_LOGI("custom", "Setting wiper of <%i> to <%i>", I2C_Address, mappedState);
        ds3502.setWiper(mappedState);
        int wiperValue = ds3502.getWiper();
        ESP_LOGI("custom", "--> Wiper value of <%i> is now <%i>", I2C_Address, wiperValue);
    }
};

In your device yaml, you need to call the include:

esphome:
  name: ${device_name}
  friendly_name: Your Friendly Name
  libraries:
    - "Arduino"
    - "Wire"
    - "SPI"
    - "Adafruit BusIO"
    - "Adafruit DS3502"
  includes:
    - DS3502.h

an i2c block:

i2c:
  sda: D4
  scl: D3
  scan: false

An output:

  - platform: custom
    type: float
    lambda: |-
      auto digipot = new DS3502_Component(0x28);
      App.register_component(digipot);
      return {digipot};
    outputs:
      - id: dc_fan_output

### Only needed for climate devices
  - platform: template
    id: fan_control
    type: float
    write_action:
      - fan.turn_on:
          id: datacenter_fan
          speed: !lambda return state * 100;
###

and a fan:

fan:
 - platform: speed
   id: datacenter_fan
   output: dc_fan_output
   name: Fan

Note that I have two outputs. The first is needed in a normal config, and will give you a speed fan in Home Assistant. The second is for if you plan to use the fan as a cooler in a climate system, such as a PID, since it can only control an output component, and not a fan device. So the second output device accepts the control input from the PID and send the value to the fan device with write action

Additionally, if you want you fan to have a permanent minimum speed so it is always running, but still with variable speed, change this line in the DS3502.h file:

int mappedState = map(int(state*100), 0, 100, 0, 127);

Change the second '0' to whatever you want your minimum to be (on a scale of 0-127). So if you want the fan to run at 10% when Home Assistant sets it to off/0, then change the second '0' to 13. Consider this an advanced feature, so make sure you know what you're trying to accomplish. If that number is anything other than '0' the fan will never stop.

UserRS232 commented 1 year ago

wow, super quick response. it works!! thank you very much for your great answer

Lou-Menz commented 1 year ago

I'd like to add my THANKS too!

On Thu, Jun 8, 2023, 1:11 PM UserRS232 @.***> wrote:

wow, super quick response. it works!! thank you very much for your great answer

— Reply to this email directly, view it on GitHub https://github.com/esphome/feature-requests/issues/1216#issuecomment-1583273780, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOQ423F4K6NCITDAX66TFZTXKIWWXANCNFSM44PRFXUQ . You are receiving this because you commented.Message ID: @.***>

WarmeBrille commented 1 year ago

Hello everyone,

I am just starting with the whole esp home and breakout board topic and I'm wondering if I still need a D1 Mini or ESP8266 board to run a the digital poti. Or if I can just wire it to the SDA an SCL pins of the pi an connect as it is given here: https://learn.adafruit.com/ds3502-i2c-potentiometer/python-circuitpython

Thanks in advance!

robinostlund commented 8 months ago

@lordratner i just updated my esphome to latest version and it stopped responding, guess it is something with the external library. Have you seen any issues with it lately? :)

lordratner commented 8 months ago

@lordratner i just updated my esphome to latest version and it stopped responding, guess it is something with the external library. Have you seen any issues with it lately? :)

No issue with mine, just updated to the most recent version.

robinostlund commented 7 months ago

@lordratner sorry for late reply, but are you using esp 8266 or esp32? I am using esp32 so wondering if that could be the issue.