Just in the middle of moving my Home Assistant from a Pi3 to a Pi4 and it seems i2c isn’t working on the Pi4.
Just tested the same USB stick called CONFIG with the relevant folder and two files (following these steps here on a Pi3, it works fine - i2c enabled on reboot. On a Pi4, it doesn’t do anything.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/smbus/smbus.py", line 81, in open
self._fd = os.open(path, os.O_RDWR, 0)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'
Same situation with me. I was able to enable the i2c bus in HASSIO on all my other Raspberry Pis, but I can not enable it on my Pi4 running hass.io 3.8 - 32bit. I need this to work because I just bought several 4gb RAM Pi 4s and I integrate the mcp23017 i/o expander chips to them. Anyone figure this out yet?
I got I2c working with the BME680 sensor and a Pi4. I did this by editing the files directly from the SD card plugged into a laptop.
Need to add this file: hassos-overlay/etc/modules-load.d/rpi-i2c.conf
Containing only these two lines:
i2c-bcm2708
i2c-dev
Need to edit this file: hassos-boot/config.txt
Uncomment only this one line:
dtparam=i2c_arm=on
On occasion the sensor doesn’t connect on boot, but a restart fixes it.
Thanks for the reply. So I guess this is why we are having a problem, I am using the latest version of Hass.IO, version 3.8, and it does not have a “hassos-boot” partition on the SD card. The only partitions are: hassos-overlay, hassos-data, 268MB Volume, and hassos-kernel. None of which contain a “config.txt” file. Which version of HA are you using when you got this to work?
OK! from your clues, I got it working! I wrote up the procedure:
How to enable i2c on the Pi4 board Running HassOS 3.8 in HASS.IO
Issue: the “import from USB” procedure to enable i2c does not work on a Pi4 (only tested on HassOSv3.8)
Resolution: manually edit the required files in linux (I used KALI Linux)
1) remove the sd card from the pi and plug it into a pc running Linux
2) most likely linux will not mount the partition "hassos-boot" because it is FAT
a) open a terminal window
b) type > blkid
c) in the resulting output, you'll see "LABEL="hassos-boot", note the location, mine is /dev/mmcblk0p1
d) type > sudo mkdir /mnt/msdos
e) type > sudo mount -t vfat /dev/mmcblk0p1 /mnt/msdos
d) now you can open the file /mnt/msdos/config.txt
e) uncomment the line "dtparam=i2c_arm=on"
3) If the hassos-overlay partition mounted, (if not, do step 2 for this partition)
a) open the file: hassos-overlay\etc\modules-load.d\rpi-i2c.conf
b) ensure it has only these 2 lines: (mine already did, likely from when trying "import usb" method)
i2c-bcm2708
i2c-dev
4) replace the sdcard back into the pi and start normally
a) the i2c bus should be functioning now
Awesome! Glad I found your post. I was fighting with the i2c interface for a few days now. Checking whether it might be Raspi 4 related was a lucky punch. It worked right away.
Perhaps a note should be added to the official how-to page (https://www.home-assistant.io/hassio/enable_i2c/) indicating that the described method is not yet working for Raspberry Pi 4.
I am on Ubuntu now trying to follow your steps. On step 2.d, should I just type /mnt/msdos/config.txt in the console and a text editor should pop up? Because I am getting: /mnt/msdos/config.txt: line 65: [all]: command not found.`
BTW, I have rPi 3b, but the Import from USB does nothing to my system. So I found your post.
Thank you so much! I’ve used nano a year ago so I forgot how it’s done. Newbie here obviously
Any idea how to rename in linux a format type from .txt to .conf for step 3?
Because I created a text file, added the lines but I am stuck again as I have a rpi-i2c.conf.txt file instead of a rpi-i2c.conf file
So like I said, what I did is create a file in the Documents folder in Ubuntu because it did not let me save it in the hassos-overlay\etc\modules-load.d folder. Now I am trying to move it and it does not let me as I do not have enough privileges. So back to square one.
Thanks to your help, I managed to create the file in nano.
If you are absolutely sure you have the file correct and are not overwriting an existing file that you might want to keep, you elevate your permissions by putting “sudo” before your command.
If there is already a file with the same name at the destination location, you can rename it so that it’s still available for future reference: “sudo mv filename filename.original”
I managed to get I2C working on RPi4. For ONE sensor, sitting on the default SDA, SCL pins (GPIO2 and GPIO3). However I have 5 other BME280 sensors, sitting on different GPIO-s.
The below code in config.txt worked on RPi2 earlier, but with RPi4, hassio is not booting if I add these.
this is still not working for me , I have been trying for days with every possible combination
I might just give up on Hassio if such a basic function of Pi is not available …
is there a hardware version of the Pi4 board I need to check for ? mine is brand new bough 2 weeks ago ( trying to move up from Pi3 )