Arduino Mega and OneWire issue! Help please!

OneWire library does not work on a Arduino Mega. What maybe wrong???
Help me please!!!! :~
I try both version 1 and 2. But still get only "No more addresses" :disappointed_relieved: (it's from example sketch)

Did you include the 4.7k pull-up resistor on your OneWire pin?

Indeed - that's a common mistake that I've done a few times :frowning:

johnwasser:
Did you include the 4.7k pull-up resistor on your OneWire pin?

Of course!

What model Arduino Mega are you using?

What pin are you using for OneWire?

What does your sketch look like?

How many devices do you have on the OneWire interface?

Do those devices work correctly on a non Mega Arduino?

Are you using parasitic power over two wires (ground/data) or regular power over three wires (+5v/data/ground)?

  1. Arduino Mega 1280
  2. pin #10 (or all others digital pins)

#include <OneWire.h>
/* DS18S20 Temperature chip i/o /
OneWire ds(10); // on pin 10
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
byte i;
byte present = 0;
byte data[12];
byte addr[8];

if ( !ds.search(addr)) {
Serial.print("No more addresses.\n");
ds.reset_search();
delay(250);
return;
}

Serial.print("R=");
for( i = 0; i < 8; i++) {
Serial.print(addr
, HEX);
Serial.print(" ");
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.print("CRC is not valid!\n");
return;
}

if ( addr[0] != 0x10) {
Serial.print("Device is not a DS18S20 family device.\n");
return;
}
// The DallasTemperature library can do all this work for you!
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end*

* delay(1000); // maybe 750ms is enough, maybe not*
* // we might do a ds.depower() here, but the reset will take care of it.

present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad*
* Serial.print("P=");
Serial.print(present,HEX);
Serial.print(" ");
for ( i = 0; i < 9; i++) { // we need 9 bytes*
_ data = ds.read();
Serial.print(data*, HEX);
Serial.print(" ");
}
Serial.print(" CRC=");
Serial.print( OneWire::crc8( data, 8), HEX);
Serial.println();
}[/sup]*
4. One device per pin
5. Yes, this device is IButton and it correctly work on onon Mega Arduino
6. I use parasitic power over two wires (ground/data)_

If you are using a DS1990A iButton instead of a DS18x20 you might have to do things differently.

This example:
http://tushev.org/articles/electronics/35-reading-ibutton-with-arduino
use a 2.2k pull-up resistor. I don't know if that is necessary or not because I've only used the DS18B20 thermometer chips.

Serial.print( OneWire::crc8( data, 8), HEX);

Well, now, that's hardly going to make the compiler happy. There's a reason that there is a button to use when posting code.

If using parasite power you need a strong pull-up, is this done by the OneWire library? Is an Arduino pin a strong enough pull-up anyhow - perhaps its border line so that some Arduinos work and some don't due to process variations?