Temperature Sensor DS18B20 Not Detected on Arduino Nano v3.0

I am having problems getting my temperature sensor to read on my Arduino Nano v3.0. I am hoping someone can take a look at my code/schematic and tell me where I’m going wrong. Temp returned is -127 (indicating no sensor found).

I am using code from ds18b20 tutorial. I have attached the wiring diagram and have verified the temperature sensor works on a Raspberry Pi 2 B successfully using the 1-wire bus.

Datasheet says the sensor takes between 2.7 and 5.5 volts and my voltmeter displays 4.69 volts on both VCC and Data pins with 4.7k resistor wired in.

I’m racking my brain trying to figure out what’s wrong.

The code expects the DS18B20 data line to be on digital pin 2 but your diagram shows it connected to analog pin 5.


Ah yes, sorry about missing the clarification… Data wire is actually on A6 (pin 25 I thought) and I made a change to the code:

#include <OneWire.h>

#include <DallasTemperature.h>

  Rui Santos
  Complete project details at http://randomnerdtutorials.com  
  Based on the Dallas Temperature Library example
// Data wire is conntec to the Arduino digital pin 2
#define ONE_WIRE_BUS 25

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

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

void setup(void)
  // Start serial communication for debugging purposes
  // Start up the library

void loop(void){ 
  // Call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus
  Serial.print("Celsius temperature: ");
  // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire
  Serial.print(" - Fahrenheit temperature: ");

A6 is pin 20.


Thank you for pointing me in the right direction. A6 looks like it's an analog only pin. I moved it to A5 and referenced it as A5 and the thermometer started reading.

I was using this pinout... Where do I find official pinout for this board?

vvarrior: I was using this pinout... Where do I find official pinout for this board?

The following diagrams could be helpful for you:



|500x243 Figure-3:

|500x343 Figure-4:

A: Figure-1 1. The pin numbers of the NANO Board have been shown in parentheses like: (1), (2), ..., (30).

2. Text at the side of a NANO Pin (Blue color text which is engraved on the NANO Board in while color) is the name of the signal that is attached with this pin. For example: Pin-7 is attached with D4. D4 is the software name for the bit-4 (PD4) of Port-D Register (see Fig-4). D4 is equivalent Digital Pin-4 (DPIN-4) of UNO Board.

B: Figure-2/3 1. It clearly indicates that A6 and A7 are the ADC Channels ADC6 and ADC7. They are not the part of Port-C; hence, they can not be used as digital IO lines.

BTW: There are following Port Lines in UNO/NANO : PD0 - PD7, PB0 - PB5, and PC0 - PC5. These signals are seen by the software as Digital Pins with these numbers: 0 - 7 (for PD0 - PD7), 8 - 13 (for PB) - PB5), and 14 - 19 (PC0 - PC5).

I am not sure if ADC6 and ADC7 of NANO could be referred to by 20 and 21 (they are not digital IO pins?).