Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed config with the ArduinoPortExpander and analog reading #4

Open
davidusb-geek opened this issue Mar 6, 2021 · 0 comments
Open

Comments

@davidusb-geek
Copy link

Hi, nice work on this ArduinoPortExpander. I've been using it with esphome to control mostly relays, digital outputs (to LEDs and buzzers, etc) and for some binary sensors. I'm using a wemos d1 mini and an Arduino Uno as the APE device.
Now I want to read two power loads in my house using the analog input function and two different current clamps (SCT-013-030). I want to use for this the CT Clamp current sensor from esphome (https://esphome.io/components/sensor/ct_clamp.html). The problem is that analog sensor output from the APE is not a voltage. So either using the ct_clamp or the analog to digital (https://esphome.io/components/sensor/adc.html) sensor integrations gives a failed configuration error.

Here is my yaml configuration for this implementation:

esphome:
  name: main_tableau_elec
  platform: ESP8266
  board: d1_mini
  includes:
    - arduino_port_expander.h

wifi:
  ssid: !secret wifi_id
  password: !secret wifi_pwd

logger:
  level: DEBUG

api:
  password: !secret ota_pwd

ota:
  password: !secret ota_pwd

i2c:
  id: i2c_component

custom_component:
  - id: ape
    lambda: |-
      auto ape_component = new ArduinoPortExpander(i2c_component, 0x08, true);
      return {ape_component};

sensor:
  - platform: custom
    lambda: |-
      return {ape_analog_input(ape, 0),  // 0 = A0
              ape_analog_input(ape, 1)};  // 1 = A1
    sensors:
      - name: Analog A1
        id: analog_a1
        filters:
          - throttle: 10s
      - name: Analog A2
        id: analog_a2
        filters:
          - throttle: 10s
  - platform: adc
    pin: analog_a1
    name: ADC1
    update_interval: 60s
  - platform: adc
    pin: analog_a2
    name: ADC2
    update_interval: 60s

And the error message obtained is this:

Failed config

sensor.adc: [source main_tableau_elec.yaml:61]
  platform: adc
  
  Cannot resolve pin name 'analog_a1' for board d1_mini.
  pin: analog_a1 [source main_tableau_elec.yaml:62]
  name: ADC1
  update_interval: 60s
sensor.adc: [source main_tableau_elec.yaml:65]
  platform: adc
  
  Cannot resolve pin name 'analog_a2' for board d1_mini.
  pin: analog_a2 [source main_tableau_elec.yaml:66]
  name: ADC2
  update_interval: 60s

The same error arises if I try to use the ct_clamp integration. Do you think that there is a way to achieve some compatibility with the ct_clamp or the adc esphome integrations? Could you help me to solve this issue?
A secondary solution for me is to connect a ADS1115 directly to my wemos d1 mini ESP8266, but then it will be a shame to not use those analog pins in the Arduino Uno APE.
Thank you for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant