tiimsvk
(Tiimsvk)
May 17, 2023, 5:15am
1
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
koying
(Chris B)
May 17, 2023, 7:41am
2
Yes, it’s (likely) possible.
There is already a pretty similar multiplexer supported, so you probably use it as a template
dev/esphome/components/tca9548a
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems. - esphome/esphome/components/tca9548a at dev ...
tiimsvk
(Tiimsvk)
May 17, 2023, 7:52am
3
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.
koying
(Chris B)
May 17, 2023, 7:56am
4
tiimsvk:
I can’t program
Mmm… Ok. Why are asking about custom component, then?
Are you trying to make someone else do it for you?
koying
(Chris B)
May 17, 2023, 8:06am
6
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.
tiimsvk
(Tiimsvk)
May 17, 2023, 8:11am
7
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
koying
(Chris B)
May 17, 2023, 8:23am
8
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
tiimsvk
(Tiimsvk)
May 17, 2023, 8:31am
9
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.
whakru
(Whakru)
May 20, 2023, 7:51pm
10
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!
tiimsvk
(Tiimsvk)
May 22, 2023, 9:29am
11
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
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
Did you manage to get it to work ? Because I can’t
tiimsvk
(Tiimsvk)
January 18, 2024, 5:34am
13
yes, it is enough to do what Whakru wrote