under hood of HTU21DF sensor part 1

There is so much to learn and so many moving parts in technology now a days, am always reminded of what I do not know, rather than what I know. Hope that clarifies my very basic knowledge and would be glad if someone corrects mistakes in this post. In this post I am trying to learn Sensors to do a side project in my company. So this is a idiots guide to sensor specifically HTU21DF sensor.

HTU21DF is a digital sensor for capturing “Humidity” and “Temperature”. Sensor provides signal in I2C (I Squared C)  format. I2C is a serial communication protocol that communicates over Two Wire Interface (TWI). In this post, let us learn about I2C / TWI Protocol.

I2C / TWI Protocol:

  • A Micro-controller will have limited number of pins.
  • But sensor that a micro-controller can serve are many but limited by pins.
  • A two wire interface bus is built around 2 lines
    • 1 SCL – Clock (Synchronizes data transfer between master & sensors)
    • 1 SDA – Data (Carries data)
  • These two wires / bus helps connect multitude of sensors to Microcontroller.

Schematically I2C bus along with sensors is something as below, in which each sensor is Slave is connected to microcontroller using two wires (bus) one for Signal Clock and other for Signal Data


With 7 Bit address, 128 devices (sensors+ Masters) can be added to controller and with 10 bit addressing 1024 devices can be used using serial bus. Every sensor has unique address on bus, that master uses to communicate to that sensor.

Data Protocol:

Chunk 1: 

  • S= Start Bit.
  • A0 to A6 are address bits for Sensors for data transfers
  • A7 type of operation (Read / Write) that master will perform on slave.
  • Followed by Acknowledge bit used by slave to acknowledge receipt of previous sequence of bits from master.


After ACK, master device hands over control of SDA link to sensor with address in Address bits.

Chunk 2:


Post ACK, are bits for internal registers for sensors. For example temperature  / humidity sensors will have internal registers to capture either address  / data. When detailing HTU21DF we will deal again with these internal registers.

Chunk 3:

Data being transmitted either from Master to Slave to Slave to Master depending upon RW bit set in Chunk 1 and finally ends with a Stop bit to indicate communication between Slave and Master ends.


Above outlines how I2C protocol works on a Two Way Interface using Serial Bus Architecture.

Next up is understanding specific sensor, HTU21DF in terms of “Address”, “Internal Registers” and “Data Format” packet.

Immediately following up with next blog that utilizes these concepts with sensor..



One thought on “under hood of HTU21DF sensor part 1

  1. Pingback: Developing with HTU21DF Sensor part 4. | Abhyast

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s