Trying to get I2C device data from a remote Raspberry Pi to HA

Apologies in advance if I didn’t tag/format things properly, not used to this forum style.

I have HA running supervised on a laptop using Debian 12. Not 100% sure it’s a fully supported install, but I think that’s a separate problem… the idea was that I’d be able to run other stuff on the laptop, but that hasn’t materialized so at some point I may revert to HA OS. But that’s neither here nor there.

Anyhow, in my garage I have a Raspberry Pi 4 running Raspbian. Currently all it’s doing is monitoring a UPS for some network gear via NUT, and that’s being picked up by HA perfectly. I’d like to expand that capability to use the GPIO for various tasks, one of which is to monitor the temperature and humidity in the garage.

So a while back I went and bought a DHT20 sensor (this one here: Humidity and Temperature Sensor - DHT20 - SEN-18364 - SparkFun Electronics). Plugged it in to the RPI and never got around to integrating it. It seems to talk to the Pi, but that’s all the further I’ve got. Haven’t had a chance to really dig in and try to get the data from it.

I’ve done some searching and seen the recommendations to use remote_RPI_GPIO. However this seems to only support binary_sensor and switch types. I can’t see that there’s any way to successfully get I2C data from this interface.

Seems to me that this needs to be a three step process: first I need to process the I2C data somehow on the RPI and make it available somewhere. Step 2 would be to use a 3rd party service to grab and publish that data somehow, and then step 3 would be to have HA use an intergration for that 3rd party service to grab that data.

And that’s where I’m completely lost… all 3 steps, frankly. Honestly I’m pretty inexperienced when it comes to Linux stuff, so a lot of this is opaque to me. I can stumble through individual guides and make things work, but I don’t even know where to start here.

So with all that, right now it’s looking like:

  1. Write a python or C/C++ script/program that runs periodically (how?) to acquire and process/scale the sensor data to real world units, then store that data <somewhere??>
  2. Use some 3rd party thing to publish the data (MQTT? no idea here)
  3. Use whatever HA integration supports the above 3rd party thing.

Step 3 seems to be the easiest here, once I figure out the rest that is. For step 1 I can find plenty of guides on how to get and process the sensor data, but I don’t know how to store it somewhere that would be accessible to whatever is used in step 2.

The other thing I’ve noticed is a lot of suggestions revolve around using ESP32 chips. I’d like to avoid this because I just don’t want extra hardware and I don’t want to add more devices to my network. Maybe I’m being irrational and stubborn, but it seems to me that I already have the RPI, so I feel like this should be fairly straight forward.

tl;dr: I have a DHT20 temp/humidity sensor that talks via I2C. It’s connected a remote Raspberry Pi via the GPIO, and I need to get this data over to a separate computer running HA as a sensor. Trying to figure out the best strategy to do so that doesn’t require additional hardware.

When you have a spare $2 get yourself a esp8266 (e.g. D1 mini) connect your DHT20, install esphome and call it a day :wave:

Yeahhhh not what I wanted to hear. And I mean that in a “this is my problem” way, not that you’re wrong for posting this!

Is there really no easy solution? I guess I’m kind of surprised that this is so difficult. For all the tutorials I see about pulling data from various sources, seems like there should be a straight forward way to do this.

Follow-up: am I going to piss off my RPI if I power an ESP from the GPIO power supply? I see some that have USB supplies, but others that don’t and I already have a bread board with the GPIO wedge and the DHT20 sensor sitting on it.

The easy solution was already posted and includes a esp/pico together with esphome :wink:

The “problem” with your RPI it’s just a total overkill (4 cores, 1GB RAM). It’s running a full fledged OS and so many things can go wrong and even if you manage to setup everything you like updates can break the functionalists or a broken sd card can reset your mileage.

Best way to get such sensors into HA is with a minimal setup that doesn’t break like a $2 D1 mini as suggested.

Probably not. But depends totally how capable your PSU is and what other peripherals you are running on your RPI.

Yeah it’s very overkill… I repurposed it after I had HA running on it and killed a 2nd SD card. Had an old laptop lying around, so I migrated because I was tired of fiddling with SD cards.

Also planning on running a display from it, which is part of why I want the sensor data for that area. So I have it pulling local UPS data, and soon to be running a display with a HA screen, so I figured that the built-in GPIO would be the “easiest” way to display local temp/humidity data.

Basically I’m trying to get by with the equipment I have, rather than buying a bunch of new stuff.

OK cool. I wasn’t sure if this was a “power is for RPI GPIO only” sort of thing, or if it was more or less a paralleled feed off the incoming USB power. I suppose I ought to look at the spec sheet!