0

I have two DS18B20 temperature sensors connected via a OneWire bus to an arduino. I noticed that these sensors get hot, when permanently powered and decided to just turn them on for measurment.

First attempt: Define a pin as output and feed the sensors. Because I received only one value (first sensor on bus), I assumed that the current delivered may not be high enough and utilized a transistor (+resistor) as switch for the main 5V line to feed the sensors from the mains (as before). The result is the same. I only get the value of the first sensor. When I connect the sensors directly, I get both values.

I tried up to 4 seconds delay after switching the bus on and again after reading the values (before switching the bus off again), with no luck. Only the first sensor answers.

Do I have a timing or a current problem here?

UPDATE

Wiring (working): Two DS18B20 in parrallel with a 4,7k resisor between DATA and VIN. One Arduino pin used, Sensors directly powered by power-supply (same as arduino)

Wiring (not working): Broke the VIN line and added a transistor as switch between power-supply and sensors VIN. Used a second pin and a resistor to power up the line.

The transistor is a TC124E (npn) logic level transistor. I have the feeling, that this boy is not providing enough current to the sensors, which in addidtion have five meter cables attached...

UPDATE II It is not the current. I replaced the transistor with a mosfet (70T03H) and the result is exactly the same: When switched, only one sensor answers . When I connect the gate directly to a +5V line, I get both values as expected.

Kinda think, that the switching of the pin irritates the bus or the specific device.

UPDATE III (Solution)

I tracked this down to a mixture of

  • Different resolution settings on the sensors
  • my code not waiting long enough to get the sensor with the higher resolution to setup (on-to-read time). Giving the bus slightly more time to setup before any reading is accepted, solved my problem.
4
  • Please add the wiring used. Commented Aug 21, 2016 at 12:22
  • Cable length won't lead to sensor heating but may cause sufficient distortion of signals to prevent recognition of all the devices.
    – JRobert
    Commented Aug 21, 2016 at 12:59
  • @JRobert I know :), but the cable "consumes" current and I beg this is my problem her. Going to heat the iron and report the outcome.
    – moestly
    Commented Aug 21, 2016 at 13:01
  • Or to be more accurate, the current in a long cable could cause a voltage drop (current in must == current out at any point on the bus). But yes, testing with a short bus is a good first step. Also see my (ASCII) schematic for a parasitic bus with strong pullup, in my answer below.
    – JRobert
    Commented Aug 21, 2016 at 13:04

1 Answer 1

1

If you were trying to wire your bus in parasitic mode, here is what I am using:

OneWire Bus in parasitic mode:

+------------+     +5v            +---------+     +---------+
|    MCU     |      |             | DS18b20 |     | DS18b20 |
|            |  R_pu = 4.7K       | g  d +5 |     | g  d +5 |
| Strong-    |      |             +-o--o--o-+     +-o--o--o-+
| Pullup   > o------o               |  |  |         |  |  |
|            |      |               +--|--+         +--|--+
|            |      |               |  |            |  |
|    Data <> o------o---------------|--o------------|--o------ - - -
|            |                      |               |
+------------+                      V               V

I run at least three sensors this way on an approximately 6 meter bus, completely reliably.

1
  • Nice Work. Upvote for that, even If it is not my wiring.
    – moestly
    Commented Aug 21, 2016 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.