Is it possible to connect an SHT75 sensor to I2C bus of BBB?

The SHT75 sensor has an I2C ‘like’ communications protocol (data sheet link below). It seems to have a default address below the range of the BBB I2C bus. Does anybody know how to go about logging this sensor on the BBB, and the necessary steps required to do so? Even general, hand waving in the right direction is welcome!

Thanks,

Rick

SHT75 datasheet:
http://www.sensirion.com/fileadmin/user_upload/customers/sensirion/Dokumente/Humidity/Sensirion_Humidity_SHT7x_Datasheet_V5.pdf

I’ve gotten the SHT15 humidity sensor working on my IOIO. I haven’t done so on the BeagleBone Black yet, though pretty much the same approach should work. It looks like the SHT75 has a similar protocol.

You just want to use one GPIO pin for the clock and one for the data line, and then write some routines to bring them high and low per the protocol described on the datasheet. The only difficulty I had was that the SHT15 seemed to respond slowly, so I had to sleep for 10 or so milliseconds between pulses.

Eric Westphal

Why not use the driver?

A quick search through the kernel/drivers/hwmon directory shows at least 2 drivers for different sensitron temp/humidity sensors.
sht15.c and sht21.c

sht21.c seems to be compiled by default. It uses the i2c protocol to communicate with the sensor.

sht15.c is not compiled by default, so you would need to rebuild your kernel and enable it. It uses gpio to communicate with the sensor.

From your datasheet, the following are the i2c commands:

Measure Temperature 00011
Measure Relative Humidity 00101
Read Status Register 00111
Write Status Register 00110
Soft reset, …11110

From sht21.c:

/* I2C command bytes */
#define SHT21_TRIG_T_MEASUREMENT_HM 0xe3
#define SHT21_TRIG_RH_MEASUREMENT_HM 0xe5

Looks like a perfect match!

Give it a shot. Connect up your sensor to some i2c pins. Load one of the i2c device trees to enable the i2c pins. Then load up the driver and check to see if it detected a monitor, ie ‘sudo insmod sht21’ or ‘sudo insmod sht21.ko’

You may need to run ‘echo sht21 0x40 > /sys/class/i2c-adapter/i2c-X/new_device’ where X is the i2c line the sensor is on.

If all goes well, there should be an interface somewhere in the /sys directory where you can run “cat temp” or something like it to read the temperature.

See http://www.raspberrypi.org/phpBB3/viewtopic.php?f=44&t=7086 for an adventure in trying to get it working the raspberry pi or do a search on google for “sht21 linux” to try to find some examples of usage[as opposed to all the links to the sourcecode which you don’t care about]

Looking at the datasheet a bit further, sht21 uses an ACTUAL i2c protocol, while the SHT75x seems to use the same command bits, but skips the address book. Checking the datasheet for the SHT1X sensor, it’s communication descriptions seems to be an exact match for the SHT75X
http://www.sensirion.com/fileadmin/user_upload/customers/sensirion/Dokumente/Humidity/Sensirion_Humidity_SHT1x_Datasheet_V5.pdf

So you would need to compile that driver[easiest method is to recompile the kernel and during the configuration find the sensor in the options and enable it].

Checking the driver I see the following:

static struct platform_device_id sht15_device_ids[] = {
{ “sht10”, sht10 },
{ “sht11”, sht11 },
{ “sht15”, sht15 },
{ “sht71”, sht71 },
{ “sht75”, sht75 },
{ }
};

So that’s promising. Not sure how you go about invoking modprove to specify which GPIO pins to use, but I’d think it would be much easier to use the module than write new code.

Thank you very much for all the pointers for getting this to work on the BBB, Gary. It actually was pretty easy to write some custom code to get the SHT15 to work on the IOIO (in Java), but I am just at the stage in my BBB education where I’m curious about compiling the kernel for myself and configuring the device tree, so I will give this a try too. Your pointers are very helpful.

Best Regards,

Eric Westphal

Thanks Eric and garyamort - really helpful suggestions and it’s good to see that it is not only possible, but is in multiple ways too. Now that I can see how to deal with the I2C protocol, I feel more comfortable with the programming approach but will give the recompiling option a shot first as it does sound quicker, and the Angstrom Wiki page seems to lay it all out.

Cheers,

Rick

Hi, Gary & Rick.

Well, I got the sht15 kernel module compiled and installed. Now the rub is indeed, as you say, how to specify which GPIO pins to use!!! So far I’m not seeing it in the c code. If I figure it out, I’ll post a how-to somewhere… In any case, it has certainly been educational so far!

Thanks again,

Eric

It looks like it has to be done within the device tree, setting gpio_data, gpio_sck, and supply_mv in a platform device struct. I have yet to tackle the device tree myself, and it’s too late here for me to start that tonight…

I think your right about it being in the device tree - I know there is a way of specifying drivers and such there, but have not gotten around to needing that yet.