Arduino Uno + Gravity: Waterproof DS18B20 Sensor Kit

hi i have both of these and im having issues with configuring them. i found the code online and it should be plug and play but i feel like im messing something up. the temp sensor kit came with wireing that converts it to a plug that can be used on the 3 pin headers. however i think the code isnt using the headers at all. every video i see is using ports on the board instead.

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

#define ONE_WIRE_BUS 8

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

float Celsius = 0;
float Fahrenheit = 0;

void setup() {
sensors.begin();
Serial.begin(9600);
}

void loop() {
sensors.requestTemperatures();

Celsius = sensors.getTempCByIndex(0);
Fahrenheit = sensors.toFahrenheit(Celsius);

Serial.print(Celsius);
Serial.print(" C ");
Serial.print(Fahrenheit);
Serial.println(" F");

delay(1000);
}

any ideas on what i can do

Please post your code in code tags (</>).

Please post a diagram showing how the sensor is connected to the Arduino.

The headers can be cut off if you want. What you need to do is connect the three wires from the plug (jumpers will usually fit) and connect them to the appropriate pins on the Arduino. Just a SWAG but Red to +5, Black to Ground, and Yellow to the appropriate port pin, probably pin 8 or D8 depending on what board you have. Let us know how that works for you.

is there any way to keep the plug and use the 3 pins on the board?


I was thinking about using one of these ports. I'm new to these things so I don't know anything yet but I feel like it should connect since it came with it

Have you got a pic of the "plug"?


on the top left. unless i have this seriously wrong

These are the important wires... the rest seem superfluous.

image

Connect them to the Arduino...
Red - 5v
Black - GND
Yellow - Pin 8

OneWire requires a single 4.7K pullup resistor, connected between the pin and your power supply.

I keep an assortment of Dupont connectors and mail and femail pins on hand. They are also called Jumper Wire cables. They are low cost and used to connect hardware such as sensors, Arduino boards and breadboards together. The connectors are available in male and female with a 2.54mm (100mill) pitch. They make headers from 1 to 10 or more pins single and double row. I would use a 3 pin connector and use mail pins assuming the sensor is female. You will need a crimping tool to do this. Do not forget to terminate it. You may have to lower the termination resistor value if the wire gets long or is highly capacitive. You can buy these jumpers in any combination of mail and femail you want.