
Your DS18B20 temperature sensor is likely a fake, counterfeit, clone - 0x402DF854
https://github.com/cpetrich/counterfeit_DS18B20
======
kregasaurusrex
Trust in hardware supply chains when manufactring a PCB for a product can be
quite fragile: when one component operates outside of spec, the entire device
could be rendered useless. In the case of the DS18B20, the author states in
the 'Warning' section that the primary way of determining counterfeit sensors
is to check the ROM output compared to a known format. When counterfeit parts
like this are added, it creates vulnerabilities in the entire system due to
the ability for a bad actor to leverage this vulnerability and cause one part
in an entire system to fail.

For example, the company FTDI snuck in code that was in a series of Windows
updates that was able to detect counterfeit FTDI and brick them via software
to send back all 0's.[0][1] This anti-consumer behavior on behalf of comapnies
can a be a headache for end-users and programmers alike.

[0] [https://hackaday.com/2014/10/22/watch-that-windows-update-
ft...](https://hackaday.com/2014/10/22/watch-that-windows-update-ftdi-drivers-
are-killing-fake-chips/)

[1] [https://hackaday.com/2016/02/01/ftdi-drivers-break-fake-
chip...](https://hackaday.com/2016/02/01/ftdi-drivers-break-fake-chips-again/)

~~~
robomartin
> This anti-consumer behavior on behalf of companies

I strongly disagree with this. I see no way to rationalize that a company
should be responsible for ensuring that counterfeit devices work correctly by
releasing drivers that are tolerant of them or do not stop them from
functioning. FTDI's products are the combination of their hardware with their
drivers. Both are required in order to delivery functionality and reliability
to meet their specifications.

Imagine your drivers are used in some sort of a critical application and a
counterfeit device causes a failure that, in turn, causes harm to someone. An
example might be a wired remote control for an industrial machine. It seems to
met that bricking that device as soon as possible before harm is done is what
we would want from a company that delivers a quality product.

Another way to put it is: Let the counterfeiters engineer a real product and
be responsible for their own drivers, quality and safety.

The way to see clearly through some of these problems is to extend the
definition towards extremes. Let's forget FTDI for a moment and generalize the
problem to a microprocessor and a vendor-provided RTOS used to run the flight
system of an airliner. This is a contrived hypothetical, forgive me for taking
artistic license.

Imagine counterfeit processor make it into the supply chain. Should the
avionics OS do its best to work with every possible fake or should it brick it
on power-up before that potentially dangerous aircraft gets off the ground?

Another hypothetical could be one where we eliminate hardware completely.
Imagine someone creates a fake Amazon, Facebook, NY Times or online brokerage
site. Imagine proposing that the real companies would be anti-consumer if they
created software that revealed the impostors. I could not imagine anyone who
would propose they allow the fakes to continue to deceive consumers.

From my perspective this isn't anti-consumer at all. It's as pro-consumer as
you can get: You work hard to ensure quality, consistency, performance and
reliability.

The real anti-consumers are the counterfeit manufacturers. They, quite
literally, could not care less. All they care about is tricking engineers and
consumers into thinking they are designing and buying a quality product when,
in reality, they might be dealing with dangerous junk.

~~~
LeifCarrotson
I agree that anyone who built a device and knowingly used a counterfeit FTDI
chip deserved to be punished.

However, the FTDI debacle didn't punish those people, they're not the
consumers. It punished end users who have no idea what an FTDI chip is or does
or that one exists in the products they buy.

In your airliner microcontroller example, you have much more informed
consumers. They could reasonably be expected to know what processor is in
their hardware, and to want to validate it. That's not the same.

It would be more like a good packaging manufacturer finding that their
packaging was being counterfeited and their proprietary plastic blend was
somehow being leaked up the supply chain. If they changed their recipe to
something toxic, but using good plastic internally, and when people started
dying said "they should have bought potato chips packaged in genuine
FoodSafeStuff bags". People don't know what their packaging is made from or
who it's made by. They have no way to verify it prior to purchase, and even
after purchase, it would take an expert to identify. And there's no customer
loyalty based on the plastic bag, after the food manufacturer switches away
from the counterfeit they won't be significantly harmed. But everyone who
innocently bought those bags and got poisoned suffered real harm.

~~~
toohotatopic
>People don't know what their packaging is made from or who it's made by. They
have no way to verify it prior to purchase, and even after purchase, it would
take an expert to identify.

For food, you can't change the game without prior notice, but if it is clear
that faked goods are toxic, people would start buying from trusted providers
themselves. For electronics, I don't see a problem. If a device is bricked, go
to your dealer and let him replace it. He will do the same for his supplier,
etc.

Somebody in the chain will discover that his supplier is a fraud. He will have
to swallow the costs, but has learned a valuable lesson.

If people have brought the product from some unstable source, then they most
likely got it cheaper and they are now paying the price for the increased risk
they took. It doesn't feel good but I don't think that it is unfair.

~~~
pastage
The counterfeit FTDIs are ok. How drivers are created is a much bigger
problem, the windows model specifically where hardware takes a long time, if
ever, to be included in the default installation.

Getting hardware to just work on windows was a mess (not sure if they have
corrected this).

------
as-j
This affects temperature sensors/parts bought from un-official distributors
like ebay or AliExpress, not digikey, farnel, etc. Perhaps I've been too lucky
in my career and practiced EE for work, but who would you ever go to ebay
instead of digikey?? <mind blown>

Digikey certainly has a premium, but their speciality is small numbers/cut
tape/etc and they have a small order size which makes them ok for hobby work,
and I've used them for small production runs when I didn't want to end up with
a ton of excess materials.

Makes you wonder what other junk is out there, and what purchasing guy figured
he'd save $10 and get it from ebay...?

~~~
myself248
I'd never expect to find these in official products from trusted brands, but
off-brand crap? Oh yeah. DIY kits? Absolutely. The parts drawer at the
makerspace? One hundred percent.

So much stuff on eBay is free shipping, that's huge when you only need a few
dollars worth of stuff. If I could convince Digi-Key to lick a 55-cent stamp
when I need ten of something, instead of charging me $7 for shipping, I'd have
a lot fewer counterfeit parts around.

~~~
IgorPartola
This. I buy a decent amount of hobby electronics from eBay and AliExpress
because yes it is cheaper. When I need quality, Mouser, DigiKey, and McMaster-
Carr are there for me. But the minimum $7-9 shipping is the main reason is
forego them. I’d gladly pay 2x for small electronic components (vs directly
from China options) if shipping wasn’t a problem.

~~~
fermienrico
For any serious person trying to develop a little bit beyond hobby projects:
Think about an hourly rate of $80/hour for yourself. If you have to spend an
hour trying to fiddle with subpar shady parts, you've already paid for the
shipping 8 times over.

Also, it is painful to wait for these packages from China. Digikey ships same
day and its at your door step in the morning (I overnight it) and if you use
$7, it is usually 2-3 days.

Plus, you're supporting legit businesses and not the shenzhen market.

I can understand total hobbyist who cannot afford $7 shipping often. But even
then, you can bundle all your parts and order once.

Any engineer who earns a salary _can_ afford $7 shipping. If you're a
business, there is absolutely no excuse to penny pinch here. You're losing
money by using unreliable parts, if not now, at some point in the future.

~~~
fpgaminer
> But even then, you can bundle all your parts and order once.

I fall for this trap every. single. time.

_HOURS_ spent racking my brain to think of all the things I might need in
different scenarios, so I can be absolutely, positively, 100% sure that I have
everything in that one single order.

... and end up placing 2 to 3 more orders before the project is done.

~~~
fermienrico
Hahaha I can totally relate. Always ends up being a few packages.

------
tzs
I've got one genuine one that I bought from Sparkfun near the end of 2015 and
10 more I got from Amazon in the middle of last year.

I haven't gotten around to doing anything with the 10, but the genuine one has
been hooked up to an RPi for a while, which is controlling a space heater.

That was still using a solderless breadboard, so it was an easy matter to swap
in the 10 one by one and check if they were genuine. As was probably to be
expected, they are all counterfeit.

They all seemed to be fairly consistent with each other and with the genuine
one, although it turns out that these things are really sensitive to body heat
--just holding one pinched between two fingers while slightly spreading the
leads to fit the breadboard would heat it up 2-3 C. This made comparing
different ones a bit confusing.

The genuine one seems to cool back down to room temperature noticeably faster
than the counterfeits. I wonder if the genuine ones take more care to ensure
that the die is not too insulated from the outside world so it will be more
responsive?

Anyway, since I'm still using a solderless breadboard, and then things are
designed to chain, it was not hard to rig it up so all 11 are hooked up at
once [1]. (And yes, the resister is hooked up correctly. It is just a really
bad angle in the photo that makes it look like it is off by one).

I've got a program running now that checks them all periodically and logs all
the readings. Here are results after it has been running about 20 minutes:

    
    
      22.437 [22.375, 22.25, 22.187, 22.312, 22.375, 22.187, 22.25, 22.25, 22.375, 22.25]
    

The first one is the genuine one, and the array are the counterfeits.

[1] [https://imgur.com/a/jPBTrvJ](https://imgur.com/a/jPBTrvJ)

~~~
0x402DF854
I remember reading somewhere that genuine ones have a sensing element anchored
to the ground pin, so it might explain why it cools down faster when inserted
into a breadboard

------
Teknoman117
There's so much fake stuff on eBay in the IC world. As someone who was looking
to get into the retro electronics hobby, I'm bumped into a ton of fakes on
eBay. I'm amazed that there are sellers in China who find it worth their while
to fake "ancient" chips like the Intel 286 and Motorola 68040 and 68060. In
the former case, they took lower speed parts and rebadged them as higher speed
components and in the latter case, some are downright fakes that don't
function.

~~~
TazeTSchnitzel
A lot of chips are harvested (in horrifying conditions for the workers and the
chips) from old electronics and then retopped.

------
lnsru
Once I was working for a company having single Motorola 68K based design. They
were selling their ancient design without changes for decades. Motorola 68K
disappeared from market, they moved to Coldfire, but then peripheral chips got
obsolete. It was a big problem. Junior boss started buying everything he could
find in Chinese Internet stores. Everything was fake!!! Sometimes parts were
empty shells, no silicon inside, some parts were rebadged modern parts, some
parts had silicon inside, but weren’t functional. Solution was found using
some shady brokers. They delivered parts at 50x price. Ancient real time
clocks were bought for 100$ a piece. It was still better than not delivering
products to final customers. Re-Design was started porting the design to
Xilinx ZynQ, but I left. Lesson number 1: no Aliexpress parts in final
products! Lesson number 2: obsolescence of parts is a big deal, it comes more
often than one is prepared for. Lesson number 3: even for hobbyist Digikey or
Mouser is a place to go. Free shipping to Germany buying for at least 50€. All
parts worked as expected.

~~~
varispeed
How is it even possible to sell products with these parts if you are unlikely
going to get RoHS certificates? That's like asking to go bankrupt.

~~~
lnsru
These guys did other shady things balancing between unethical and criminal. I
guess they would just deliver products with fake parts expecting to replaced
them by redesigned ones in the future.

------
0x402DF854
I've bought ~100 of these sensors from ali and ebay and 9/10 had troubles
reporting temperatures in passive mode reliably. However simply repeating
requests until sensor reports a valid value (!=+85C and !=-127C) works fine.
Rarely I've seen sensors not working in passive mode at all.

Still, I always recommend running an extra +VDC wire (3 wires vs 2 wires isn't
a big inconvenience). When running large 1-wire buses (>100m long, dozens of
sensors each), a dedicated power line is always a must.

Another funny use for these sensors is a source of nonce/id. Weirdly, every
single DS18B20 I've bought had a unique ROM address, even when I got large
batches. I still PTSD about that batch of PCIE network cards with identical
MAC addresses...

~~~
metaphor
> _However simply repeating requests until sensor reports a valid value
> (!=+85C and !=-127C) works fine._

You _know_ you're dealing with counterfeits and you _know_ they're unreliable,
but you've somehow convinced yourself that despite all the uncovered variance
sitting on the table, if you keep poking long enough until the component
returns some non-edge-case value, then it "works fine".

I must have hopped on the sanity train quicker than I should have because it
seems like I'm missing something critical in the narrative here.

~~~
yjftsjthsd-h
> You know you're dealing with counterfeits and you know they're unreliable,
> but you've somehow convinced yourself that despite all the uncovered
> variance sitting on the table, if you keep poking long enough until the
> component returns some non-edge-case value, then it "works fine".

Yes? Because it usually does? If you test a bunch of fakes and they tend to be
either basically accurate xor really inaccurate, and your project isn't super
critical, why not? It's like unit testing; if you trust your tests, then any
function which passes is probably fine to use. I wouldn't do it for something
mission-critical, but for fun hobby stuff I probably would.

~~~
metaphor
"usually"..."basically"..."probably"...that's a lot of handwaving. Your
usecase is both your prerogative and your folly to embrace; that's not the
point.

I poke fun at the OP because his qualifier for "works fine" is an
indeterminate definition of _eventually_ establishing some semblance of
compliant 1-wire communication with a counterfeit component without even so
much as batting an eye to question the accuracy of the _sensor measurement_
being read in, let alone:

    
    
      a) environmental constraints
      b) electrical constraints
      c) timing constraints
      d) system integration considerations
      e) counterfeit variance/unpredicability
    

No, this is not even remotely asymptotic to the implications of software unit
testing. This is _physical hardware_ which manifests real variance "vetted" by
some half-baked functional "test" that completely ignores every parametric
spec without discrimination. Without questioning implementation merits, your
software unit tests operate on hash-replicable code...at the silicon level,
such a luxury doesn't exist.

~~~
yjftsjthsd-h
I think the difference here is that you're taking this from the perspective of
an actual engineer, and I'm a hobbyist (and I assumed the same of OP; I _hope_
Real Engineers aren't getting parts off eBay). Which means that, yeah, I'm
happy to handwave a lot. By software analogy, I write a lot of shell scripts
and python, which is passable but hardly rigorous; if I wanted it to be
Correct, I'd break out coq or write in Ada or something, but I just want
something that usually works because the stakes are so low. Of course
counterfeit parts aren't reliable, but if failure _is_ an option then they're
good enough.

------
jerkstate
Wow, I am pretty sure I had some of these, parasitic power would NOT work, I
had it on a scope and everything. What a pain in the butt that was! Why not
just give these mostly cloned parts their own honest name and part number?

~~~
nullc
> Why not just give these mostly cloned parts their own honest name and part
> number?

Would you have bought it, at the same price, if they had?

~~~
MaxBarraclough
To put that another way: the reason they go the fraud route is to easily
profit from the good reputation of an established brand.

------
panitaxx
I buy from AliExpress and eBay not because of the shipping fee but because
most of the time digikey/mouser doesn't sell hobbyist friendly form factors
(like breakout boards) and some of this ic come in really tiny package (like
tssop) which for an amateur are difficult to solder. Sometimes they need a
resistor or a capacitor or a transistor easier to buy a board with everything
on it that you stick to another board and that's it.

~~~
0x402DF854
That, or they slap huge markups for these otherwise unpopular products.

Try to find a popular 16-bit ADS1115 ADC on digikey. They offer SMD 10X2QFN
chip for $8, 10VSSOP for $10, assembled adafruit board for $22 (!!!) or
DFRobot board for $15 (exact same board is half the price on ebay).

In comparison, ADS1115 boards from aliexpress are $2.

------
ChrisMarshallNY
Counterfeit chips are a huge problem, these days.

I suspect that a significant number of Bluetooth chips are fake; even in very
expensive kit.

I got tired of having expensive headsets croak after less than a year, while
my cheap 20-dollar exercise headsets lasted for four years.

~~~
kregasaurusrex
Chips have a higher value on a BOM, and as such have more financial incentives
to be reverse-engineered and counterfeited. This is a bit more interesting
since it's a sensor that has several operating parameters that "sort-of" send
expected data back, but depending on the operational characteristics could
need to be recalled entirely.

~~~
ChrisMarshallNY
Especially if they are to be used for something like monitoring for excessive
heat in some kit that could catch fire.

~~~
kregasaurusrex
If this was used in a BMS with a lithium battery, a counterfeit sensor's
behavior could result in the total loss of a device. Let's say the device's
PCB is designed such that the sensor is connected to a rail that requires
parasitic power, and you were unexpectedly shipped the D1 variant that outputs
garbage data back to the onboard firmwre instead the proper temperature. Your
company would have to recall every device in that manufacturing run at great
expense, if it weren't caught early enough by QA.

~~~
0x402DF854
This particular sensor isn't used in mass produced devices AFAIK. NTC
thermistors are cheaper and easier to design for using cheap analog
components. Reading DS18B20 is quite an exercise when it comes to $0.05
microcontrollers used in e.g. household appliances.

~~~
kregasaurusrex
That's true in an analog design, I recently took apart a generic computer
power supply that failed and noticed it used NTC thermistors. In a hobbyist
kit I purchased that came with with various cheap sensors, the temperature one
has a Dallas 18B20 on a board to be interfaced with an Arduino. It's probable
that some people would just duplicate exactly what they used on a quick-and-
dirty design to be deployed on a small scale.

------
unnouinceput
I don't get it. Why bother faking something that is very cheap to make
genuine? I mean you pay peanuts for real deal, and you want to make something
even cheaper then that?...why? Where is the profit?

~~~
ajnin
First, when you make millions of a thing, then saving even fractions of a cent
add up to a lot of money. Chinese manufacturers favor high volume, low margin
products. Second, Maxim parts are not cheap, in fact they are among the most
expensive in the IC industry. A single DS18B20+ goes for 3.47€ on Mouser right
now. That's a juicy target for counterfeiters.

~~~
unnouinceput
I don't know where you are, but in my country I paid the equivalent of 4 cents
for DS18B20. I hook it up to my multipurpose Raspberry Pi and I use it to
measure my room temperature. I bought 2 of them, for redundancy reasons when
lockdown started. The other one is still in original package.

------
sfgweilr4f
I buy all sorts of fine parts off ebay/aliexpress. A lot from China. No issues
so far. All work within expectations. But I'd never base a product on any of
them. Nor go fine tolerance / high expectation either. Not without very high
trust. There is such a thing as a savvy* buyer who has a suspicious and not
naive mind.

Then again, hardware is a hobby for me. My level of "buyer beware" means a
slew of parts cannot be purchased from ebay so maybe that is a factor?

I can't fathom anyone using ebay for serious products that would be sold to a
supported customer with any kind of actual warranty. The mind boggles. I have,
however, dabbled with alixpress and found speaking Chinese useful to the
extent I made a short run of my own gadgets with humble success. No I'm not a
hardware company. Just had an issue that needed a gadget so I made it happen.

* No flash memory or any similar memory devices. No FTDI gadgetry. No battery of any kind. Nothing that involves oddball power supplies. I parts bin any power supply "ebay-direct-from-China" as I don't trust any of them.

------
esaym
>If the ROM does not follow the pattern 28-xx-xx-xx-xx-00-00-xx then the
DS18B20 sensor is a clone

Darn, my sensor from usbtemp.com has 28 FF EC C5 21 17 04 99

------
ggm
Ethics aside, are they accurate enough for e.g. home brewing or fishtank
usage, compared to parellax reading error on a traditional mercury/alcohol
thermometer?

~~~
asddubs
depends on what fake you get, based on the linked article. seems like for the
most part yes

------
6nf
Off topic but... how do you do IO on a chip that only has 3 pins? I assume you
need one pin for V+ and one pin for Ground and then there's only one pin left
for both I and O?

~~~
codys
As exmadscientist noted, these use the 1wire bus.

The general mechanism (to use 1 io pin as both an input and an output) though
is to have the io-pin operate in "open collector" mode. Essentially: it
assumes that there is something external "pulling up" the io _line_ (normally
a resistor attached to the positive logic level), and all devices attached to
the io-line only "pull down" (ie: output the 0 logic level, normally 0v) on
their io-pin. The io-pins, thus, have 2 states: low (ie: 0v), and hi-z (high
impedance, ie: not driving the output in any direction)

This ensures that no device on the io-line will directly push/pull against the
level being driven by the other device (because all devices only drive 0v, and
none drive the the logic 1 level, they rely on the pull up).

Then to allow communication to occur reasonably (without both ends pulling the
io-line low all the time), buses like 1wire specify how the devices decide
which one "wins" (ie: gets to transmit it's data), or which one goes first, or
which one directs the other devices to "talk".

------
rootsudo
Same as most USB to serial adapters, Prolific (PL2303) and FTDI FT232RL.

What's fun is one of them updated a driver, which bricks counterfeits.

[https://hackaday.com/2016/02/01/ftdi-drivers-break-fake-
chip...](https://hackaday.com/2016/02/01/ftdi-drivers-break-fake-chips-again/)

~~~
panpanna
I sort of understand how the FTDI thing happened. They were charging an arm
and a leg for an ancient IC, so China cloning it was really a no brainer.

Thankfully, 1-2 companies came up with their own competing solutions which you
now can buy for cents. If you are still using FTDI chips (fake or original)
you might want to update your designs.

------
Avamander
There's the same issue with nRF24L01+ radios that are very widespread.
Unfortunately, the fakes also have errata and cause problems when people try
to use them.

------
andi999
I am a bit disappointed about that a lot of his claims how to identify clones
are referenced with [5] own research. I mean doesnt one need confirmation from
the IP holder?

~~~
fake-name
I mean, the entire article is basically documentation of that research.

This isn't a peer-reviewed piece of work, it's a writeup of someone's fairly
exhaustive research into a problem they encountered.

I don't see why you'd need confirmation from another person that something you
bought doesn't do what it's part number claims it should.

~~~
andi999
Maybe I didnt read it carefully enough but to me he does not research it but
just states it. I mean some (non counterfeit) production runs might not have
the expected quality isnt this possible? If the rom signature is not garanteed
by the ip holder than it still might be legit.

Probably he is right though, but to me it reads like the conclusion is the
premise. (Might be due to the writeup though)

Edit: here is my bone: it says: how do I know? If the ROM does not follow the
pattern 28-xx-xx-xx-xx-00-00-xx then the DS18B20 sensor is a clone [5]. And
here I would have expected [5] to be the datasheet or something, but not 'own
research'. The idea of citations is also to make your claims more verifiable.

Now, if we look at the Datasheet:
[https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf](https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf)
it actually says:"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. A detailed
explanation of the CRC bits is provided in the CRC Generation section." So the
28 is required. The '00-00' part is ust the higher bits of the unique serial
number.

I wouldnt be surprised if different factories get different higher bits.

------
panpanna
Well, the original components costs 1-2 dollar when bought directly from
Dallas but you can buy 10 PCBs (with additional supporting components) for $3
on AliExpress. It was extremely obvious to everyone that these were fakes.

But... while I fully understand the ethical issues, there is also an
interesting engineering challenge here were you can sometimes get your design
to work even with crappy fake components.

Btw, if you think this is bad, try ordering some jfets from China...

------
Faaak
Not an excuse, but when you compare the relative simplicity of these sensors
compared to their retail price 2$+, I can see why they would be cloned

------
VLM
In the old days if you wanted sweepings from the factory floor you shopped at
Radio Shack. Usually worked well enough anyway. Just like ebay or amazon
today, usually.

I've had worse luck with assemblies than components; switching supply modules
from ebay / amazon don't come with decoupling caps or RFI inductors or RFI
chokes.

------
amelius
Only slightly related but why do manufacturers have so much trouble printing
the type and or value of the component onto the package? Often it's not even
readable with a magnifying glass unless the lighting is from exactly the right
direction.

------
amadeuspzs
I just ordered a bunch of these, yesterday, from Farnell.

I've received fake electronics from 3rd party Amazon sellers and eBay.

For testing a PoC I will buy knowing there is a risk it's likely fake - but
once I've validated a design I'll go to Farnell.

------
Fej
I have one of these, purchased from Adafruit - they're not an authorized
distributor but they're certainly reputable. My unit works fine but I haven't
tested it yet... anyone else bought from them?

------
LyndsySimon
Anyone have an idea what these are used in? I originally thought they might be
used for 3D printing, but that doesn’t seem to be the case - except, perhaps
for chamber temperature.

~~~
hannibalhorn
I have several for homebrewing - monitoring mash, sparge, and fermentation
temps.

~~~
jcims
I have a bunch for a related process. I don’t need them to be super accurate
but they should be consistent and repeatable and the ones i have definitely
are that.

------
edf13
Any cached version of this page since Github is down?

------
djmips
These acerbic comments make me feel like on Hackaday instead of Hacker News.

