CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

SHT11 with the I2c bus

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
lmo44181



Joined: 24 Sep 2004
Posts: 1

View user's profile Send private message

SHT11 with the I2c bus
PostPosted: Fri Sep 24, 2004 6:56 am     Reply with quote

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 !
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Sep 24, 2004 8:50 am     Reply with quote

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
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Fri Sep 24, 2004 9:56 am     Reply with quote

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
Pierre
Guest







PostPosted: Mon Mar 06, 2006 1:14 pm     Reply with quote

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
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Mon Mar 06, 2006 1:51 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group