I drive sht11 temperature-humidity sensor from mcu, the reference design from MikroElektronika uses the following:
To make sda pin high, the pin connected to sda (which is pull-up) is not given to logic 1 instead, it is made input to make sda high.
I used this and it worked, I ask is it better and why?
/***************************************************************
* Generates a transmission start
* _____ ________
* DATA: |_______|
* ___ ___
* SCK : ___| |___| |______
***************************************************************/
void Transmission_Start() {
SDA_Direction = 1; // define SDA as input
SCL = 1; // SCL high
Delay_1us(); // 1us delay
SDA_Direction = 0; // define SDA as output
SDA = 0; // SDA low
Delay_1us(); // 1us delay
SCL = 0; // SCL low
Delay_1us(); // 1us delay
SCL = 1; // SCL high
Delay_1us(); // 1us delay
SDA_Direction = 1; // define SDA as input
Delay_1us(); // 1us delay
SCL = 0; // SCL low
}
Best Answer
On page 5 of the datasheet it says "To avoid signal contention the microcontroller must only drive DATA low. An external pull-up resistor (e.g. 10kΩ) is required to pull the signal high" - I guess it means that you don't want to have the possibility that your micro drives it high while the sensor drives it low, giving a direct short.