Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

DS18B20 sensors

Status
Not open for further replies.

Wp100

Well-Known Member
Hi,

We have a working project with 5 Ds18b20 sensors, each on their own IO pin, so if any one failed a new one can simply be plugged in, and away we go.

If an update to the project, formerly a Nano, now to be an ESP32, we are looking at using a single daisy chained line for all of these sensors, ( 3mtr max length) but looking at various software options, we have to connect and read each sensors ID and manually enter that into our code, which would be a problem when the working project is not near the PC etc.

So it raises two quesions, first how reliable are these pre wired metal encapsuled DS18b20s ( far east clones ??) and is there any software that would automatically modify the program code if a sensor was replaced in the daisy chain ?
The program is very slow running in that there would be plenty of time to read all the sensors ID on every program loop.
 
Any 1wire chip has an individual ID.
I would read out all ID's and store it into a EE-Prom space of Your Controller.
You can do this at any reset of the controller.
Check if the ID's are known to avoid useless EE-Prom writings.
Additional You had to make a Allocation Table what sensor measures temperature at what place.

You can do this with an single tactile switch:
Remove all DS... - Press switch ( Allocation Start ) - Plug in first DS... in chain - Then one after the other of the Chain.
Check if all sensors are allocated right.

When one Chip failed, You have to repeat the whole procedure.

That's the cause why I don't want to use this Chip's.

To access the 1wire chips free You can use a display ( e.g 2x 16 Character display ) and make the allocation with a few tactile switches there.
So You can replace a single chip too.
 
I've found the one wire chips to be pretty reliable - not had one fail yet. I have a product that uses 16 DS2413s and use the SearchRom to get there IDs. I also did a DS1820 to PC board that had the SearchRom function in Assembly. When it was a post it was all there but then it got converted to an article and lost all the discussion. https://www.electro-tech-online.com/articles/one-wire-temperature-sensor-ds1820-to-pc-interface.12/

Mike.
Edit, the original discussion was far more valuable than this "article", is it still available?
 
To figure out the IDs is not the problem.
This function is nearly in any IDE.
But when You want to use more measuring Chips of the same type ( = same Type ID ), The Controller has to know what values are measuerd at any chip.

e.g. 5 DS18B20 in 5 Rooms on a single chain.
Witch ID measures witch Room?
That You have to allocate, when it should be useful.
 
When I used three DS18B20s for temperatures at different heights in a hot water tank, I didn't bother sorting out which DS18B20 was in which position. I just took the highest temperature reading to be the physically highest, etc.

As others have mentioned, there are a lot of ways of finding out and storing all the IDs. You can compare the IDs with what was stored previously, so you would know that identification is needed if any have changed.

The best method depends on what operational procedure or other circumstances apply for you. You might want a button to learn new ones, or there might be some way of identifying each in turn from the temperature profile.

You could have a routine like this:-
If the stored IDs don't correspond to the searched ones, or there aren't exactly 5 searched IDs, go into a calibration mode. (You should have a few tries and several seconds of the wrong IDs before going into calibration mode)
In calibration mode, wait until exactly one ID can be found. Store it as being the first.
In calibration mode with the first ID only stored, wait until exactly two IDs can be found. Store the newcomer as being the second.
In calibration mode with the first two IDs only stored, wait until exactly three IDs can be found. Store the newcomer as being the third.
In calibration mode with the first three IDs only stored, wait until exactly four IDs can be found. Store the newcomer as being the fourth.
In calibration mode with the first four IDs only stored, wait until exactly five IDs can be found. Store the newcomer as being the fifth, and leave calibration mode.

You could easily make the system where it could be powered off between each learning of IDs, if that helps.

As long as the user can tell if the system isn't working, nothing else would be needed. If the system stopped working, the procedure would be to disconnect all but the first sensor, and then connect one at a time until it worked.

An indication that a new sensor had been found would be needed if the user can't otherwise tell which sensor is faulty.
 
An option is to add a 1-Wire switch at each node, that connects the rest of the chain. I believe the switches power up in the off mode.

To map ID's to positions, power up the chain. You'll see 2 devices, a temperature sensor and a switch. This is the first node in the chain. Close the switch. Two additional devices appear, the second node in the chain. Repeat until no more devices are found.
 
Thanks all, will have to get busy coding ! :)

Am using this type of DS18B20 to measure air temperatures, just that they are pre wired, sealed and readily available for us and others to use.

.jpg
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top