i am trying to read Temperature sensors DS1820 (the very old one) and the new DS18x20 (DS18S20, DS18B20) on the same bus.Due they have different parameters i played around to get the read all together on the same bus (pin).

void writeTimeToScratchpad(byte* address){ //reset the bus ds.reset(); //select our sensor ds.select(address); //CONVERT T function call (44h) which puts the temperature into the scratchpad ds.write(0x44,1); //sleep a second for the write to take place delay(1000);}

As you can see at the brown marked parts the values of the new DS18B20 (begins with 28 instead of 10) i had to remode the leading 0(zero) to fit the belongings of the compiler - if not, it causes an error even when i test the code.

WITH these manipulations the sketch runs, but gives wrong result (the other two shows about correct 21.50 degree celsius) with 30.5 degress celsius.When i touch it short, it jumps up to 62 degree celsius.

So, i know something about the MSB and LSB but not enough to get them work together.

Hey, I was about to post my own question about a similar issue (first post for me).From looking at your code, the only thing i realize is that you are far more competent than I am with everything related to electronics.I used the Dallas temperature library, and frankly it works quite fine (using DS18B20 and DS18S20) and is simple.I successfuly managed to hook up 6 B types along with 1 S type. It might also work with the "old" ones, as you call them. Would gladly upload the code had I known how to make that neat frame with the "code:" title the way you did.Nevertheless, I kinda ran into my own little problem that I would like to solve (not to take the spotlight away from yours, ill share it after we get to fix yours).

Its a modification of a sample i found somewhere... perhaps on the library's wiki, can't remember.you can find more details here: http://www.ay60dxg.com/doc/loguino/class_dallas_temperature.htmlAnyways, devices 1-5 are cable sensors (should be DS18B20) placed along a 3-meter cable (cut, connected and wrapped),and device 0 (it says on it that it is also a DS18B20, contrary to what i posted earlier) is a small one placed on the matrix.My problem, and i have checked it, appears to be that when the program gets to the line "sensors.begin();", it gets stuck there (doesnt go on to serial printing and such - inf loop?).If i unplug device 0 or the cable with devices 1-5 (either one, doesnt matter), the program suddenly continues, and if i plug them back, it goes on as if there was no problem ever (correct readings every 10 secs).Alternatively, if i delete the "begin" line whatsoever, the program works fine from start to finish.I understand nothing from looking at the "begin" command reference (provided link above).my questions are:1. Why the hell does it get stuck on that line, is it the arrangement of the sensors or their type or what?2. Whats the importance of the "begin" command, especially if the code works fine without it?shouldnt it be some kind of obligatory condition for the sensors item to "ignite"??

Thought maybe because you guys are more familiar with serial communication you might know the answer.

Any help would be greatly appreciated And i hope this library might ease your way in getting readings from the sensors.

I found this sample, too - but it seems not work for me as i testest.The follwoing code works and shall have the advantage to read the sensors "byIndex".

Doesnt know why in the moment, but it works ;-)

i found the fowlloing site where the main things of OneWire-Bus can be found (only in german, but you can translate the site with google).http://shop.wiregate.de/1-wire-bus

Parasite Power:

Non-parasite Power:

Another interesting i found was the kind of wiring-methods for the bus and the sensors, so i had found an mistake in my bus-topology and make it more effectiv:Tree : Restrictions : 50 - 100 meter / 10 - 20 sensors

Tree with short lines : NEARLY OPTIMALRestrictions : up to 100 meter

Line : OPTIMALRestricitons : up to 150 meter

Star : Restrictions : up to 100 meter / =< 10 sensors

Ring (noGo) : Restrictions : no function

I have to read (besides 9 other kinds of sensor datas) anout 20 DS18x20 datas, and some of the topologies? can only handle up to 10.

void loop(void){ Serial.println(); Serial.println(); Serial.println("DS18x20_MIX_OK Sketch"); Serial.println();sensors.requestTemperatures(); //to issue a global temperature//request to all devices on the busSerial.println("Requesting temperatures");sensors.requestTemperatures(); //Send the command to get temperaturesSerial.print("Temperature for Device 1 is: ");Serial.println(sensors.getTempCByIndex(0));Serial.println("DONE");sensors.requestTemperatures(); //Send the command to get temperaturesSerial.print("Temperature for Device 2 is: ");Serial.println(sensors.getTempCByIndex(1));Serial.println("DONE");sensors.requestTemperatures(); //Send the command to get temperaturesSerial.print("Temperature for Device 3 is: ");Serial.println(sensors.getTempCByIndex(2));Serial.println("DONE");//Why „byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire}

The problem with stucking i had also: 3 sensors worked fine, the forth one also, but only the 1st time.Then (in the serial monitor) the 3rd and the 4th sensor where also be repeated and even when i disconnect them, the monitor shows still the same datas (without sensor XD)

Only after a hardware reset all works fine again...

So i read these site and there was written, that it would ALWAYS be better to connect all 3 Pins of EACH DS18x20 with the bus and not to use parasite power.

So, resoldered my complete bus (1st time only the 1st sensor had a resistor, the following used parasite power) and now all is good !

I think i wil have a tree with short lines (really sort, may be 5 cm, to made me able to place the sensors in the correct site -outdoor-maintaining the main cable in position -inside a cover to protect from the environment).

However, you said something interesting:

Quote

1st time only the 1st sensor had a resistor

Do you mean that each sensor should have its own resistor? This is the first time i readed something like that. My idea, and what i readed here and there in this forum and everywhere, is that the resistor is one per bus... Could you confirm that with a configuration of multiple sensors it works? Thanks!

As i have tested out each one needs one I also read never about that, but all descriptions are for sensors of the same type.

If not, it will read (beginning from the first one on the bus) until it reaches the first other-type-ds18xxx (in my case the 4th one).Then the reading will return each second (seems that the bus hangs) with the same device AND the device before !

Maybe because it is a mix of different types a 4,7k is needed at each sensor.

Also i disabled the begin.sensors(); part, because then an error occurs.As i read the Devices byIndex(x), it works as long as the sensor adresses are defined before

The Atmega328 is configured to use internal pull-up resistors which may be adequate for short cable runs. Warning: for multiple I2C devices, or longer cable runs, the 4.7K pull-up resistor (for each line) is recommended

The Atmega328 is configured to use internal pull-up resistors which may be adequate for short cable runs. Warning: for multiple I2C devices, or longer cable runs, the 4.7K pull-up resistor (for each line) is recommended

This totally throws me. If you have a star topology, this implies that you need one resistor for each leg, but if they are all shorted together at the port pin, does this mean that the resistor should be at the end of the line and the connection should be 3-wire (eg, not parasitic)? OK, time for a test--for two long legs, will a 2.2K resistor do the job. Back soon.

Well, blow me down. With two 30' cables the "address finder" code could find each address when only one was connected at time (with 4.67K resistor). Did not work with both cables. I added another 4.7K to the port pin and viola', both addresses popped up.

This doesn't seem to have anything [much] to do with the load presented by multiple DS1820s, but only how many wires are coming together at the port. Admittedly, these 22-4 cables have relatively high cable capacitance. The same experiment using 24 gauge pairs didn't require the added resistor. I assume the if the 22-4 cables were significantly shorter, they would work with one resistor. Emphasize "assume."