Multiple Dallas onewire busses on a Arduino

// this has been covered before this is another way to do the same thing. hope this helps

#include <OneWire.h>
#include <DallasTemperature.h>

OneWire oneWireA(2);//pin
OneWire oneWireB(3);//pin

DallasTemperature sensors1(&oneWireA);
DallasTemperature sensors2(&oneWireB);
void setup() {



void loop()



float probeTEMP1 ;
probeTEMP1 = sensors1.getTempCByIndex(0);


float probeTEMP2 ;
probeTEMP2 = sensors2.getTempCByIndex(0);


Serial.println(" °F");


goto Main_A;


Please follow the advice given in the link below when posting code , use code tags and post the code here to make it easier to read and copy for examination

Expect unfavourable comments about using goto in your sketch

As noted, you're about to go there anyway, via a return and a call.
Completely unnecessary.

How exactly would it help? I mean, I havent thought of a use case where two separate onewire buses would have to be addressed by a single master. You're making me curious; how come you needed this?

if the code i just put up was there it would have helped me.
it may help the next person.

But it might just as well confuse them, wondering why a goto is in there, and if it is required.

the goto is not needed, the correct answer.

Again, out of curiosity, where did the need for 2 separate onewire buses arise from?

Ref:Again, out of curiosity, where did the need for 2 separate onewire buses arise from?

Originally I was only using one input(one onewire bus) but I was experiencing a problem where the Arduno was confusing the inputs 4 senses and was the main reason why I decided to move away from one onewire bus to 4 separate onewire buses,

even though this worked perfectly in my office as soon as I went out into the field the prom seem to come back that is the main reason why I made the change.

Okay, I see; sounds like you had protocol and/or hardware issues to begin with. 4 sensors on 1 onewire bus works just fine. I've got 3 +2 homemade devices running on a bus that is partly disconnected in some modes, works in a high electrical noise environment and overall is just challenging in terms of its boundary conditions. It works just fine...

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.