DS18B20 - the most popular temperature sensor among Arduino users.
A use them a lot in my projects.
What I did not expect, is to find a fake sensor that actually works.
Well, let me explain why your sensor might be fake
and why you need to use the real one.
Well, Let get started.
Hi, guys welcome to electrical projects channel, for those who new, DS18B20 is a digital temperature
sensor, it uses just three wires, two for power and
one for data, and the awesome part is, you can connect multiple sensors in parallel,
and this is possible because each sensor has a unique address, and this allows to read temperature
from each sensor independently, even thou they connected to the same three-wire bus.
I have 5 of them.
Inside, Outside,
In the attic, In the basement,
and one measuring heating system temperature.
As you can see my network is pretty big,
and in such a big network a fake sensor can cause a lot of troubles.
Well, first I want to show you that both sensors actually work.
The real one works… and the fake one works as well.
But don’t be fooled.
Now let me show what happens when I do the same on my big network that has 5 sensors.
Here on the phone, you can see real-time date from all sensors.
It updates every 2 seconds.
Let’s try the real one, and nothing happens network works.
Now let’s try to connect the fake one.
And everything stops working completely.
After disconnecting everything goes back to normal.
Now let’s see what is going on with sensor’s addresses,
Let’s connect the real sensor first, and we see one more sensor detected we see its
address and temperature readings.
Now let's try a fake one, no new addresses detected but other sensors start to show -127,
which means an error, the fake sensor disrupts all communication on the bus, but that is
not all... if I disconnect all distant sensors it starts to work without errors.
Now I only have two sensors connected, one that measures the temperature inside,
and this fake sensor, so if you have a short bus you may not even notice a fake sensor, everything
But if I connect other sensors I have only errors, no temperature reading at all.
But even after all this I couldn’t fully believe that Chinese manage to fake a pretty
complicated digital sensor, previously I thought if it is fake it will not work at all,
but I was wrong.
So after some research, I’ve built a fake sensor tester, link to the code in the description.
It turns out that Chinese did not implement all features of the sensor.
From the first lines of the datasheet, we can see that the sensor provides 9-bit to
12-bit resolution, and it is not true for the fake sensor.
Also, it should have an alarm function with upper and lower trigger points, and it also
not true for the fake sensor.
Also, we can see that depending on the resolution we should have different temperature conversion time,
and it is not true for the fake sensor.
So here is my fake sensor tester.
Here you can see that it sets different resolutions,
and then checks what resolution sensor currently using.
The normal sensor should support, 9, 10, 11, 12-bit resolution.
Then tester writes arbitrary values in alarm trigger registers.
On the line below we can see what we read from those registers.
And the last line is time conversion, it depends on the resolution
and should be close to what we have in the datasheet.
Now let’s connect the fake sensor and see what we get.
First of all the fake sensor doesn’t support, 9, 10 – bit resolution.
And second, as you can see it doesn’t matter what we write to alarm registers
we always get 255.
And the last inconsistency is the time conversion.
The fake sensor is actually extremely fast, it requires only 35 milliseconds to do temperature
conversion.
The real sensor needs almost 600 ms, so it is 17 times faster at 12-bit resolution.
Which is actually pretty damn good.
With the real sensor you can get less than 2 readings per second, but with the fake,
you can get 28 readings per second at 12 –bit resolution.
It sounds pretty good, but it actually doesn’t matter,
because this Chinese crappy sensor is not precise.
So if you actually need speed then it is to use the original sensor at 9- bit resolution,
you will get about 13 reading per second but you can be sure about its accuracy, and what
is even more important you will get reliable communication without errors.
So what about you guys, have you ever got a fake sensor?
Is your one wire bus stable?
Tell me about your experience.
And that is all for today.
Thanks for watching.