1

TL;DR:
The kernel module sht3x (https://www.kernel.org/doc/html/latest/hwmon/sht3x.html) seems to be missing in a standard debian installation. I need it in order to read an external sensor. How can I install this kernel module?

The whole story
I try to connect an SHT31 temperature/humidity sensor to my Debian notebook. In order to do so, I flashed an ATTiny85 micro controller to act as i2c-tiny-usb interface.

I got this part working - lsusb lists the device as

Bus 003 Device 003: ID 0403:c631 Future Technology Devices International, Ltd i2c-tiny-usb interface

and I also get a promising response from i2cdetect

$ sudo i2cdetect -l
i2c-3   i2c         i915 gmbus dpc                      I2C adapter
i2c-1   i2c         i915 gmbus vga                      I2C adapter
i2c-8   i2c         i2c-tiny-usb at bus 001 device 017  I2C adapter
i2c-6   i2c         AUX B/port B                        I2C adapter
i2c-4   i2c         i915 gmbus dpb                      I2C adapter
i2c-2   i2c         i915 gmbus panel                    I2C adapter
i2c-0   i2c         i915 gmbus ssc                      I2C adapter
i2c-7   i2c         AUX D/port D                        I2C adapter
i2c-5   i2c         i915 gmbus dpd                      I2C adapter
$ sudo i2cdetect 8
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-8.
I will probe address range 0x08-0x77.
Continue? [Y/n] Y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- 45 -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

However, I cannot read sensor data, because the kernel module sht3x is not installed on my (standard Debian) system and is not listed in lsmod.

Question
How can I install and make use of the sht3x kernel module on my Debian notebook?

1 Answer 1

2

I’m assuming you’re running Debian 10, but the instructions for later versions are similar. The module you’re after is supported by the kernel version used in Debian 10, but it is not enabled; let’s fix that.

  1. Install the kernel source for the default version in your release:

    sudo apt install linux-source
    
  2. Extract it:

    cd /usr/src
    tar xf linux-source-*.tar.xz
    

    (assuming there’s only a single linux-source tarball available, which will be the case unless you’ve installed multiple linux-source packages).

  3. Copy the current kernel configuration:

    cd linux-source-*/
    cp /boot/config-$(uname -r) .config
    
  4. Enable the configuration for the sht3x module:

    make menuconfig
    

    (this might complain about missing tools, such as a compiler; sudo apt install build-essential should fix things).

    To find which option needs to be enabled, and where it is, press / and enter “SHT3X”:

    Screenshot of make menuconfig showing the search results for “SHT3X”

    This gives a number of pieces of information:

    • the option is called SENSORS_SHT3X;
    • it is listed under “Device Drivers”, “Hardware Monitoring Support”;
    • the options it depends on are already enabled;
    • but it is disabled.

    Press Enter to exit the search results, go down to “Device Drivers”, press Enter, then go down to “Hardware Monitoring Support”, press Enter again, find the “SHT3x” option, and press M to enable it as a module.

    Press Tab until “Save” is highlighted, then Enter, confirm the name of the file to write (.config), and select “Exit” several times until you’re back at the prompt.

  5. Finally, build the module:

    make drivers/hwmon/sht3x.ko
    

    This might require additional dependencies, at least libelf-dev and libssl-dev (sudo apt install libelf-dev libssl-dev).

    If all goes well, you’ll end up with a drivers/hwmon/sht3x.ko file which you can load as a module.

5
  • 1
    Thank you for your detailed and precise instructions! For the records: In order to build the module, I also needed to install the libs libssl-dev and libelf-dev using sudo apt install libssl-dev libelf-dev. Just in case you want to add this for future readers.
    – Marcel
    Commented Jun 14, 2021 at 8:14
  • Thanks for adding that! Now that I have the module in /drivers/hwmon/sht3x.ko it should be enough to copy this file to /lib/modules/<version>/kernel/drivers/hwmon/sht3x.ko and then run depmod -a and modprobe sht3x right? Because this didn't work (the module was still not found) at the first try, but I will try again later and accept your answer once I got it running!
    – Marcel
    Commented Jun 14, 2021 at 8:38
  • Thank you! I got the kernel module compiled and loaded. I still cannot read the sensor data, but this was not the scope of my question.
    – Marcel
    Commented Jun 15, 2021 at 5:43
  • You’re welcome! What were the missing steps to get the module loaded? Commented Jun 15, 2021 at 5:50
  • There was just one thing missing: the kernel module is not signed so I cannot load it on boot and I have to use modprobe -f to load it. However, for some reason the module didn't work anyway (it was loaded but I couldn't use it to read the sensor - I don't know why) so I didn't investigate that any more and scripted/copied a simple driver in python.
    – Marcel
    Commented Jun 19, 2021 at 6:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .