Remote Raspberry Pi I2C Sensor

Hey everyone! I am looking to find out if a remote Raspberry Pi I2C sensor integration exists or if someone is attempting to create this? The general concept is that I am looking for a similar integration to remote_rpi_gpio but for I2C.

If this does not exist, I would be looking to develop such integration and would love to get a conversation started with those interested!


Did you ever find a solution to this?

Today, I’ve asked the same question: I’m moving my HA instance off an RPi but have a BME280 sensor connected to it and I’d like to read its values remotely. This is my first hit on Google so I’m leaving a note here in case someone has come across a solution. I’ll keep looking in the meantime and come back here if I find anything.

I’m doing the same thing as @parautenbach and have various sensors, and everyone I’ve asked says just get an ESP and do it that way with ESPHome or something. HA supports remote Pi GPIO as a binary sensor or switch but by the look of it that component isn’t clever enough to pull i2c or numeric sensor values unfortunately.

The ESPHome route works very well in I’d take that route if I had to create something new. In my case, since the PI does other things too, I had HomeBridge on it, so I’ve connected it to HA via that route. Probably overkill for most situations but since I had the setup I did that.

So I am trying to do something very similar. I have a Rpi 4 sitting in a ventilated box on my roof, with a set of SDR’s plugged into it (so the antennas are all close to the SDR’s). It is POE powered, and I have a Cat6 lightning protection system installed to make sure it doesn’t get back in the house. My roof sheathing has a foil backer so it blocks wifi signals from house from reaching the roof.

I would like to have a BM280 sensor plugged into the Pi and report data back into Home assistant for notification in case the temps get out a safe range. I can’t really use an ESPhome device as there is no wifi signal there, and the Pi has the GPIO pins available. It doesn’t run HA (my HA runs as a guest VM in a server down in the basement), so I am not complaining about the general removal of GPIO support on a PI running HA natively, but I thought the remote raspberry pi functionality was supposed to be a replacement for native support. But I can’t see how to get it to read the BME280 sensor.

Any advice for me?

Here are a couple of suggestions that use native RPi, not ESPHome, YMMV, and yes added complexity, and the second idea assumes you can access the bare metal on the HA server. If using a HA OS or Supervised installation, you would have to work that out :
1, Install Node-Red on the RPi, connect the sensor to the I2c bus, you will have to configure the Pi (serial bus) for this. Use node-red-contrib-i2c node to connect to the sensor, and also install `node-red-contrib-homeassistant-websocket (or similar) nodes in Node-red, connect Node-Red to the HA server (use a long lived token for auth). Then you can use Node-Red HA Entity nodes to create sensors directly in HA.
2, Install the sensor on the RPi OS as an I2C device. The sensor output will reside in a file something like /dev/i2c*. You cannot manipulate this file directly, as it is a “special file”, but you could copy the text to another file and read that directly as text. Set up a cron job to copy the file at suitable time intervals, and a cron job on HA Server to remote into the Pi using SSH, copy the file to the HA Machine and then you can manipulate the data and build a template sensor in HA.
I did similar to this for one-wire devices, and it worked, was a while ago, so If you try this let me know how it goes. Good luck

How about using the PI’s onboard CPU temp sensor? Do you need to actually know the ambient temperature? Monitoring that the PI doesn’t get too hot might be a good enough proxy.

Well, it would be nice to have humidity as well since it’s a vented enclosure on the roof. I am going to try and use a aqara zigbee sensor first, since it may see one of the outdoor switches I use for landscape lighting control to act as a repeater.

I would have though this plugin would have had equivalent functionality to the native GPIO support that’s being deprecated, but maybe that will eventually follow. If the zigbee connection is unreliable, I’ll try one of the Kdem recommended approaches.

Hey everyone, chiming in here as I see this thread picked up some speed.

For my use case, I ended up purchasing an ESP32, writing the I2C code with an added step to call the HA API, to supply the wanted values collected from the I2C bus.

This has worked very well for me and I haven’t needed to make any adjustments in almost 2 years.

Hope this helps someone who stumbled upon this post via google searches! Happy Automating!

Would you kindly post/share the code?

I don’t have access to the source code I am using at this moment in time, but linked below is a shell of the relevant WiFi & HA API code, I2C code stripped out. Bits and pieces were grabbed from different open-source implementations.