BBB - Debian 10.3 - SHT21 sensor not detected (I2C)

Hi,

I’m trying to connect an SHT21 sensor (I2C) to my BeagleBone Black, but it cannot be detected by i2cdetect.
I tried searching online, but nothing very useful popped up.
Could anyone share some advice?

PS: Just before asking this question, I started doubting the i2cdetect tool itself.
Indeed, turns out it was all working fine (see answer below).
I will still post the question I was about to ask, as it might be helpful to somebody else in the future.

Circuit
circuit

How to reproduce
Power up the BBB and ssh into it.
Then connect the +3.3V and GND pins to the external circuit, and run the following command:

i2cdetect -y -r 2

Output:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Details about the BBB
Processor: AM3358 ARM Cortex-A8
OS: Debian 10.3 Buster IoT (without graphical desktop)

Details about the sensor.
The sensor is mounted on this breakout board:

Here’s a link to its datasheet: https://www.farnell.com/datasheets/1780639.pdf
I couldn’t find anything particularly useful there, except in section 5.1 where it states:

After power-up, the sensor needs at most 15ms, while SCL is high, for reaching idle state, i.e. to be ready accepting commands from the master (MCU)

I connected a logic analyzer to the SCL and SDA pins, and it all seemed fine.
Here’s the whole logic analyzer capture:

Here’s how the first two reads looked like, both NACK:

Here’s entire session, if you need to analyze it yourself:
sht21- session.sal (17.2 KB)

Other things I’ve tried/verified - 1
As I have two of these SHT21 sensors, I verified that both are working fine by using an ESP32 board.
On the BBB side, instead, I tried to connect an SSD1306 display (I2C) to the same circuit, and indeed it was detected at address 0x3c
Conclusion: the sensor works fine, the BBB works fine.

Other things I’ve tried/verified - 2
This sensor was used as part of the BeagleBone Weather Cape (Revision A), so there has to be a way to make it working somehow: BeagleBone Weather - eLinux.org
I couldn’t find anything special in its schematic either: https://github.com/CircuitCo/BeagleBone-Weather/blob/Rev_A/BeagleBone-Weather-RevA-schematic.pdf?raw=true

As stated in the question, i2cdetect isn’t able to detect the SHT21 sensor on the BBB, although plenty of posts online claim that it works fine with a Raspberry PI.
Therefore, you can ignore it and use the sht21 kernel module anyway.

The circuit remains the one shared before.
Here’s what you need to do in a nutshell:

# gain root privileges, or use `sudo` each time you're asked
sudu su

# verify that the sht21 kernel module exists
find "/lib/modules/$(uname -r)/kernel/drivers/hwmon" -name sht21.ko.xz

# load the module
modprobe sht21

# let the kernel know to which bus the sensor is connected
echo sht21 0x40 > /sys/bus/i2c/devices/i2c-2/new_device

# the sensor values should now be exposed at /sys/class/hwmon/hwmon0 (or hwmon<some other number>)
cd /sys/class/hwmon/hwmon0

# print the temperature reading
cat temp1_input

# print the humidity reading
cat humidity1_input

Meanwhile, if somebody knows why i2cdetect doesn’t work with this particular sensor on the BBB, feel free to share!

1 Like