DS18B20 doesn't work in parasite power mode

Hi Guys!
Here is a pic of what I have:

As you can see the left sensor is connected in a normal power mode, the right one in parasite power mode.
The issue is the left sensor doesn't work in the parasite power mode if I connect its Vdd to the ground rail (with or without the right sensor connected) . The 1-wire example sketch throwing "No more adresses" in both cases, so the right sensor stops working.

Do all DS18B20 support parasite power mode? The problematic sensor says 18B20 1602C4 +233AA, the working fine one says 18B20 1516C4 +760AA. I suppose they are pretty much the same though.

Another question is in the current setup I use DallasTemperature library and haven't found anything regarding the power mode to be set up in there (as against the 1-wire example where we've got:

  ds.write(0x44, 1);        // start conversion, with parasite power on at the end

to have parasite mode "enabled"

The sketch of mine is:

#include <OneWire.h>
#include <LiquidCrystal.h>
#include <DallasTemperature.h>


OneWire  ds(2); // on pin 2 (a 4.7K resistor is necessary)
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
DeviceAddress firstTermometer = { 0x28, 0xFF, 0xA5, 0x05, 0x83, 0x15, 0x02, 0x01 };
DeviceAddress secondTermometer = { 0x28, 0xF5, 0x68, 0x08, 0x00, 0x00, 0x80, 0x38 };
DallasTemperature sensors(&ds);


const int numReadings = 10;
int readings[numReadings];
int readIndex = 0;
int total = 0;
int average = 0; 
int FAN = 3;
int FAN_pwm = 110; //140-2V minimum without sound
int POWER = 4;


void setup(void) {

  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.write("AIR: ");
  sensors.begin();
  sensors.setResolution(firstTermometer, 10);
  
  pinMode(6, OUTPUT); //LCD brightness
  pinMode(FAN, OUTPUT);
  pinMode(POWER, OUTPUT);
  analogWrite(6, 1);
  analogWrite(FAN, FAN_pwm);
  digitalWrite(POWER, HIGH);
  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }
}

void loop(void) {
  delay(1000);
  int ldr = 0;
  int ldrReading;
  
  sensors.requestTemperatures();
  Serial.print("Temperature for first Therm =");
  float  temp1 = sensors.getTempC(firstTermometer);
  float  temp2 = sensors.getTempC(secondTermometer);
  Serial.println(temp1);
  
  lcd.setCursor(4,0);
  lcd.print(temp2);
  lcd.print((char)223);

 
  total = total - readings[readIndex];
  readings[readIndex] = analogRead(ldr);
  total = total + readings[readIndex];
  readIndex = readIndex + 1;
  if (readIndex >= numReadings) {
    average = total / numReadings;
    //Serial.print("Avg Reading = ");
    //Serial.println(average);
    if (average == 0) average = 1;
    if (average > 400) average = 255;
    analogWrite(6, average);
    //Serial.print("Avg applied = ");
    //Serial.println(average);
    readIndex = 0;
  }



}

Is it OK that I use two power modes simultaneously?

As far as I am aware, you can't mix the two modes, although I haven't tried it and I haven't read the datasheet closely enough to be sure. If you use the Dallas Semiconductor library, it checks whether there is a parasite mode DS18B20 on the bus (there is a DS18B20 command to do this), and if there is then it uses parasite mode to access all of them.

If for some reason you need to have both, you can put them on separate pins and instantiate two buses: similar to this:

OneWire  ds_non(2); // non_parasite modes on this bus
OneWire  ds_par(3); // parasite modes on this bus

The buses don't have to be on pins 2 and 3. Use whichever digital pins are convenient and valid.
The non-parasite mode DS18B20 can all be commanded to do a temperature conversion simultaneously. This means that the delay that is required while waiting for the conversion only needs to be done once while they are all converting.
The parasite mode conversions must be done one at a time because there's not enough power on the bus for them all to convert at once.

Pete

Hi Pete!

el_supremo:
If you use the Dallas Semiconductor library, it checks whether there is a parasite mode DS18B20 on the bus (there is a DS18B20 command to do this), and if there is then it uses parasite mode to access all of them.

Assuming this I've tried to disconnect Vdd of the left (problematic) sensor and it stops working. Does that mean that the Dallas Semiconductor library doesn't access the sensors in the same way.

el_supremo:
If for some reason you need to have both, you can put them on separate pins and instantiate two buses: similar to this:

I do not need to have both, I'd like to figure out why the left sensor doesn't work in a parasite mode :frowning:

Disconnecting Vdd would leave the pin floating. I don't know what it'll do in that case.

IIRC either ds.write(0x44, 0); or ds.write(0x44); specifies non-parasite power.

I would wire up both sensors in non-parasite mode and use a OneWire scanner to see if it finds them both just to be sure that both are working. Then wire them both in parasite mode and try again.

Pete

both works perfectly in non-parasite mode and the (working) sensor works in parasite mode but when I connect the (faulty?) sensor in parasite mode both stop working. So there are two working combinations: both in non-parasite mode and (using Dallas Semi Lib) one sensor in parasite mode and another one in non-parasite mode. I think I need to check a third sensor.

Oh gosh! Another thing that I see is my "working" sensor returns crappy readings when it's powered in non-parasite mode! WTF is wrong with my setup?? So the only working combination for me right now is one sensor in parasite mode and another one in non-parasite mode :frowning:

A better explanation of "crappy readings" might be in order.......

I don't think it is a good idea to use parasite and normal modes. I didn't think it was possible, and maybe it isn't. Parasite power is only for the desperate, usually gives grief, is best avoided, and I bet you haven't got a good reason for using it. You might be better off testing each sensor in a new one-sensor programme with normal power supply, so you can better find your feet, and ensure all the sensors are kosher.

I'm sure it is possible to get parasite mode working, but I've never been able to and now don't bother even trying. Without specialist equipment (an oscilloscope at least), it's going to be tricky to debug too. Unless you are enjoying the challenge, I'd concentrate on getting your project working with three wires.

Nick_Pyner:
A better explanation of "crappy readings" might be in order.......

I don't think it is a good idea to use parasite and normal modes. I didn't think it was possible, and maybe it isn't. Parasite power is only for the desperate, usually gives grief, is best avoided, and I bet you haven't got a good reason for using it. You might be better off testing each sensor in a new one-sensor programme with normal power supply, so you can better find your feet, and ensure all the sensors are kosher.

Sorry. When both sensors are connected in normal modes one of them returns values 10-15°C higher then another. I read them every 1 sec. If it was self-heating they would heat both I assume. When I switch back to parasite mode, the readings difference reduces to ~0,3°C.

That's how I try to connect them in normal mode. (Third pads set is spare)


wildbill:
I'm sure it is possible to get parasite mode working, but I've never been able to and now don't bother even trying. Without specialist equipment (an oscilloscope at least), it's going to be tricky to debug too. Unless you are enjoying the challenge, I'd concentrate on getting your project working with three wires.

I'd love to drop meddling with this damn parasite mode. My store run out 18B20 so I'll need to wait couple of days to get another one to check what is misbehaving.

In the first diagram, the resistor appears to be 220 ohms which is way too low.
Use a 4700 (4k7) ohm resistor. The diagram you've just posted shows 4k7 which is correct.

Pete

el_supremo:
In the first diagram, the resistor appears to be 220 ohms which is way too low.
Use a 4700 (4k7) ohm resistor. The diagram you've just posted shows 4k7 which is correct.

Pete

Sorry, the first diagram is not correct. I just placed elements to show how I connect them. Don't bother about the values in it. The second mathematics is one I use in my proj. So it must be currect.

Have you made it work?

GeeksTips:
Have you made it work?

Not yet, I wait for a store to get the sensors in stock.

So, I've bough another 18B20, connected them in normal mode and they return the same readings! Yay! And meanwhile I've moved to the "production" PCB.

So the issue is solved. Use working sensors and the force will be with you.

DS18B20s are pretty robust so, now that you have things working properly, you might try re-installing the other sensor. Your problems may have been due to pilot error all along, and the sensor is actually OK.

Nick_Pyner:
DS18B20s are pretty robust so, now that you have things working properly, you might try re-installing the other sensor. Your problems may have been due to pilot error all along, and the sensor is actually OK.

I've checked it several times, it def heats when is used in normal mode.

You solved that issue only with changing sensor? I have same problem, yet I am using single DS18B20 sensor and it is connected in normal mode. Therefore I have corrected the parasitic power line as ds.write(0x44). By the way I am using onewire library not dallas. Thanks.

This thread has been dead for over 3 years you realize?

My first question is do you have a genuine DS18B20 - unless you buy from a reputable electronics supplier you
will likely have a counterfeit these days, its heavily counterfeited on the grey market.

Hello, I am working on a project with a DS18b20 waterproof Temperature sensor, I have to use this temperature sensor especially in parasatic mode, so I am facing some problems here
the link of temperatue sensor:-[https://de.rs-online.com/web/p/entwicklungstools-sensorik/2049893/] but I wanted to mention something

  1. I am using 4 sensors they all are working fine in Normal mode when I connected Vdd to external power 5v or3 3.3v.
    2 .but when I connected with Vcc to the ground(Parasite power) it shows a -127 dc error according to the datasheet it says the sensor is disconnected, the voltage between gnd and data wire showing 0.7 volts, I have tried 4.7k,1k,3.3k all types of pull up resisitors.
    3.Its just a problem with parasitic power mode.
    Please I desperately need on this.

Thanks in advance

Why?