DS1820 bad reading from 4th sensor I am very new to Arduino. I want to add about 50 sensors to Arduino R3. I get good readings from 3 sensors, but when I connect 4th one, I get 'No devices found'.

Here is a diagram:


and here is the code I use:

#include &lt;OneWire.h&gt;
#include &lt;DallasTemperature.h&gt;

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 8
#define BAUD_RATE 9600

// 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(&amp;oneWire);

// arrays to hold device addresses
DeviceAddress devices[10];
int devicesFound = 0;

void setup(void)
{
  // start serial port
  Serial.begin(BAUD_RATE);

  sensors.begin();

  devicesFound = sensors.getDeviceCount();

  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  Serial.print(devicesFound, DEC);
  Serial.println(" devices.");  

  // report parasite power requirements
  Serial.print("Parasite power is: ");
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");

  for (int i = 0; i &lt; devicesFound; i++)
    if (!sensors.getAddress(devices[i], i))
      Serial.println("Unable to find address for Device" + i);

  // show the addresses we found on the bus
  for (int i = 0; i &lt; devicesFound; i++)
  {    
    Serial.print("Device " + (String)i + " Address: ");
    printAddress(devices[i]);
    Serial.println();
  }

  for (int i = 0; i &lt; devicesFound; i++)
    sensors.setResolution(devices[i], TEMPERATURE_PRECISION);
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i &lt; 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] &lt; 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC &lt; 10)
    Serial.print("0");

  Serial.print(tempC);
}

// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
  Serial.print("Resolution: ");
  Serial.print(sensors.getResolution(deviceAddress));
  Serial.println();    
}

// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
  Serial.print("Device Address: ");
  printAddress(deviceAddress);
  Serial.print(" ");
  printTemperature(deviceAddress);
  Serial.println();
}

void loop(void)
{
  if (devicesFound == 0)
  {
     Serial.println("No devices found.");
     return;
  }

  int start=millis();
  sensors.requestTemperatures();

  // print the device information
  for (int i = 0; i &lt; devicesFound; i++)
  {
    printTemperature(devices[i]);
    if (i != devicesFound - 1)
      Serial.print(" ");    
  }  

  Serial.println();

  Serial.print(millis() - start);
  Serial.println(" ms passed.");
}


The resistor I use is 4.7&nbsp;k&Omega;. What should I change to get good readings? And is it a problem to get reading from about 50 sensors?

UPDATE

So after a few trials, I managed to get readings for 18 sensors. I managed to have a mixed topology. What I did is I added close to sensors I didn't get reading a resistor (mainly 4.7k, but also few 100, 1k). At the moment I get occasionally -127 reading from some sensors, but I think I will fix that with CRC check in the program. Thanks for your help! –
Max current

For 4 sensors I wouldn't expect problem, however, for 50 it will.
The VCC/GND pin has a maximum of 200 mA, see Arduino Pin Current Limitations.

(Update after remark of Gerben, thanks!):
However, these are for the ATMega, not the Arduino R3. See Arduino Voltage and Current. It's not an official document, but made by Gabriel Staples). It contains a lot of references. But the VCC can handle 0.5 or 1A depending on USB or battery power. 

This means:
The DS1820 uses 4 mA (checking a random datasheet), so 50 * 4 = 200 mA, which is way within 500 mA/1000 mA).

Non one wire sensors (not your case)

Since you have one wire sensors the following is not applicable (just leave it here for others):

None one-wire sensors use their own GPIO pin mostly. Since the Arduino doesn't have 50 GPIO pins, especially not for analog input, you need to have external IC(s), ADCs (Analog Digital Converters) or analog multiplexers, see also connecting more than 6 analog input pins to Arduino.

One wire sensors (your case)

You might find how many ds18b20 temperature sensors can I connect to one bus interesting.