Support i2c new device PCF8591

Hello.
Is it possible to integrate this PCF8591 component into esphome using i2c custom component?

I’ve never done this before and it doesn’t look like official esphome support will be available anytime soon.
See: https://github.com/esphome/feature-requests/issues/2175

well thank you

Yes, it’s (likely) possible.

There is already a pretty similar multiplexer supported, so you probably use it as a template

it will be more like this: https://github.com/esphome/esphome/tree/dev/esphome/components/ads1115

A library from adfriut could be used.
https://github.com/adafruit/Adafruit_PCF8591

of course I can’t write it well. I can’t program.

Mmm… Ok. Why are asking about custom component, then?
Are you trying to make someone else do it for you?

Yes.
Or help create it.

Is this a paid job or are you trying to make someone else do it for you for free?
It surely would be interesting to know for those reading this post.

Please? after all, we are on a forum where we are discussing smart home and esphome.
Everything is open source.
I don’t want to force anyone, I’m just asking for help.
If there is someone who has a similar problem and knows how to program, he will definitely be happy to help. If it’s not here, nothing happens.

I don’t know if it’s appropriate to force someone to do something

Ok, so that will be unpaid. Thanks for confirmation.

It’s just that after an ESPHome feature request, a bump, then this post, you seemed very eager to have this device supported, so you might have considered actually paying someone to do it rather than asking again and again hoping someone will do it for free :smiling_imp:

If I see that someone needs help and I know how to help, I will write the entire procedure. (unfortunately, I’m not proficient in English and I’m more active on the Slovak-Czech forum). Therefore, I consider the request for help to be free. I didn’t even think of writing a post here that I would pay someone to help me. There are other forums for that.

While there is no official solution made temporary for myself. You may need:
File /config/esphome/pcf8591.h

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

#define TIME_INTERVAL 1000


#define PCF8591 (0x90 >> 1)
byte value0, value1, value2, value3;

class CustomPCF8591 : public PollingComponent {
 public:


  Sensor *adc0= new Sensor();
  Sensor *adc1 = new Sensor();
  Sensor *adc2 = new Sensor();
  Sensor *adc3 = new Sensor();

  CustomPCF8591() : PollingComponent(TIME_INTERVAL) { }

  void setup() override {
    Wire.begin();
  }

  void update() override {
 Wire.beginTransmission(PCF8591); // пробуждаем PCF8591
 Wire.write(0x04); // управляющий байт - чтение ADC0, затем автоинкремент
 Wire.endTransmission(); // конец передачи
 Wire.requestFrom(PCF8591, 5);
 value0=Wire.read(); 
 value0=Wire.read(); 
 adc0->publish_state(value0);
 value1=Wire.read();
 adc1->publish_state(value1);
 value2=Wire.read(); 
 adc2->publish_state(value2);
 value3=Wire.read();
 adc3->publish_state(value3);
  }
};
esphome:
  libraries:
    - "Wire"
  includes:
    - pcf8591.h

sensor:
  - platform: custom
    lambda: |-
      auto CustomPCF = new CustomPCF8591();
      App.register_component(CustomPCF);
      return {CustomPCF->adc0 ,CustomPCF->adc1, CustomPCF->adc2, CustomPCF->adc3};
    sensors:
      - name: "My Custom adc0 Sensor"
      - name: "My Custom adc1 Sensor"
      - name: "My Custom adc2 Sensor"
      - name: "My Custom adc3 Sensor"

There may be inaccuracies. I did it quickly for myself … Keep this in mind!

Yes Yes.
This is exactly what I needed, those outputs can already be calibrated to the required output as I need. WELL THANK YOU.

Even if I already use the ads1115 sensor in my project, it will be used in the next one :slight_smile:

Here is a link for some data and a wiring diagram. https://www.best-microcontroller-projects.com/pcf8591.html

It will be interesting to try to program the DAC for the output. Then this sensor will really be useful :slight_smile:

Did you manage to get it to work ? Because I can’t :smiling_face_with_tear:

yes, it is enough to do what Whakru wrote