DS18B20 Dallas temp sensor question

I am busy with an project where I will be using at least 20 of these sensors in a “One Wire” config.

All my research shows that you can run as many as you want but I cant seem to get the coms stable. I lose some of the sensors a few minutes in. Some forums say that it is a chinese knockoff DS18B20 that I am using and they freeze up from time to time without any reason. To be honest , I dont even know where to look for the originals as all the shops like Micro Robotics are selling the same sensors.

Interim solution is to connect the positive of these sensors to an output pin of the ESP32. Use an Automation to switch off the output for 1 second when a state change in any of the sensors takes place. I use a change from any state to Unavailable. This resets all the sensors and values reappear at the next scan interval and my control loop continues without any interruptions.

Anyone with experience or better solutions? I dont really want to replace all the sensors.

EDIT: I havent played around with Home Assistant for a very long time and decided to rebuild my HA at home. Started from scratch. Everything has changed, but I must admit, it turns out to be so much easier than before. I must compliment the developers of the ESP32 and Tasmota platforms. They have done some serious development and improved their products and integrations so so much. Even guys that knows as little as I do can basically set it up without much thought. I had to phone a friend today to assist in getting Sonoffs (tasmota) back online. My mind was so stuck in the old ways and I tried to still add switches and sensors to .yaml files like I was use to. Nowadays you install MQTT, install Tasmota, create a MQTT user and setup the Sonoff MQTT on the device. HA does the rest. Once it is connected, all the Entities are available out of the box, just add your automations using an “Wizzard” and your done. I am impressed.

Thank you @ebendl for your time earlier today, I appreciate it.

1 Like

According to the documentation, the maximum number of sensors supported by the driver is 8, unless you recompile tasmota with a higher number…

The sensors you can buy from places like micro robotics will usually be fake and these are actually quite bad compared to the real deal. (But not in ways that usually matters unless you are developing the driver or trying to use some of the more advanced features.) If you want the real thing, RS components is probably your best bet, but I think you might have to settle for the bare component then.

On the other hand - why do you need that many sensors on a single device? The boards are cheap - just buy 2 more…

1 Like

I have about 10 boards in the drawer, I guess I could also define different pins on the one board and connect 5 per pin (Might Help), but i saw that even with running only one, that the sensor sometimes freezes and I need to reset the sensor to see the values again. I guess its just cheap sensors and no matter what i try, I will still be faced with the same issue.

I wanted to keep the project small and compact in one place. Been running the system with 10 sensors since yesterday afternoon and so far all seems stable and the control is perfect.

Now I need to find out why the ESP is showing offline on HA even though the readings change every 10 seconds as requested and all the Automations wright to the ESP and controls as expected. I guess there is a “Keep Live” funktion I can use somewhere.

That is indeed what the fake sensors do. In my experience the tasmota firmware handles the fake sensors quite well. Perhaps try a different version? I have a confirmed fake on 13.2.0 working quite well, albeit on a 8266, which might not function the same as an ESP32.

1 Like

Thank you, I will try that. Will flash an ESP32 with tasmota and try and set it up as a a drop in replacement board. I assume the pins will be the same so I can pull out the current esp and push in the new one as a test.

Hi Jaco
The key to reliable comms with one-wire bus devices is to make sure that there is a suitable pull-up resistor (e.g. not more than 1k). This assumes that the controller actively pulls the data line low and then releases it (i.e. high impedance) to float back high. Too many devices and too long a cable adds capacitance that slows the rise time, until the bus doesn’t have time to go high before it is pulled low again. Lowering the resistance will improve the rise time, but check the datasheet for lowest allowable value.
I have used the cheap and cheerful sensors without any issues for many years.

Edit: Also, don’t try the Data + Ground option (2 wires). You need Data + Ground + Supply (3 wires) to work properly without severe limitations.

2 Likes

Thanks a lot. Will try this as well. The normal consensus were to use a 4k7 resistor, but two sites recommended dropping to a 1k when using a lot of them. My board was already installed and all the components soldered into place and I did not want to remove everything again.

I used a three wire cabtyre for testing, thought its the problem and changed over to screened Mylar to ensure no interference can influence it. Did not help, but i stuck to the screened Mylar.

Screened cable is unlikely to be needed, since the bit rate is quite low and there is a fair bit of capacitance on the bus.

Also check that the bitrate setting is not close to min or max values (see datasheet for temp sensor).

I haven’t ever used Tasmota, but have a working ESPHome setup (on ESP32 board + DS18B20) that integrates seamlessly into Home Assistant.

I’m away from home now but could send more info later next week.

1 Like

You can also add a parallel resistor (between supply and data) at either end of the cable. E.g. Adding a 2.2k resistor in parallel would lower the pull-up resistance to about 1.5k.

Thanks, that will make my life a lot easier. Will try it tonight still.

This made a huge improvement. I use to scan every 10 seconds and once a sensor changed to “Unavailable” it would not reset till I remove and reconnect the source. It most cases I would lose up to 6 of the 10 currently used sensors and needed to reset.

After adding the 2k2 in parallel I decided to poll every second to try and force the same fault condition. Now I occasionally lose a value for one scan and its only No1 and No2 sensors. It resets itself and the value returns with the next scan.

Even disabled the Reset automation to make sure its holding up. I will Enable it again and change the conditions to only activate the reset should a sensor remain in an Unavailable state for longer than a certain time.

@FXSuper and @_a_a_a , Thanks so much for the advice.

Use case:

Problem to be solved:

I have three aquariums and my daughter currently have 10 Breeding tanks. A few months back the thermostat on my main display tank failed and I lost 60+ fish overnight as the temp increased to over 33deg. Last week I managed to save a Angle breeding pair when another thermostat failed. A week before we almost lost about 80 breeding females because the heater failed all together and the tank got too cold.

I am on the road a lot with work and my daughter has a hectic school program so we can not monitor our tanks on a daily basis. Loosing all the breeding females can destroy all of her work over the last 2 years and I dont ever want to wake up again to find all the fish that I grew out over 4 years have died.

Solutions

1: Buy High end German heaters with build in protection at roughly R1500 per heater (Not an options as normal heaters are between R160 an R300 and we use to have over 30 tanks running till a while ago.
2: Use all the components that I have been accumulating over the last few years and build something to lower the risk. (Note: I have not spend a cent on this project so far, every component i used was lying in drawers all over. Might look like a mess and a school project, but I decided to use what I have and make the best of it.)

My first test

A system that will monitor the temps of each tank and control the heaters accordingly. Will also receive notifications should the temp in any tank drop below 25 or rise above 29. Should the temp be over 29.5 in any tank a Sonoff POW will cut the power to all the heaters and flood me with alarms and notifications, it will also cut the power to the heaters during a power failure at night as my battery bank is to small to get them through the night. Second Sonoff POW monitor the total consumption of the Fish room.

The ESP will also act as a timer for the lights and control the pump used to fill the tanks from a 1000 l storage tank we use to condition water before refilling our tanks. I plan to add Auto filling to this system in the future where automations will control the filling of the storage tank, allow time for the water conditioning and then fill up each tank automatically when needed. I have never seen any similar systems for aquariums so this is my take on a solution. If any one has some recommendations on improving it, feel free to comment.

I will also be able to monitor and control everything when i am on the road and inform my daughter about any abnormalities.

Daughters little fish room with 10 tanks. Note the single board PC with small screen top right to monitor everything while in the room.

Simple HA display, will still work on using some other add on to improve on this:

High school project, I am sure it can be much neater with the correct components, but i had this and used it.

1 Like

That looks very nice Jaco.

Titbit:
The one thing I learnt in my attempts at automation, and with geysers and Victron it is dead simple compared to your daughters setup, with my son who also has a big huge tank with similar challenges as your daughter, is KISS.

The more components he installed, or I tried to install, the more points of failure.

And o boy, when one gets to it a while later, one cannot always remember why it was done so, if that is a thing you also experience maybe?

For me to KISS, I prefer NodeRED, or your case, HA, is to use Shelly relays and a temp sensors, calibrated, that if the water temp exceeds a set point before the fish is affected, switch off the power to the heater and sending warnings.

Like Victron, I suspect Shelly is also quite robust for critical systems.

Just a thought, as components fail going forward, consider if the Shelly idea may work for you guys.

1 Like

I have already started looking at more reliable equipment should stuff start to fail. For now it was a test / proof of concept kind of idea and I did not have to spend a cent as everything was on hand. I did not want to go overboard and buy a bunch of new components for this. I am aware that it is all cheap components from hobby shops and reliability might be an issue in the future.

1 Like

Agreed. I do the same, use what I have, learn, then upgrade carefully with WANT, NEED and HOBBY kept in mind at all times, with KISS foremost above all.

It is a impressive setup, I must re-iterate.

Bit off topic. I had specific fish I hoped would breed. Have them for almost 2 years and they were not interested in breeding up till now. By doing the above, I could ensure that the temperature is stable at the required level and that resulted in 3 breeding pairs producing almost 800 eggs in a few days after implementing the new control system. Some even started hatching and the rest has been removed to the hatchery to ensure that the inexperienced parents and other tank mates don’t feast on the eggs and newly hatched fry.

Maybe just coincidence, maybe not.

Well my few days off is coming to an end today and we are in full operation again. Maybe I will find some time to refine this system in the evenings.

3 Likes