Ds18b20 and arduino connection error

hello.
I connected the ds18b20 sensor with arduino as in the picture.

and again I uploaded this sample code with Arduino Ide.

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

// Sensör pini (2. dijital pin)
#define SENSOR_PIN 2

// Sensör nesnesi oluşturma
OneWire oneWire(SENSOR_PIN);
DallasTemperature sensor(&oneWire);

void setup() {
// Seri haberleşme başlat
Serial.begin(9600);

// Sensör başlat
sensor.begin();
}

void loop() {
// Sıcaklık ölçümü başlat
sensor.requestTemperatures();

// Sıcaklık ölçümü sonucunu oku ve seri porta yazdır
float temperature = sensor.getTempCByIndex(0);
Serial.print("Sicaklik: ");
Serial.print(temperature);
Serial.println(" C");

// Bekle
delay(1000);
}

ps:As soon as the upload is complete, the arduino is blinking 4 fast 4 slow and disconnecting from the computer. Any ideas? When I do a quick reset twice, the led turns green and the computer recognizes it again. I installed the example blink, it works.

any idea or help please??

Time to buy some 1/4 or 1/8 watt resistors :wink:

What is printed on the serial monitor.

Plugging wires into a dupont wire like this is not a great idea. :woozy_face:

1 Like

hello larry:) i just had 5w on hand thought no matters:)

as soon as upload is complete arduino blinks red and lost connection with pc. soo no serial monitor.

Do you have the correct Arduino selected before you upload ?

Does the IDE say upload complete ?

Can you try to upload the blink sketch ?

did you read my first post:)?
blink works well.
and yes i get upload is completed.

When we read 100+ questions in a day, all gets put into the same wash :wink: .

  • Do you have a new sensor, if so, see if the same problem occurs.

Did you try the One Wire address finder to see if you were connecting to the DS18B20?
one_wire_address_finder.ino (1.1 KB)

Usually, a 4.7K ohm 1/4W pull-up resistor is used with DS18B20. I can see that you are using a 5W resistor. Perhaps that is not an issue. But it's better to try the typical circuit. I do not think the problem exists in the code.

Looks like you are assuming the red wire is +, black is - and yellow is signal, that may NOT be the case. That's why I posted reply #8

yes, i assume so.
i will try with 1/2w resistor today and update the post.
still getting 4fast,4slow red blink from arduino.

i downloaded and run . as soon as upload completes ; arduino 4fast4slow red blinks. idid the curcuit with the 1/2 W resistor.

i also tried with a in anorher ds18b20 sensor.

please help me:(

Hi,
Post us some images with the 18B20 in the frame.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Certain these are correct...???

i also uploaded example 1wire code. as soon as upload complete, pc lost connection with arduino. some says reduce the resistor i have tried with 2.8k an 3.2k resistor

4.7k is 4.7k and, while a 5W resistor might look a little silly, it is still 4.7k and can't possibly be the cause of your problem. You could try code from a tutorial, Hacktronics foe example, but the problem may simply be slack-arsed wiring. You do seem to be using more than you should need, amd a problem can lie in every joint.

I've tried the code from post #1, and can confirm that it works successfully. (Tested on a Uno).

hello tomZ pic is attached:) and i have learned arduino 4fast-4Slow red blinks when MbedOs crashes.
as i said earlier when i upluad the code without connecting ds18b20 sensor; it also crashes.
thanx for your kindly reply:)

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

are you sure that the libraries are compatible with Giga board?

no i am not sure. how can i check or verify please?