SHT31/Why this sensor/01. Two wires instead of one
Why this sensor · 01 of 11

Two wires instead of one

The DHT boards in the same kit each need a digital pin of their own. The TK120 shares two wires with everything else on them, which is the whole reason it exists — and the reason it runs out at the third sensor rather than the fourth.

What the board is for

Two numbers — temperature and relative humidity — from a part 2.5 mm square, already calibrated, over two wires that everything else on your project can share.

The TinkerBlock line has four other ways to measure temperature, and they are a ladder. An NTC thermistor gives you a resistance and leaves the arithmetic, the reference voltage and the accuracy to you. A DHT11 gives you a number, in whole degrees, down a wire of its own. A DHT22 gives you tenths, down a wire of its own. An LM75 shares a bus, and measures temperature only.

This one is the last rung: both numbers, tenths of both, and a bus.

Two wires, however many sensors
Sensors on the project3
Signal pins, one wire each
3
Signal pins, shared bus
2
Addresses free
0
3 of these on one bus is 1 too many. The SHT31 has exactly two addresses — 0x44 and 0x45 — so a third board answers at an address something else already owns, and the two reply over each other. More sensors than that means a second bus, or a different part.

Why a pin each adds up

A DHT has no address anywhere in its protocol. The host pulls the line low, the sensor answers, forty bits arrive. There is no field in that exchange for "and this message is for you", so two DHTs on one pin both answer at the same moment and neither reading survives.

That is not a defect, it is what the protocol is. It just means every DHT costs a pin, and pins are the thing a small board runs out of first.

I²C puts an address at the front of every exchange. The two wires are shared, every device on them listens, and the one whose address was called answers. Six devices is still two wires.

Where it runs out

At the third SHT31, and for a reason worth understanding before you buy two.

The address is not a setting you write to the sensor — it is decided by a pin, ADDR, and that pin can be at ground or at the supply. Two states, two addresses: 0x44 and 0x45. On this board ADDR is held at ground by a resistor, and the two jumpers are where you change that.

So one bus holds two of these and no more. A third would answer to an address one of the other two already owns, and the symptom is not an error — the scan finds one device where there are two, and the readings come back as rubbish or not at all.

What it does not do

The sensor has an ALERT output that can be programmed to go high when a reading crosses a limit you set, and an nRESET pin for a hardware reset. Neither is brought out to the header on this board: both appear in no net at all. If you want an interrupt when the room gets damp, you compare the numbers in your own sketch. A soft reset command is the only reset there is.

When it does not work

Is this the same as a one-wire sensor?

No, and the resemblance is only that both use few wires. A DHT sends forty bits down a single line with no address in the protocol at all, so two of them on one pin would answer at once. I²C has an address in every exchange, which is what lets devices share the wires — and it is why an I²C scan finds an SHT31 and will never find a DHT.

Do I need to add pull-up resistors?

Not for this board. Two 10 kΩ resistors are already fitted, one on SDA and one on SCL, and they are connected from the factory. That is unusual enough to matter: most bare I²C chips leave it to you, and this one does not.

How many of these can share one bus?

Two. The sensor has exactly two addresses, 0x44 and 0x45, chosen by one pin — so a third board has nowhere to go and would answer over one of the first two. Three sensors means a second I²C bus, a multiplexer, or a different part.

Can it share the bus with a display or another sensor?

Yes, and that is the point of a bus. Anything at an address other than the one your SHT31 is using can sit on the same two wires: an SSD1306 display at 0x3C, an ADS1115 or an LM75 at 0x48. Run an I²C scanner first and read off what is already taken — and note that those last two both default to 0x48, so they are a conflict with each other rather than with this.

Where this goes next

What the +/- on the box is actually worth, and where the sensor stops being your limiting factor.

How good the numbers are

Edit this page — content/books/sht31/two-wires-instead-of-one.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

SHT31 Temperature and Humidity Sensor

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum