Electronic – Dallas 1-wire Digital Thermo – issue with strong pullup

1-wireatmegapullup

I have 2 Dallas/Maxim DS18b20 digital thermometers connected in parasitic-power mode. If I include a strong-pullup as shown on p.6 of the datasheet, the nearer device gives good data; the further one reads back 85C (== the reset value). If I disconnect the strong pullup, I get valid temperature readings on both devices.

I omitted the MOSFET switch on the pullup and connected the strong-pullup i/o pin directly to the one-wire bus, floating it by making the pin an input with no pullup.

Why does the strong pullup not work as expected?
Why do the devices work OK without one?

schematic

simulate this circuit – Schematic created using CircuitLab

Sensor read function:

 int8_t DSSensorsSample(TempSens_t t[SENSORS_REQD], uint8_t nsens){
   for( TempSens_t *p = t;  nsens-- > 0;  ++p ){

      p->type = p->addr[0];

      ds.reset();
      ds.select(p->addr);
      ds.write(0x44, 1);        // start conversion, with parasite power on at the end
      pinMode(DSSTRONGPULLUPPIN, OUTPUT);
      digitalWrite(DSSTRONGPULLUPPIN, HIGH);

      delay(1000);     // maybe 750ms is enough, maybe not
      // we might do a ds.depower() here, but the reset will take care of it.

      pinMode(DSSTRONGPULLUPPIN, INPUT);
      digitalWrite(DSSTRONGPULLUPPIN, LOW);

      p->is_present = ds.reset();
      ds.select(p->addr);
      ds.write(0xBE);         // Read Scratchpad

      for ( uint8_t j = 0; j < 9; j++) {           // we need 9 bytes
         p->data[j] = ds.read();
      }
   }
   return( 0 );
}

Best Answer

Why are you switching DSSTRONGPULLUPPIN high/low each time? Just leave it high all the time and change the pin mode only. Even if this leaves the ATMEGA's internal 20kΩ pullup enabled, this is insignificant with respect to the 4.7kΩ fixed pullup you have.

In particular, the sequence

pinMode(DSSTRONGPULLUPPIN, OUTPUT);
digitalWrite(DSSTRONGPULLUPPIN, HIGH);

is causing the the pin to be a strong pull-down briefly. This is probably creating the errors you are getting.

Related Topic