1
\$\begingroup\$

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
}
\$\endgroup\$
  • 4
    \$\begingroup\$ 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. \$\endgroup\$ – Roger Rowland Jan 30 '16 at 9:24
  • 1
    \$\begingroup\$ @RogerRowland suggest you make this an answer so the question does not remain unanswered. \$\endgroup\$ – DoxyLover Jan 30 '16 at 19:18
2
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.