M5Stack PoESP32 with i2c devices not detected

Hi, I have recently picked up one of these excellent little units to try and monitor temperatures reliably around my solar inverter and batteries which are located in my loft, so the PoE device is ideal for always being available (I wanted to avoid anything which needs battery replacement due to access).

I have managed to get a basic configuration loaded onto the device by following other helpful posts (thank you to anyone who contributed to this post…)

However now I have enabled the i2c configuration in esphome I seem to be hitting a bit of a blocker and I really have no idea why…

[07:39:05][C][i2c.arduino:071]: I2C Bus:
[07:39:05][C][i2c.arduino:072]:   SDA Pin: GPIO21
[07:39:05][C][i2c.arduino:073]:   SCL Pin: GPIO22
[07:39:05][C][i2c.arduino:074]:   Frequency: 50000 Hz
[07:39:05][C][i2c.arduino:086]:   Recovery: bus successfully recovered
[07:39:05][I][i2c.arduino:096]: Results from i2c bus scan:
[07:39:05][I][i2c.arduino:098]: Found no i2c devices!

The logs show the i2c has loaded fine, but the bus scan does not pick up any devices. So far I have tried:
ENVIV Unit connected directly, but I also have a Ph.Hub v1.1 (because eventually I want to have 6 ENVIV sensors connected) and nothing seems to work.

I would really appreciate any pointers or assistance anyone can provide.

How did you manage to connect the sensor to GPIO21 / 22

I have the following in my device config file:


i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true
  id: bus_a

I was expecting to see the address of any detected device appear in the logs so I would then know what sensor configuration to apply (Reference)

I’ll be honest I assumed the GPIO numbers would be those two, and given the log entries assumed they were right - do you think I have the wrong ones?

Assumed?
What about observing? I expect M5 devices have printed pinout on the device.
At least all I have seen do…
Feel free to post an image if you need help.


This is the back of the case, but the port numbers listed don’t seem to align to the details on the schematic, but also neither mention the i2c bus

Which schematic do you mean?
If ESPHome or ESP32 general, then these are not really relevant.
You need to use the actual pins available/connected.
And in case of PoESP32 these are 16 and 17 (as shown on picture).

This works for me, so I suspect would also work for you:

i2c:
  sda: 16
  scl: 17

It tells exactly what gpios you have exposed on the connector. 16/17.
Doesn’t leave a lot of room to assume. :wink:
While you can mux Esp32 pins many different ways and different purposes (input/output/analog/serial/I2C,SPI etc.), it still is that GpioX, there’s no way it could become GpioY.

That’s why I asked on post#2 how you connected to 21/22, only with careful soldering on the chip that could be doable.

When I use that configuration I have the same results in the log file… do you see something different?

[15:10:51][C][i2c.arduino:071]: I2C Bus:
[15:10:51][C][i2c.arduino:072]:   SDA Pin: GPIO16
[15:10:51][C][i2c.arduino:073]:   SCL Pin: GPIO17
[15:10:51][C][i2c.arduino:074]:   Frequency: 50000 Hz
[15:10:51][C][i2c.arduino:086]:   Recovery: bus successfully recovered
[15:10:51][I][i2c.arduino:096]: Results from i2c bus scan:
[15:10:51][I][i2c.arduino:098]: Found no i2c devices!

My config entry is:

i2c:
  sda: 16
  scl: 17
  scan: true
  id: bus_a

please ignore the above - I had failed to plug the sensor in properly :man_facepalming:

I am now seeing:

[15:25:20][I][i2c.arduino:096]: Results from i2c bus scan:
[15:25:20][I][i2c.arduino:102]: Found i2c device at address 0x61

which matches the address of the Pb.HUB unit :slight_smile:

If I connect the ENVIV directly to the PoESP32 then that works perfectly. Looks like I made some assumptions that I could use the Pb.HUB to get multiple sensors connected :frowning:

Unfortunately these things are not that simple. You need to pay attention to details and read carefully what functionality these thing provide.
You could use Grove Hub (U006) to connect more I2C devices to PoESP32.
However, as far as I know ESPHome officially does not support STM32F030, so Pb.Hub cannot be used.

General purpose MCU for multiplexing I2C?

Not sure what the question is, but from link in 1st post: PbHUB Unit is a 6-channel expansion Unit with I2C control. Each Port B interface is capable of GPIO, PWM, Servo control, ADC sampling, RGB light control and other functions. Adopts STM32F030 for internal control.
I did not see any documentation for STM32 on EPSHome page …

The pb.hub does NOT appear to be an i2c expander (in the sense that it would allow connecting multiple i2c devices to the same set of pins) that @DaveIr appears to want.

The pb.hub is an I/O expander that speaks i2c to the controller and increases the number of pins that can do regular I/O including PWM, but not i2c.

You do not need an expander for i2c, since you can have multiple devices share the same 2 pins. You can get the grove hub to make it easy to share the pins with multiple devices and no soldering.

But, since the sensor @DaveIr wants to use already has two i2c sensors Integrated and does not seem to provide a way to change the i2c addresses it likely won’t work either.

i2c is not designed to work over long distances. It is designed for VERY short distances (the distance between two or more integrated circuits on the same circuit board, so typically MUCH less than a meter). People have been successful using i2c at longer distances and there is hardware available to make it work over much longer distances, so it is possible. I generally don’t trust it at over a meter.

So, @DaveIr you might want to start with the real problem you are trying to solve, since it seems your choice of hardware is likely not the best design choice for the real problem you are trying to solve.

For that, I would recommend the DS18B20 (make sure you get real ones) or NTC sensors. The DS18B20 is my go to for temperature, but some people have difficulty with them. This might be due to the majority of them being cheap imitations of the real ones these days.

You really don’t need to know the humidity and/or pressure at your solar panel. If you do, it is going to take more work to get that information. You can use multiple i2c buses and/or this TCA9548A I²C Multiplexer — ESPHome

Because STM32 is MCU like ESP32 or PIC32.
It’s kind of weird to use it as multiplexer but why not, you could use Esp as well…

Thank you for the comprehensive response - you are right I have picked both a bad choice of expander and also a bad choice of sensor.

Part of this was not really understanding the documentation (which I do much better now).

Thanks - They look good, but I really want to get something already in a case so can “plug and play” as I don’t have a 3d printer, and really need everything to be protected to some extent.

If I am reading this right I could theoretically use the Pahub to expand out to multiple i2c devices even if they have the same device address because the expander is supported by esphome?

My other alternateive would be to use the simple hub but I would need to pick different sensors so I can change their individual addresses…

That would be wrong component for I2C multiplexer.
But this Esphome component would probably work with Pahub v2.1:

look up “DS18B20 waterproof” on the Internet and you will find MANY choices.

is the one that many copy

is another one.

Both of these are supposed to have genuine DS18B20 sensors inside. You can get copies which are pretty much guaranteed to have fake sensors and might not have actual epoxy for 1/5 the price. They usually work. If you know what you are doing, they can be an okay choice. If you are just starting out, but at least one real one so you are more likely to experience success.

@Karosm why do you say it woudl be the wrong component? Reading the description on the m5stack site it clearly says “it allows multiple devices with the same or different I2C addresses to coexist on the same I2C bus (switching via channel polling).”

To your recommendation I don’t see how that board would meet my other requirement to be “plug and play” given it’s a bare board, would require me to manufacture both a case, and solder any wiring needed.

Sorry if that seems like a negative response, not really intended that way, but I am trying to learn, but limited in my skills (I cannot solder, and I have no 3d printer) and understanding of electronics.