I am new to Arduino and electronics in general and I can't get my MKR1000 to read correct data from a DS18B20 temperature sensor.

Here is the tutorial I followed.

The issue is: I always get the same readings from the sensor: -127.00.

I should mention I have tried 2 different sensors and get the same readings.

From the sensor, GND goes directly to GND on the board, and I have the 4.7kΩ resistor in between the data and power wires.

According to the sensor manufacturer, output leads: Yellow (VCC), Red (DATA), Black (GND).

Data line is connected to the pin ~2 on the MKR1000.

// First we include the libraries
#include <OneWire.h> 
#include <DallasTemperature.h>
// Data wire is plugged into pin 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);
void setup(void) 
 // start serial port 
 Serial.println("Dallas Temperature IC Control Library Demo"); 
 // Start up the library 
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 temperature readings 
 Serial.print("Temperature is: "); 
 Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"?  
   // You can have more than one DS18B20 on the same bus.  
   // 0 refers to the first IC on the wire 

Any idea what I am doing wrong?

enter image description here enter image description here enter image description here

  • In addition to the photos, do you have a schematic for the circuit to upload? It would be more helpful than looking at the bunch of wires to figure out what is going on.
    – MichaelT
    Nov 16, 2018 at 16:04
  • Thanks @MichaelT - This question has been answered already. Sensor manufacturer messed up their documentation so I had the power going to the data and vice-versa.
    – MrUpsidown
    Nov 16, 2018 at 16:10

1 Answer 1


Looks like you have it wired wrong. A schematic would really help but it looks like you've got 5V going directly into the sensors data line (yellow wire) it's connected on your breadboard to the orange wire +5V. The power wire of your temperature sensor (red wire) is running through a 4.7K resistor which is not likely what you wanted here either.

  • According to the sensor manufacturer: Output leads: Yellow (VCC), Red (DATA), Black (GND)
    – MrUpsidown
    Nov 16, 2018 at 15:29
  • May be a typo in their documentation. I've found similar sensors on Ebay and: Output lead: red (VCC), yellow(DATA) , black(GND) Nov 16, 2018 at 15:40
  • The schema I am trying to achieve can be found on the link I posted earlier: create.arduino.cc/projecthub/TheGadgetBoy/…
    – MrUpsidown
    Nov 16, 2018 at 15:40
  • OMG! Okay... you were right, they managed to get their schemas wrong! Red is VCC and yellow is DATA! I thought about many possible causes but not that one... ;) Thanks for your help.
    – MrUpsidown
    Nov 16, 2018 at 15:46
  • 1
    The only thing worse than no documentation is errant documentation. Nov 16, 2018 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.