『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 171|回复: 2

关于冬瓜haos树莓派i2C驱动问题。

[复制链接]

7

主题

190

帖子

1866

积分

金牌会员

Rank: 6Rank: 6

积分
1866
金钱
1676
HASS币
0
发表于 2025-1-14 15:44:57 | 显示全部楼层 |阅读模式
本帖最后由 dts 于 2025-1-14 22:00 编辑

冬瓜大佬,能不能把树莓派的i2c驱动加上啊。
已经解决了,驱动添加方法参见链接https://community.home-assistant ... configurator/264167
1、在加载项中添加仓库:https://github.com/adamoutler/HassOSConfigurator 需要科学上网。
2、仓库添加成功后,添加加载项: HassOS I2C Configurator
3、启动 HassOS I2C Configurator (注意禁用保护模式)启动成功后会自动生成i2c配置文件。
4、重启树莓派(不是重启ha)两次:第一次修改系统参数,第二次加载i2c组件。
5、登录终端检测:ls /dev/i2*    返回 /dev/i2c-0   /dev/i2c-1   /dev/i2c-13  /dev/i2c-14 表示成功。
6、成功后可以把HassOS I2C Configurator卸载掉。
回复

使用道具 举报

1

主题

37

帖子

256

积分

论坛DIY达人

积分
256
金钱
214
HASS币
20
发表于 2025-2-5 01:27:41 | 显示全部楼层
关注一下,学习学习。我有个黑豹X2也加了I2C的屏幕,看看又没头绪点亮
回复

使用道具 举报

1

主题

37

帖子

256

积分

论坛DIY达人

积分
256
金钱
214
HASS币
20
发表于 4 天前 | 显示全部楼层
Enable I2C
Home Assistant using the Home Assistant Operating System which is a managed environment, which means you can’t use existing methods to enable the I2C bus on a Raspberry Pi. In order to use I2C devices you will have to

Enable I2C for the Home Assistant Operating System
Setup I2C devices e.g. sensors
ENABLE I2C WITH AN SD CARD READER
ACCESS THE BOOT PARTITION
You will need:

SD card reader
SD card with Home Assistant Operating System flashed on it
Shutdown/turn-off your Home Assistant installation and unplug the SD card. Plug the SD card into an SD card reader and find a drive/file system named hassos-boot. The file system might be shown/mounted automatically. If not, use your operating systems disk management utility to find the SD card reader and make sure the first partition is available.

ADD FILES TO ENABLE I2C
In the root of the hassos-boot partition, add a new folder called CONFIG.
In the CONFIG folder, add another new folder called modules.
Inside the modules folder add a text file called rpi-i2c.conf with the following content:
i2c-dev
Txt
In the root of the hassos-boot partition, edit the file called config.txt add two lines to it:
dtparam=i2c_vc=on
dtparam=i2c_arm=on
Txt
START WITH THE NEW OS CONFIGURATION
Insert the SD card back into your Raspberry Pi.
On startup, the hassos-config.service will automatically pickup the new rpi-i2c.conf configuration.
Another reboot might be necessary to make sure the just imported rpi-i2c.conf is present at boot time.
ENABLE I2C VIA HOME ASSISTANT OPERATING SYSTEM TERMINAL
Alternatively, by attaching a keyboard and screen to your device, you can access the physical terminal to the Home Assistant Operating System.

You can enable I2C via this terminal:

Login as root.

Type login and press enter to access the shell.

Type the following to enable I2C, you may need to replace sda1 with sdb1 or mmcblk0p1 depending on your platform:

mkdir /tmp/mnt
mount /dev/sda1 /tmp/mnt
mkdir -p /tmp/mnt/modules
echo -ne i2c-dev>/tmp/mnt/modules/rpi-i2c.conf
echo dtparam=i2c_vc=on >> /tmp/mnt/config.txt
echo dtparam=i2c_arm=on >> /tmp/mnt/config.txt
sync
reboot
Bash
TROUBLESHOOTING
After rebooting the host there should be i2c-0 and similar device files in /dev. If such device files are missing, enabling I2C failed for some reason. You can check the status of I2C kernel modules by using lsmod | grep i2c in the terminal. If they are loaded, you should find at least the entry i2c_dev. Active usage of the modules is indicated by a number, e.g. i2c_dev 20480 2 would indicate two active I2C device files.

An active I2C can also be checked with a multi meter showing 3.3 V on the I2C pins GPIO2 and GPIO3.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2025-2-23 23:04 , Processed in 0.151017 second(s), 24 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表