Problem with one wire and DS18B20 temp sensors

Hi all,

I'm trying to find the addresses for several DS18B20 sensors and no mater what I try all I get in the serial monitor is this

àà àààà àààà àààààà à

Any ideas?

I've tried different pins, different sensors (I have 5 in total) and different address finding sketches (dallas temp library test sketch and one_wire_address_finder). All have the same result.

The sensors are wired to 5v ground and pin 51 on a mega 2560 (I have also tried pin 2,3 and 4 as well as 49). I currently have only had one connected at any one time as I was wanting to write down the addresses for each as opposed to getting all the addresses and trying to work out which is which.

Any help would be great.


Can you please post a copy of your sketch, using code tags? Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Please use code tags.. See section 7,148850.0.html

Also check that the serial speed declared in the sketch is the same as the monitor speed.

Tom.... :)

Hi Tom,

Thanks for the quick reply. How do I check serial speed in the sketch and the monitor? That seems most likely to me as its the only thing I haven't tried/thought of.

This is the library test code

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

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

int numberOfDevices; // Number of temperature devices found

DeviceAddress tempDeviceAddress; // We'll use this variable to store a found device address

void setup(void)
  // start serial port
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  // Grab a count of devices on the wire
  numberOfDevices = sensors.getDeviceCount();
  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  Serial.print(numberOfDevices, DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  Serial.print("Parasite power is: "); 
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");
  // Loop through each device, print out address
  for(int i=0;i<numberOfDevices; i++)
    // Search the wire for address
    if(sensors.getAddress(tempDeviceAddress, i))
		Serial.print("Found device ");
		Serial.print(i, DEC);
		Serial.print(" with address: ");
		Serial.print("Setting resolution to ");
		// set the resolution to TEMPERATURE_PRECISION bit (Each Dallas/Maxim device is capable of several different resolutions)
		sensors.setResolution(tempDeviceAddress, TEMPERATURE_PRECISION);
		 Serial.print("Resolution actually set to: ");
		Serial.print(sensors.getResolution(tempDeviceAddress), DEC); 
		Serial.print("Found ghost device at ");
		Serial.print(i, DEC);
		Serial.print(" but could not detect address. Check power and cabling");


// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
  // method 1 - slower
  //Serial.print("Temp C: ");
  //Serial.print(" Temp F: ");
  //Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit

  // method 2 - faster
  float tempC = sensors.getTempC(deviceAddress);
  Serial.print("Temp C: ");
  Serial.print(" Temp F: ");
  Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit

void loop(void)
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  // Loop through each device, print out temperature data
  for(int i=0;i<numberOfDevices; i++)
    // Search the wire for address
    if(sensors.getAddress(tempDeviceAddress, i))
		// Output the device ID
		Serial.print("Temperature for device: ");
		// It responds almost immediately. Let's print out the data
		printTemperature(tempDeviceAddress); // Use a simple function to print out the data
	//else ghost device! Check your power requirements and cabling

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
  for (uint8_t i = 0; i < 8; i++)
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);

And this is the alternative I found this morning to see if there was an issue with the first test code.

// This sketch looks for 1-wire devices and
// prints their addresses (serial number) to
// the UART, in a format that is useful in Arduino sketches
// Tutorial: 

#include <OneWire.h>

OneWire  ds(3);  // Connect your 1-wire device to pin 3

void setup(void) {

void discoverOneWireDevices(void) {
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];
  Serial.print("Looking for 1-Wire devices...\n\r");
  while( {
    Serial.print("\n\rFound \'1-Wire\' device with address:\n\r");
    for( i = 0; i < 8; i++) {
      if (addr[i] < 16) {
      Serial.print(addr[i], HEX);
      if (i < 7) {
        Serial.print(", ");
    if ( OneWire::crc8( addr, 7) != addr[7]) {
        Serial.print("CRC is not valid!\n");
  Serial.print("\n\r\n\rThat's it.\r\n");

void loop(void) {
  // nothing to see here

As for diagrams I don’t have any to hand. But they are the same as the given examples for standard set up, 5v supply off the mega, ground on the mega and then a data conection to pin 51 oh and a 4.7k reistor between 5v and data.

Hi, the sketch sets the speed at 9600, when you opne the serial monitor in the IDE at the bottom it will have what speed it is receiving at.

Tom.... :)

It would be less confusing to decide on a data pin and stick to it. You say you have connected data to pin 53, but the first programme says pin 2 and the second pin 3.

The first programme appears to be incomplete and is probably junk. The second is not an alternative, it is a an address sniffer, and does not measure temperatures. It goes with the other programme in the Hacktronics tutorial. This is a similar version

/* Basic 2xDS18B20 code for serial monitor, bluetooth, Excel or w.h.y.
Derived from Hacktronics. USE THEIR ADDRESS SNIFFER, test one sensor at 
a time, and substitute your numbers. 
Use Hacktronics connections diagram.
Stay away from using parasite power
-127C means bad connection
85 means you haven't gotten a read yet, probably just the 
wrong order of commands

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

// Data wires are plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
byte Thermo1[8] = {0x28, 0x39, 0xFD, 0x50, 0x04, 0x00, 0x00, 0X69};
byte Thermo2[8] = {0x28, 0x09, 0xA9, 0xC0, 0x03, 0x00, 0x00, 0x95};
float tempC,Temp1,Temp2;  

void setup(){
  delay(500);//Wait for newly restarted system to stabilize
  sensors.setResolution(Thermo1, 12); 
  sensors.setResolution(Thermo2, 12);

void loop() {
 sensors.requestTemperatures();  // call readings from the addresses
  Temp1 = sensorValue(Thermo1);
  Temp2 = sensorValue(Thermo2);  

Serial.print("      Temp1 = ");
Serial.print("      Temp2 = "); 

//sensorValue function
float sensorValue (byte deviceAddress[])
  tempC = sensors.getTempC (deviceAddress);
  return tempC;

That's what I'm trying to do. Get the addresses of the sensors. I have a reef control program (Jarduino) that will be using the addresses to read the sensors monitoring water temp and heat sink temps. But I can't get the addresses. I thought the 2 sketches above were both to supposed to do that. But as I have said the serial monitor displays àà àààà àààà àààààà à constantly on one line.

I have chosen a pin (51) as that is set in the Jarduino program (I can change it if I need to), what I said in the original post was I have tried other pins to rule out a bad pin/my jumper set up. Same result with any pin and different sensors. I intend to run 5, however as I'm trying to get the addresses for the different locations the sensors will monitor, I was connecting only one at a time to read its address to add them to the program. So I have ruled out a dead sensor as I have tried several with again the same result.

What is your answer to reply #4? Are the sketch and monitor baud rates set to the same value?

BennyGW314: I thought the 2 sketches above were both to supposed to do that. .

Aha! I guess you are right. But it doesn't say much for the first one. The Hacktronics sniffer is exactly the same as what I use and should be OK. Test one sensor at a time. As the others say, check the baud rate.

Guys thanks so much it was as simple as a the speed.

Never even knew about that so good catch I'd of been chasing my tail for ever.

Thanks again.