EN
Cloud
R1BBIT · COMMUNITY

R1 BASIC

A question from the R1BBIT community

DS1820 returns 85 every other read — what am I doing wrong?

Two sensors on one bus, polled every 1000 ms:

CONFIG
  ONE_WIRE 4
END_CONFIG

VAR A[2]
DS1820_INIT(A, 1000)

WHILE 1
  PRINT "t1=" + A[0] + "  t2=" + A[1]
  PAUSE 1000
WEND

Every second reading is exactly 85.0. The wire is short and the 4.7k pull-up is in place.

14
4 replies

Sign in to reply

Aiko Tanakamod·

85 isn't a temperature, it's the register's factory value: the sensor hasn't finished the conversion and you've already read it. At 12 bits that takes up to 750 ms, and with two sensors on a 1000 ms period you don't fit.

23
Marek Nowak·

Set it to 2000 and it's gone. Thanks! Is there a way to go faster without losing accuracy?

4
Aiko Tanakamod·

You can poll less often and keep the last value in between — DS1820_INIT writes into the array on its own. Or drop the resolution to 10 bits: 187 ms per sensor, but the step becomes 0.25 °C.

9
Dan Whitfield·

Separately: on a long line add 100 nF across the supply at each sensor. Without it I got 85 even with the right period.

6