Skip to content

Instantly share code, notes, and snippets.

@glmnet
Last active June 29, 2025 14:45
Show Gist options
  • Save glmnet/49ca3d6a9742fc3649f4fbdeaa4cdf5d to your computer and use it in GitHub Desktop.
Save glmnet/49ca3d6a9742fc3649f4fbdeaa4cdf5d to your computer and use it in GitHub Desktop.
// this gist is no longer needed,
// see https://github.com/glmnet/esphome-components/blob/main/docs/arduino_port_extender.md
// for up to date information
// this gist is no longer needed,
// see https://github.com/glmnet/esphome-components/blob/main/docs/arduino_port_extender.md
// for up to date information
@glmnet
Copy link
Author

glmnet commented Feb 21, 2024

That’s interesting. Didn’t know

you can try using update interval: none on the sensor s so you disable automatic polling. Then write an interval script which will call component update on the sensors, eg call it twice in A0 and the pick the value on the second call then call twice A1

@Bjoern3003
Copy link

Do you have a small example for me? I will test it shortly.

@glmnet
Copy link
Author

glmnet commented Feb 21, 2024

This does disables polling and calls to update explicitly

https://github.com/glmnet/esphome_devices/blob/master/my_home/eh-energia.yaml

You might want to create another template sensor which you’ll set the value you read the second time

@Bjoern3003
Copy link

Bjoern3003 commented Feb 21, 2024

Thank you,

I think I got it.

I added a dummy analogRead() to the arduino Script before the reading for publishing.

Also I found a thread: firmata/arduino#334 (comment)

I also have added a interval Script to my yaml, to read the Analog Sensors in the correct sequence

  - interval: 60s
    then:
      - component.update: analog_input_3_humidity
      - delay: 1s
      - component.update: analog_input_3_voltage
      - delay: 10s
      - component.update: analog_input_4_humidity
      - delay: 1s
      - component.update: analog_input_4_voltage
      - delay: 10s
      - component.update: analog_input_5_humidity
      - delay: 1s
      - component.update: analog_input_5_voltage
      - delay: 10s
      - component.update: analog_input_6_humidity
      - delay: 1s
      - component.update: analog_input_6_voltage
      - delay: 10s
      - component.update: analog_input_1_humidity
      - delay: 1s
      - component.update: analog_input_1_voltage
      - delay: 10s
      - component.update: analog_input_2_humidity
      - delay: 1s
      - component.update: analog_input_2_voltage```

Now I will test it for a couple of Days :-)

@vicio2008
Copy link

Hola buen dia. Existe la manera de usar el sensor dht11 conectado en arduino. Soy nuevo en esto y no he encontrado la manera.

@balazs111
Copy link

Hello i am trying to use Arduino Port Expander in my home project where reliability is really important .

As a test, temporary I braked the i2c line between the port expander and the esp device. I got a following error immediately (which is good) :

[E][component:112]: Component was marked as failed.
And never recovered (that is not good).

I wonder how can this made more robust? eg. after the transient is gone should recover by them self.

Thank you

@TheAbhor
Copy link

Hello everyone,

I have a little dumb question, I have it all working (the first version was working for me here),
but .... if the i2c bus hangs for some reason, I know the command to reset the ESP8266 ---> "- platform: restart",
but not the NANO (in my case) ... (so the i2c bus won't reset), is there a easy way to reset the NANO too in that same command ?

GreetingZzz

@TheAbhor
Copy link

lol ... I see it now, @balazs111 has the same question :-)

@balazs111
Copy link

Hello,

here is the solution: https://community.home-assistant.io/t/arduino-port-expander-i2c-connection-not-recover-after-failure/745984
In the end decided to use modbus because i needed to breach a longer distance what i2c was not able to handle

@vitucciog
Copy link

vitucciog commented Mar 29, 2025

Hi @glmnet,
any chance you make a version for Arduino Mega 2560?
I've been using a modified version from @thebradleysanders in the last years, but with the migration from custom to external components I've lost the possibility to update my devices with the latest versions of esphome.

Thanks. Bye,
Vito

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment