-
-
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 |
I am embarking on a project in which I need to use H711X
, which is natively supported by esphome but I do not have more pins for it.
I have quite a few sensors connected via I2C and when I saw this component arduino_port_expander
that allows you to expand I/O ports via I2C I thought it would be a very good option.
I had a pro mini lying around the house so I decided to upload the sketch and connect it to the esp32c3.
I currently do not have the H711X
, since I am considering the possibility of using it via I2C, but I have a DHT11
at home and I decided to test if the arduino_port_expander
component allows me to control it.
First I did tests by configuring an output associated with pin 13 of the Arduino and I was able to control the LED from home assistant perfectly.
Once I verified that arduino_port_expander
was working correctly I decided to try the DHT11
. First I had to modify the DHT11
component so that it allowed the arduino_port_expander
pins to be configured and not just the internal ones of the esp32 running esphome. Change InternalGPIOPin
to GPIOPin
in yaml:
arduino_port_expander:
id: ape1 # must identify somehow to later use
i2c_id: tca9548a_ch0
address: 0x08
analog_reference: DEFAULT
sensor:
- platform: dht
pin:
arduino_port_expander: ape1
number: 2
temperature:
name: "Living Room Temperature"
humidity:
name: "Living Room Humidity"
update_interval: 60s
Unfortunately, although it compiles perfectly, on boot it causes bootloop (I imagine due to wdt)
It seems that the sensors where communication is time critical do not work through I/O I2C expanders.
Still, arduino_port_expander
is a cool component.
Thank you!
I forgot to mention here I created a new repo for this. See here
@fran6120 thats a nice story but the end was predicted. If you’re short on pins you can try to use the expander for simple io pins, eg relays switches and save internal gpio for sensors which requiere fast io pins. (And also switching pin mode from input to output quickly)
Hi, do you know about the Problem, that neighborhood Analog Inuts have wrong values.
I want to read some of those Sensors: https://de.aliexpress.com/item/1005004819365767.html
Reading a single Sensor has no problems (eg A0). But if I add a second one to A1, the voltage is much higher as its really is.
I have no really solution.
On some Formthreads, they write, that you have to read the ANalog Pin twice and only use the second result:
https://forum.arduino.cc/t/analog-input-affected-by-its-neighbor/88758
or
https://forum.arduino.cc/t/cross-voltages-from-neighbor-analog-input/178708
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
Do you have a small example for me? I will test it shortly.
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
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 :-)
Hola buen dia. Existe la manera de usar el sensor dht11 conectado en arduino. Soy nuevo en esto y no he encontrado la manera.
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
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
lol ... I see it now, @balazs111 has the same question :-)
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
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
Nice, looks like, that it's working :-)
I can not test binary_sensor, but my 8 Outputs and 6 Analog Inputs are working directly.
My big test example: