OneWire 2 devices

The idea is to use DS18B20U and DS2401 on the same wire (ESP12, pin IO0). On that line I have a 4.7K pull-up resistor.
The DS2401 can work only in setup as obviously it doesn't need to work in loop. But the temperature sensor should work all the time.

I tried both devices separated and both works.
Libs I used:

When both connected, the DS18B20U works. The 2401 does not.

Any idea what is wrong? Can those two different ICs work on the same wire?

The problem is either in the sketch that you did not post or the project schematic that you did not post or possibly both

Please post them

1 Like

The DS18B20 has it's own 48 bit serial number, so why the need for a DS2401at all?

Two data lines connected to the IO0, with a pull-up resistor. I can make a schematic if you need. But it is so simple circuit. If those devices are separated, if I try them one by one, both works, one by one. When both are connected to IO0, only temp sensor works. The DS2401 throw this error with the lib example:

CRC Not Valid!!!

Examples are from the libraries I provided. There is no sketch of my own.

I didn't know that.

Does any of the lib examples get this nr? According by the names of the examples, none does it. I might be wrong...

Yes, some of them do, but just to confuse you they call it 'Address' in the library terminology.

The one I have used for the following example is 'Multiple' in the DS18B20 library:

Screenshot 2023-03-25 130907 DS18B20

(I modified the sketch slightly to print the leading zeros of the HEX bytes).

1 Like

From the DS18B20 Datasheet:

64-BIT Lasered ROM code
Each DS18B20 contains a unique 64–bit code (see Figure
8) stored in ROM. The least significant 8 bits of the ROM
code contain the DS18B20’s 1-Wire family code: 28h. The
next 48 bits contain a unique serial number. The most
significant 8 bits contain a cyclic redundancy check (CRC)
byte that is calculated from the first 56 bits of the ROM
code.

According to the DS2401 datasheet:

Read ROM [33h]
This command allows the bus master to read the DS2401’s 8-bit family code, unique 48-bit serial number, and 8-bit CRC. This command can only be used if there is a single DS2401 on the bus. If more than one slave is present on the bus, a data collision will occur when all slaves try to transmit at the same time (open drain will produce a wired-AND result).

A similar statement appears in the DS18B20 datasheet:

Read Rom [33h]
This command can only be used when there is one slave on the bus. It allows the bus master to read the slave’s 64-bit ROM code without using the Search ROM procedure. If this command is used when there is more than one slave present on the bus, a data collision will occur when all the slaves attempt to respond at the same time

I see.

Somehow the temperature sensor works when connected together with the DS2401. But the DS2401 does not. Can this be solved somehow?

in re. ROM code --
If they are Genuine.

Counterfeit DS18B20 do not conform.
I have some of these that worked fine with an Arduino sketch that ignores the ROM check (but not with RP2040 programs - that are dependent on it).

The libraries I'm familiar with use the search algorithm described in this application note:
One Wire Search Algorithm
to determine the addresses of multiple slaves on the bus.

Do you suggest some other libs?

This is the one I've used in the past:
OneWire Library

Use search to build an array of the slave addresses on the bus.

Official Arduino Docs

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.