View previous topic :: View next topic |
Author |
Message |
lmo44181
Joined: 24 Sep 2004 Posts: 1
|
SHT11 with the I2c bus |
Posted: Fri Sep 24, 2004 6:56 am |
|
|
Hello
Could anybody help me to get back the data of temperature and humidity of the sensor SHT11 then to pass on them on the I2C bus?
The programming of will make on a PIC16F877 put in slave mode.
Thank for you help ! |
|
![](templates/subSilver/images/spacer.gif) |
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Fri Sep 24, 2004 8:50 am |
|
|
If you do a search on SHT11 you will find other posts on this board with code samples. The SHT1x and SHT7x are not I2C devices they have a proprietry interface |
|
![](templates/subSilver/images/spacer.gif) |
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Fri Sep 24, 2004 9:56 am |
|
|
The SHT1X uses the same command structure as regular I2C devices but it is not 100% compatible. First, get the specification sheet for it and read through it completely. I had to go through it multiple times before I figured out how to get the thing to work.
You'll notice that the start signal, for the sensor, involves both an I2C start and stop signal. This is one of the main points that it is not completely I2C compatible. I had to lower my pull-ups to 1K to get communications to work properly. I had to insert a buffer IC between the PIC and sensor when I mounted the sensor a few feet away from the PIC. I used a 74CBT3253 and had 4K resistors on the PIC side and 1K resistors on the sensor side.
I bit-banged the start signal and then used regular I2C commands to read and write to the sensor. Remember that the sensor takes a while to do it's thing so monitor the SDA line to see when it's been released by the sensor before you try to read back the data. Just make sure you read through the spec sheet a lot and become very familiar with it.
The PIC will need to be in Master mode to talk to the sensor too.
Ronald |
|
![](templates/subSilver/images/spacer.gif) |
Pierre Guest
|
|
Posted: Mon Mar 06, 2006 1:14 pm |
|
|
rnielsen wrote: |
I bit-banged
|
Hum, what does that mean exactly (sorry I'm french, I don't understand english at all...)
rnielsen wrote: |
The PIC will need to be in Master mode to talk to the sensor too.
|
So you mean you achieved to make the SHT work on the *hardware I2C interface* and not by GPIOs controled by software ?
Thx !
Pierre |
|
![](templates/subSilver/images/spacer.gif) |
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Mon Mar 06, 2006 1:51 pm |
|
|
It's been a while since I responded to the original post but...
When you, normally, start an I2C communications sequence you would send a i2c_start() command. This would tell all of the I2C devices that the master is going to start talking to one of them. Since the SHTXX sensors are not fully compatible I 'bit-banged' the signals. Meaning that I manually told the outputs to go high, low, high again.
This is the Start sequence that I use for the SHTXX sensors:
Code: |
void strt_i2c(void) // I2C start signal for the sensor. the sensor needs a slightly
{ // different start signal than the standard I2C protocol
output_high(clk); // calls for.
delay_cycles(1);
output_low(data);
delay_cycles(1);
output_low(clk);
delay_cycles(3);
output_high(clk);
delay_cycles(1);
output_high(data);
delay_cycles(1);
output_low(clk);
}// end of strt_i2c()
|
As for connecting the SHTXX sensor up to the regular I2C bus, I would strongly recommend against it, now that I've worked with them for a while. If you are using the I2C bus with other devices I believe you should connect the sensor to two different dedicated I/O pins and 'bit-bang' all of the signals to it. Master mode would not need to be a concern if this was done.
Ronald |
|
![](templates/subSilver/images/spacer.gif) |
|