Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8157

Raspberry Pi OS • Re: How to access I2C device from user space

$
0
0
That was a big help! thanks!

I had wondered if I had broken the SHT45 hardware and it wasn't probing. So, I added some pr_alert()'s in sht4x_probe() expecting to see them in /dev/kmsg when I modprobe'd. I did not. However, after making the change you recommended, on the reboot my serial console showed me debug statements at the end of the boot. I like to remove "quiet" from cmdline.txt so I can see all the start up messages.

Code:

[   17.858735] sht4x_probe: Entering sht4x_probe[   17.866720] sht4x_probe: I2C Send Returned 1[   17.884229] sht4x_probe: SucceededDebian GNU/Linux 12 sws ttyS0sws login:
I looked at /sys/bus/i2c/drivers/sht4x and there was a directory in there that didn't exist before

Code:

$ cd /sys/bus/i2c/drivers/sht4x$ file *1-0044: symbolic link to ../../../../devices/platform/soc/3f804000.i2c/i2c-1/1-0044bind:   regular file, no read permissionmodule: symbolic link to ../../../../module/sht4xuevent: regular file, no read permissionunbind: regular file, no read permission
The 1-0044 sym link didn't exist before. I assume it means I2C bus 1 Address 0x44.
I followed that down and found the files that correspond to the temperature and humidity:

Code:

$ cd /sys/bus/i2c/drivers/sht4x/1-0044/hwmon/hwmon2$ file *device:          symbolic link to ../../../1-0044humidity1_input: ASCII textname:            ASCII textof_node:         symbolic link to ../../../../../../../../firmware/devicetree/base/soc/i2c@7e804000/sht4x@44power:           directorysubsystem:       symbolic link to ../../../../../../../../class/hwmontemp1_input:     ASCII textuevent:          ASCII textupdate_interval: ASCII text
Sure enough I get reasonable values:

Code:

$ cat namesht4x$ cat temp1_input25338$ cat humidity1_input46473
I am going to have to learn a little more about the Device Tree.

Thanks again.
Chris

Statistics: Posted by chriskot870 — Tue Sep 03, 2024 12:05 am



Viewing all articles
Browse latest Browse all 8157

Trending Articles