M5 atomS3 lite with i2c hub PaHub 2, m5 relay, kmeteriso, and ext.io gpio extender peripherals in esphome

—Solved: see below yaml code block for esphome----

Is there support for a PCA9548APW m5 hub (pahub2)?

I am trying to update the econet esphome yaml in the esphome add-on in HA. I have a RS485 atomS3 connected i2c to the hub. The hub has (3) m5 4-relay connected i2c and also has (1) PCA9554PW gpio expander (unit-ext.io), and (1) MAX31855 sensor (kmeteriso). I want to be able to connect them together locally so that I can control each relay as on or off depending on information in the econet HA dashboard, the sensor is for outdoor ambient temperate measurement so I just want that to be able to be displayed in the dashboard, and the gpio expander is to sense when a separate system is signaling for changes so my system knows how to respond. Everything I search online is completely fragmented information and nothing is directly relatable or any examples of where to start. If there are no platform support for these units, what do I need to do to get them in there so I can make this possible?

also secondary follow up, these units are defined in UIflow, is it possible to build in UIflow and somehow add that to the esphome econet base install?

I tried using the yaml configuration in esphome support pages as the tca i2c multiplexer. Unfortunately that configuration returns with need platform information, although the yaml config example did not have one. Further research hints that the esphome team finds that the unit is not working and they have not further developed solutions.

I know that the i2c address of the hub is 0x70, the relays would be 0x26, and the sensor would be 0x66. I just do not know how to configure the yaml in esphome, because apparently I do not know what I am doing at all.

1 Like

To operate them independently, you need to change each of their addresses to something unique in your setup.

(Not all devices support this)

Alternatively, they must reside on separate I2C universes

I don’t know where to start. I cannot find anything because every single resource either has no reference whatsoever or such a narrow incredibly specific reference that it doesn’t apply to anything else other than that one project. There has to be some resource that has a list of platforms or basic code of where to start from.

This example of full of extras that might confuse.

relay.write(1,1)

Turns it on

relay.write(1,0)

Turns it off

I’m not sure how you’d change the address to get three working.

I do have a paHub but I’ve got no idea how to work with it.

Or if this more along the lines of what you’re looking for / doing ?


Is it worth trying this script to change the I2C address of each relay module?

1 Like

It is technically a multiplexer so it should be able to operate using multiplexer channels to set an address as a new bus id with the multiplexer address created. ESPhome has this under the TCA9548 multiplexer section but I tried to enter that into my config and apparently it was removed. I found it was removed in a random post, not on the actual ESPhome site.

However there is a post in the thread that you sent regarding m5 relays that someone already built as an external component (both the PCA hub and the m5 relays). If I can get it working that way, I will update here and maybe it will be of some help for people to see.

I have figured this out and now have a working relay system using a multiplexer hub

substitutions:
  name: econet-hpwh-2
  friendly_name: Hot Water
packages:
  esphome-econet.esphome-econet: github://esphome-econet/esphome-econet/build-yaml/econet-hpwh-esp32s3.yaml@main
esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}
external_components:
  - source: github://nielsnl68/esphome-components
i2c:
  - sda: GPIO2
    scl: GPIO1
    scan: True
    id: i2c0

tca9548a:
  - address: 0x70
    id: multiplex0
    i2c_id: i2c0
    channels:
      - bus_id: multiplex0channel0
        channel: 0
      - bus_id: multiplex0channel1
        channel: 1
      - bus_id: multiplex0channel2
        channel: 2
      - bus_id: multiplex0channel3
        channel: 3
      - bus_id: multiplex0channel4
        channel: 4
      - bus_id: multiplex0channel5
        channel: 5
pca9554:
  - address: 0x27
    id: 'pca9554a_device'
    i2c_id: multiplex0channel3

switch:
  - platform: m5stack4relay
    i2c_id: multiplex0channel0
    address: 0x26
    sync_mode: true
    id: Relay_1
    relay1: relay 1
    led1:
      name: led 1
      assumed_state: true
      id: led_1
  - platform: m5stack4relay
    i2c_id: multiplex0channel0
    address: 0x26
    sync_mode: true
    id: Relay_2
    relay2: relay 2
    led2:
      name: led 2
      assumed_state: true
      id: led_2
  - platform: m5stack4relay
    i2c_id: multiplex0channel0
    address: 0x26
    sync_mode: true
    id: Relay_3
    relay3: relay 3
    led3:
      name: led 3
      assumed_state: true
      id: led_3
  - platform: m5stack4relay
    i2c_id: multiplex0channel0
    address: 0x26
    sync_mode: true
    id: Relay_4
    relay4: relay 4
    led4:
      name: led 4
      assumed_state: true
      id: led_4
  - platform: m5stack4relay
    i2c_id: multiplex0channel1
    address: 0x26
    sync_mode: true
    id: Relay_5
    relay1: relay 5
    led1:
      name: led 5
      assumed_state: true
      id: led_5
  - platform: m5stack4relay
    i2c_id: multiplex0channel1
    address: 0x26
    sync_mode: true
    id: Relay_6
    relay2: relay 6
    led2:
      name: led 6
      assumed_state: true
      id: led_6
  - platform: m5stack4relay
    i2c_id: multiplex0channel1
    address: 0x26
    sync_mode: true
    id: Relay_7
    relay3: relay 7
    led3:
      name: led 7
      assumed_state: true
      id: led_7
  - platform: m5stack4relay
    i2c_id: multiplex0channel1
    address: 0x26
    sync_mode: true
    id: Relay_8
    relay4: relay 8
    led4:
      name: led 8
      assumed_state: true
      id: led_8
  - platform: m5stack4relay
    i2c_id: multiplex0channel2
    address: 0x26
    sync_mode: true
    id: Relay_9
    relay1: relay 9
    led1:
      name: led 9
      assumed_state: true
      id: led_9
  - platform: m5stack4relay
    i2c_id: multiplex0channel2
    address: 0x26
    sync_mode: true
    id: Relay_10
    relay2: relay 10
    led2:
      name: led 10
      assumed_state: true
      id: led_10
  - platform: m5stack4relay
    i2c_id: multiplex0channel2
    address: 0x26
    sync_mode: true
    id: Relay_11
    relay3: relay 11
    led3:
      name: led 11
      assumed_state: true
      id: led_11
  - platform: m5stack4relay
    i2c_id: multiplex0channel2
    address: 0x26
    sync_mode: true
    id: Relay_12
    relay4: relay 12
    led4:
      name: led 12
      assumed_state: true
      id: led_12
  - platform: gpio
    name: "Pin0"
    pin:
      pca9554: pca9554a_device
      number: 0
      mode:
        input: true
      inverted: false
  - platform: gpio
    name: "Pin1"
    pin:
      pca9554: pca9554a_device
      number: 1
      mode:
        input: true
      inverted: false
  - platform: gpio
    name: "Pin2"
    pin:
      pca9554: pca9554a_device
      number: 2
      mode:
        input: true
      inverted: false
  - platform: gpio
    name: "Pin3"
    pin:
      pca9554: pca9554a_device
      number: 3
      mode:
        input: true
      inverted: false
  - platform: gpio
    name: "Pin4"
    pin:
      pca9554: pca9554a_device
      number: 4
      mode:
        input: true
      inverted: false
  - platform: gpio
    name: "Pin5"
    pin:
      pca9554: pca9554a_device
      number: 5
      mode:
        input: true
      inverted: false
  - platform: gpio
    name: "Pin6"
    pin:
      pca9554: pca9554a_device
      number: 6
      mode:
        input: true
      inverted: false
  - platform: gpio
    name: "Pin7"
    pin:
      pca9554: pca9554a_device
      number: 7
      mode:
        input: true
      inverted: false
sensor:
- platform: kmeteriso
  address: 0x66
  i2c_id: multiplex0channel4
  temperature:
    name: Kmeter Temperature
  internal_temperature:
    name: Outdoor temperature
api:
  encryption:
1 Like

This esp device is an M5atomS3lite with a RS485 base. The RS485 connects to an RJ adapter on a hot water tank. The econet package allows the ESP to read/write diagnostic information. With this information I needed to be able to turn circulators, sensors, and valves on and off using 120v 10a relays. In order to use the Econet system with what was purchased as the base I needed to expand the i2c port.

m5 stack also sells the PaHub2 which uses the PCA9548ap chip, which functions similarly to the tca9548 multiplexer which is already integrated into ESPhome. I attached (3) 4-channel relays to the PaHub2 into channels 0-2.

I also purchased an 8 pin GPIO extender known as ext.io sold through m5. This uses the PCA9554 chip which is integrated into ESPhome.

I also purchased a kmeteriso sensor to sense outdoor temperature.

Once this config was flashed to the atomS3lite using the yaml config above I waited for esphome in home assistant to connect (device showing as online in the dashboard) and reviewed logs. It took roughly 1 minute and was warned that components were temporarily blocked for 30ms. I then went back to the dashboard and refreshed and all of my new entities were there. The “led” entities did not work but it didn’t matter because I didn’t need them as turning relay on and off automatically turned the LEDs on and off to determine which relay was working.

kudos to ESPhome-ECOnet team for the coding for HVAC diagnostics, kudos to nielsnl68 in github for the build of m5 relay external components, and kudos to the ESPhome team for the build of TCA9548 and PCA9554 chipsets. A big kudos to @MDAR for providing a random link to a forum that had a reference to the github repository for m5 relay. Without this post, I would never have found that repository as it doesn’t seem like it has had much traffic. While I didn’t have to specifically code anything other than a yaml configuration, it did take a ton of time and research to figure out the exact verbiage needed to get all of these devices talking to each other. In order for the components to integrate, they have specific IDs in the coding. Once that was found it was trial and error until I could get all of the platforms to communicate with one another since they all needed their own specific reference, any changes in syntax and this config would not work for me.

So my final question is this. If the packages are from online github resources, does this device need constantly connect to those resources or is that only to retrieve for install and after install it no longer needs to link to that site? If it does need to constantly connect to those resources, how can I make it so that it is only installed locally on the device? I want to make this setup as locally controlled as possible to reduce any fluctuations in runtime due to poor signal or external internet outages.

1 Like

Now if people are curious about why all of this??

I plan on redesigning my HVAC and DHW (domestic hot water) system in my house. I previously designed a radiant flooring system using a hot water boiler that heated the flooring with a mixing valve and directly heated an air handler with a damper zone valve controller. I was told numerous times that it was not practical and would not be sufficient for heating. After install it was the most comfortable climate controlled space I have ever been in and it cut our LP (liquid propane) demand from 1800gallons per year down to 1000 gallons per year, almost half.

I plan on rebuilding our house and want to shift as much as possible to electric as we live in a prime area for grid-tie PV solar system. So the plan is to have two 90 gallon rheem hybrid electric/heat pump water tanks. One tank will be for heat and the other for hot water. The tanks will be set at a high temp with a mixing valve tempered for use to cut down on the amount of water that has to be drawn from the tank (hotter reservoir so it takes less water when in demand). The heat tank will be closed loop with water/polyethylene glycol mix and piped through the floor slab. The hot water tank will be for potable water and will be open. The tanks will joined by a heat exchanger (so it can exchange heat but no contamination). There will also be additional heat exchangers between each tank and an outdoor wood boiler. Additional heat exchangers to the whole system for hot tub and/or pool.

The whole plan for Home Assistant and these ESPhome devices would be to independently control circulators and zone valves to open and close based on tank temps so that they can assist each other via heat exchangers when the demand exceeds the capability. This reduces loss of temp in pipe but also helps cut down on run cycles of each tank. If the tank is too high, the heat exchanger can also pull heat from that tank to reduce pressure, particularly for the outdoor wood boiler.

1 Like

Hi

Thanks for the comment.

It was purely a random search that found that link.

I’m really happy it helped for you.

You’ll be glad to hear that the repository is never accessed by the ESP / Arduino / ESPhome code. (Unless you specifically tell it)

It doesn’t even know what the internet is :smile:

1 Like