Hi,
I try to make a ds18b20 sensor.
DS18b20 : red (vcc); Black (Gnd); Yellow (data) (I think this is correct).
So I plus red on 5v pin, Yellow on pin 2, Black on G pin.
I put a 4.7k resistor between Vcc and Data pin. (In fact two 10k in parallel, I have no 4.7k resistor)
I use this code :
#include <OneWire.h>
#include <DallasTemperature.h>#define ONE_WIRE_PIN D2
OneWire oneWire(ONE_WIRE_PIN);
DallasTemperature sensors(&oneWire);void setup()
{
Serial.begin( 9600 );
Serial.print( "Demo capteur de temperature DS18B20\n" );// Démarre le processus de lecture.
// IC Default 9 bit. If you have troubles consider upping it 12.
// Ups the delay giving the IC more time to process the temperature
// measurement
sensors.begin();
}void loop()
{
long t1 = millis();// Requête de toutes les températures disponibles sur le bus
sensors.requestTemperatures();
// On ne garde que la première température (index = 0)
float Temp = sensors.getTempCByIndex( 0 );long t2 = millis();
long dt = t2 - t1;Serial.print( "t = " );
Serial.print( t2 );
Serial.print( " ms\t" );Serial.print( "dt = " );
Serial.print( dt );
Serial.print( " ms\t" );Serial.print( "T = " );
Serial.print( Temp, 1 );
Serial.print( " degC\n" );
}
My problem, is that the serial monitor shows me always temperature of -127 !! If I unplug all, it continues telling me -127 !!!
What's wrong ?
I tried an another sensor ds18b20, and same issues.
Thank you for your help.