View previous topic :: View next topic |
Author |
Message |
edi
Joined: 22 Dec 2003 Posts: 82
|
16F819 & I2C sensor |
Posted: Mon Jul 18, 2005 4:27 am |
|
|
HI,
I want to connect an I2C sensor to the 16F819.
I saw in the data sheet that this device is only I2C slave.
Is that mean that I can't read from the sensor?
If yes, can someone please send me a simple example for that.
Edi. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Jul 18, 2005 5:53 am |
|
|
You can implement the I2C master in firmware. CCS has functions for that as well as example programs. Look at the eeprom examples. Without knowing which sensor that's about all the help I can give you. |
|
|
edi
Joined: 22 Dec 2003 Posts: 82
|
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Mon Jul 18, 2005 9:11 am |
|
|
The sensirion sensors are not I2C devices. The protocol is similar but not the same as I2C. It is easy enough to "bit bash" to implement it in the PIC. If you do a search for Sensirion on this site you will find code posted by others. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Mon Jul 18, 2005 12:21 pm |
|
|
I am, currently, using the SHTXX sensor in one of my designs. I had four sensors connected up to the I2C bus utilizing a multiplexer (SN74CBT3253). Since each sensor has the same address you cannot communicate with multiple ones on the same bus unless you use a multiplexer like this. I put 1K pull-up resistors on the Master side and also 1K resistors on each of the sensor buses. Then I simply addressed the multiplexer with a couple of outputs, from the Master, for the sensor that I wanted to talk to.
It's possible to have this sensor connected to the I2C bus but I found it needs to have the bus isolated with something like the multiplexer. The Start signal, of the sensor, is not a standard I2C Start either. It incorporates both a Start and Stop to signal you want to talk to it. It took me a while to figure out how to get it to work on the I2C bus and is a bit easier simply to bit-bang it with separate outputs from the Master.
When the data sheet says that the device is only a Slave, it just means that it cannot act as a master to control other devices. You can talk to it, read from it with a Master. You can even write to certain registers inside of the sensor. Mostly to turn on an internal heater to remove condensation, if needed, before making a reading. You would turn off the heater before you would read the RH/Temperature, of course.
Ronald |
|
|
|