vktech ds18b20 waterproof temperature sensors

Hello everyone,

i've bought the vktech ds18b20 waterproof temperature sensors.
I tried to follow some tutorials on the subject but i can't get the temperature output and the serial monitor return always the value of -127.

Now this is how i have connected the sensor to the arduino board:

red wire of the sensor to the 5v arduino power

black wire of the sensor to the ground

yellow wire to a digiatal arduino pin.

this is the code used:

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

// Il terminale data del sensore è connesso
// alla porta 2 di Arduino
#define ONE_WIRE_BUS 2

// Imposta la comunicazione oneWire per comunicare
// con un dispositivo compatibile
OneWire oneWire(ONE_WIRE_BUS);

// Passaggio oneWire reference alla Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// RS EN D4 D5 D6 D7
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup(void)
{
  // Start up the library
  sensors.begin();
  // Imposta il valore di righe e colonne del display LCD 
  lcd.begin(16, 2);
}

void loop(void)
{ 

  sensors.requestTemperatures(); // Invia il comando di lettura delle temperatura
  lcd.clear();
  lcd.setCursor(0, 0); // bottom left
  lcd.print("Temperatura di: ");
  lcd.setCursor(0, 1); // bottom left
  lcd.print (sensors.getTempCByIndex(0));
  lcd.print (" C"); 
}

I'm missing something?

One thing i noticed is that while i use the vktech ds18b20 waterproof temperature sensors, in the tutorial i found here (Sensore DS18B20 - Utilizzo con Arduino) there is a picture of the IC ds18b20. Is this IC located in the vtech sensor that appear in the picture? https://www.amazon.com/Vktech-DS18b20-Waterproof-Temperature-Transmitter/dp/B00CHEZ250

The tutorial page shows an IC with 3 pins, while my sensor is different as shown in the amazon marketplace

Thank you very much.

The IC shown on the tutorial page is what is inside the metal case of the sensor you bought.
-127 indicates that the sensor is not wired correctly because it is always reading a 1 from the data pin.
You didn't mention having a resistor. The data pin needs to have a 4.7kohm pullup resistor on the data lead as shown in the tutorial's diagram.

There are two other possibilities though.

  • some people have reported that the IC isn't a DS18B20. Sometimes it is presumed to be a 2N2222 transistor or other cheap IC instead.
  • sometimes the wires aren't connected to the IC as described on the webpage. e.g. instead of the way yours is wired, they might actually be:
    red - data
    black - ground
    yellow - 5V

Pete

The Ebay Vktech seller has this:
Product Features:

9 ~ 12 adjustable resolution

Power supply range:3.0V-5.5V

No other components, unique single bus interface

Output lead:red (VCC), yellow(DATA) , black(GND)

able length:Approx.100 cm

In spite of what is written, they do require the 4.7k ohm resistor as EL_SUPREMO stated. Won't work without it.

I suspect ALL the units you see for sale come from the same Chinese factory.

Paul

Thank you. It worked now.