Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By DaniloFix
#40993 Hi

I have a couple of DS18B20 wired to a NodeMCU in parasite mode. I use a 1K pullup resistor, but I've noticed something strange when using the DallasTemperature library with more than 1 sensor. One of the sensors is connected through a 2 meter long wire, while the other is mounted directly on the board.

In the beginning I was using just one sensor, and my readings were correct. Now I have 2 connected, and the reading are way off. But if I only use the onewire library and use the ds18b20 example from there, then I get valid readings from both sensors, so something is messing it up.

Here's serial output using first the DallasTemperature Library and second only onewire library.

Code: Select all// DallasTemperature Multiple example

Locating devices...Found 2 devices.
Parasite power is: ON
Device 0 Address: 289B161E070000E0
Device 1 Address: 28FF42A6921501A8
Device 0 Resolution: 12
Device 1 Resolution: 12
Requesting temperatures...DONE
Device Address: 289B161E070000E0 Temp C: 127.94 Temp F: 262.29
Device Address: 28FF42A6921501A8 Temp C: 46.38 Temp F: 115.47
Requesting temperatures...DONE
Device Address: 289B161E070000E0 Temp C: 127.94 Temp F: 262.29
Device Address: 28FF42A6921501A8 Temp C: 46.38 Temp F: 115.47


// OneWire DS18S20, DS18B20, DS1822 Temperature Example

ROM = 28 9B 16 1E 7 0 0 E0
  Chip = DS18B20
  Data = 1 78 1 4B 46 7F FF 8 10 51  CRC=51
  Temperature = 23.50 Celsius, 74.30 Fahrenheit
ROM = 28 FF 42 A6 92 15 1 A8
  Chip = DS18B20
  Data = 1 CD 1 4B 46 7F FF 7F 10 B1  CRC=B1
  Temperature = 28.81 Celsius, 83.86 Fahrenheit
No more addresses.


You guys have any idea as to why the DallasTemperature Library is behaving like this when I have 2 sensors connected on the same wire?
User avatar
By eas
#40996 You should really include or link to the code you are using to generate these outputs.

I'm pretty sure that erroneous reading is out of range of valid readings for that sensor, which is probably a hint of an error condition somewhere.

My guess is that the sensor with the bad reading is the one at the end of a long wire. Is that the case?

Either way, if you actually read the datasheet for the sensor, you'll see that parasitic power mode isn't really as simple as using a pull-up resistor. I suspect the underlying problem is that you need to do a better job about providing the parasitic power.

The biggest power load happens when the sensor is acquiring a temperature reading. Communications has lower power requirements.

I suspect the fact that you are seeing different results relates to differences between the two different libraries / sketches. Perhaps the DallasTemperature example tries to have both sensors do their temperature conversion at the same time, causing a voltage sag that prevents the sensor at the end of the wire isn't getting enough power to do so successfully, whereas the other example triggers the temperature conversion one at a time, allowing the sensor on the wire enough power do do the temp conversion.

Possible Solutions:
Don't use parasitic power mode, or
Implement a suitable power supply for parasitic power.

Possible Work-arounds:
Use a lower value pull-up resistor, or
Initiate temp conversion separately for each sensor in turn.
Last edited by eas on Fri Feb 12, 2016 6:54 pm, edited 1 time in total.
User avatar
By martinayotte
#40998 @eas is right !
Parasitic mode is NOT as simple as simply adding a PullUp.
According to the Dallas specs, the power need to be provided by a strong connection to VCC using a MOFSET controlled by an additional GPIO.
Most Arduino libraries doesn't provide any of such control for the mosfet.
So, even if some people said it is working with a pullup, the results are rather on border line.
I strongly suggest to have a third wire for permanent VCC, especially that it is already present if you are using cheap 4-wire telephone cable. Otherwise you will need to follow Dallas specs much more closely.
User avatar
By xtal
#41006 parasite mode requires a least 750 ms per device to get temp
issue convert cmd wait 750+ ms read
powered mode is much faster and more dependable...
If you buy the powered units , you can run them as parasitic, you must tie 2 leads together.
Parsitic units cannot be powered....except parasitic power [ie] charge an internal cap from the data line.....
I have 7 parasitic connected to a [ link USB] connected to pc using LogTemp
AC-outside - air in/air out/liquid line/suction line
Attic- Temperature-return plenum-supply plenum
been working good for 4 years/ sometimes lose outside sensor -lead coroision