Arduino and 1-wire

Well, I'm just joining this discussion because I have a new Arduino and have been building a weather station so when I saw Arduino and OneWire in the same post I jumped at the chance. I'm using the 0011 version and put the files in arduino-0011\hardware\libraries\OneWire but I get an error about
OneWire::OneWire(unsigned char)'o: In function `loop':
I'm still going through the messages but if anyone has the fix I would appreciate it.

Thanks, Stephen

I'm using the 0011 version and put the files in arduino-0011\hardware\libraries\OneWire but I get an error about
OneWire::OneWire(unsigned char)'o: In function `loop':
I'm still going through the messages but if anyone has the fix I would appreciate it.

The OneWire library, itself, doesn't have any problems with arduino-0011 that I'm aware of. If you're still having this problem, I'd be happy to look at it if you post your code here.

TomP, I'm trying to compile the sample.c program that comes with the OneWire library. Like I say I'm new to the Arduino and have not programmed in c for several (many?) years. Perhaps I'm just doing it wrong. Thanks for trying to help.

OK, told you I was new to all of this. :o I just noticed that in the files downloaded there is a onewire.h and a onewire.cpp but unlike the other libraries there is no onewire.o file. Do I need to compile the code and what would be the best way to do that? :-/ Thanks.

More info: I've gotten the library to work, I had two problems. First I copied the sample.c file into the directory and I think that was confusing Arduino somehow and there was an extra semicolon in the code ( :-[ ..who put that there?..) I got rid of the fluff and it compiled OK and works. Thanks all for the help and support, I can use all I can get at this stage.

Hello everyone,

I am from Irvine,CA. I am working with a network of 1 wire temp sensors. (DS18B20).

have you ever tried using your 1-wire arduino and Jim's updated library for arduino-10 with more than 9 DS18B20's in parasite power mode?

I am using your example code and the 1-wire library by calling it from the Arduino IDE as someone has posted in the arduino playground.( I have even commented the code)

I am attempting to connect 29 DS18B20's in parasite power mode. So far I have tested those 29 individually with your library and they worked pretty well. I can discover their addresses and ask them for a temperature value.

As long as I connect 8 DS18B20 to the same wire of course, the readings become rubbish. Only two sensors keep giving me their ID and loop forever(CRC's ok). The others sensors seem to be lost or not being able to be discovered ever.

It is not a power issue since I have looked at the signal over the oscilloscope. It is neither a problem of the pull up resistor.

I got 100 DS18B20's from maxim. ALL OF THEM WORK PERFECT INDIVIDUALLY.

The weird behaviors comes into play when I CONNECT MORE THAN 8 sensors. I tried replacing sensors with those hundred I got until I find one that is is able to be read adding an extra sensor to the 8 sensor network. The farthest I could go was 16 sensors. Leaving 16 sensors cataloged as not being able to participate in a network of more than 8 sensors.

this means that If I have a network of 16 DS18B20's working well (after trying with ~32 different sensors until 16 worked ok together) and I replace one of them with one of the cataloged as "bad"(~15) all the information becomes rubish again.

I am pretty much sure is a software problem( the 1-wire library).

Can you provide any help?

Many thanks,.

Ulises
:-[Irvine, CA.

What happens if you run them with power? and do you have the pullup resistor in your circuit?

[...] and do you have the pullup resistor in your circuit?

Without the pull-up resistor, even one device wouldn't work.

It is not a power issue since I have looked at the signal over the oscilloscope. It is neither a problem of the pull up resistor. [...] I am pretty much sure is a software problem( the 1-wire library).

I'm not sure how you can conclude that it's not a hardware issue. You can't just continue to add devices to a 1-wire network and expect them all to perform as if they were the only devices on the bus. Maxim publishes an application note (AN148 - ""Guidelines for Reliable 1-Wire Networks") that discusses the issues people encounter when trying to build medium-sized and large 1-wire networks. It's readable and seems to contain a lot of good advice. Two things, in particular, that would probably be helpful would be to power the devices directly and to split your network up into two or more separate, smaller 1-Wire busses.

Personally, I don't think there's bug in the OneWire library that could be responsible for your problems. On the other hand, it may be possible to improve the reliability of your existing circuit by using the library differently. For example, you can either tell all the devices to start a temperature conversion at once, or you can address them individually and ask them to do their conversions one at a time. Having them do all their conversions at once is going to draw much more power from the bus, and so I'd avoid doing that. I guess a similar issue arises with the command to have devices report their addresses, but I'm not sure whether there's an alternative there. All that said, my feeling is that you will probably need to (at a minimum) split up your network into smaller, separately powered networks if you want to support that many devices.

I just thought I'd try Jim's OneWire library and got the following errors when the Arduino environment (11) starts up:

OneWire.cpp: In constructor 'OneWire::OneWire(uint8_t)':
OneWire.cpp:74: error: 'digital_pin_to_port' was not declared in this scope
OneWire.cpp:76: error: 'port_to_output' was not declared in this scope
OneWire.cpp:77: error: 'port_to_input' was not declared in this scope
OneWire.cpp:78: error: 'port_to_mode' was not declared in this scope

OneWire.cpp and OneWire.h are in hardware/libraries/OneWire

Any ideas what went wrong?

I just thought I'd try Jim's OneWire library and got the following errors when the Arduino environment (11) starts up:

I don't think Jim's original library is usable in anything but Arduino-007. It had to be updated to work with changes in the header files in later Arduino releases, as you can see from your compile errors. I didn't start working with it until Arduino-010, myself, and have only tried using the most recently updated versions. At this point, the most recent update that I'm aware of is mine, which is referenced on the OneWire page in the playground; I would recommend you use that.

Sorry for the thread ressurection, but I appear to be having a problem similar to the one experienced by audas, except this problem occurs in my setup after a FIFTH DS1820 is added. I'm using the code on the Learning/OneWire page.

Here is an example of what happens:

Four sensors connected:
R=10 F2 36 55 0 8 0 D0 P=1 31 0 4B 46 FF FF 2 10 72 CRC=72
R=10 8A 14 55 0 8 0 92 P=1 33 0 4B 46 FF FF 3 10 30 CRC=30
R=10 E3 73 55 0 8 0 87 P=1 32 0 4B 46 FF FF E 10 FA CRC=FA
R=10 EF 4A 55 0 8 0 8D P=1 31 0 4B 46 FF FF 3 10 B6 CRC=B6
No more addresses.

Looks good... Now, I add a fifth:
R=10 F4 31 55 0 8 0 33 P=1 41 0 4B 46 FF FF 4 10 6D CRC=6D
R=10 F2 36 55 0 8 0 D0 P=1 31 0 4B 46 FF FF 4 10 D8 CRC=D8
R=10 8A 14 55 0 8 0 92 P=1 34 0 4B 46 FF FF E 10 69 CRC=69
R=10 F2 36 55 0 8 0 D0 P=1 31 0 4B 46 FF FF 4 10 D8 CRC=D8
R=10 8A 14 55 0 8 0 92 P=1 35 0 4B 46 FF FF 3 10 A3 CRC=A3
R=10 F2 36 55 0 8 0 D0 P=1 31 0 4B 46 FF FF 4 10 D8 CRC=D8
R=10 8A 14 55 0 8 0 92 P=1 35 0 4B 46 FF FF 3 10 A3 CRC=A3
R=10 F2 36 55 0 8 0 D0 P=1 31 0 4B 46 FF FF 4 10 D8 CRC=D8
...and on and on and on...

Now, of course, I thought I might have a bad sensor, so I swapped out one sensor each time, while running only four, and it worked every time. Every time I added a fifth sensor, it would loop.

I'm not running parasite power, and have the 4.7k pull-up (to +5V) resistor on the DQ line, which also goes to the Arduino. Pin 1 is going to ground, and pin 3 is connected to the same +5v source.

Anyone have any ideas?

Hi,

I am inclined to suspect a software bug perhaps in the search function. I have a bunch of sensors on a board for testing and am able to get 5 sensors reading reliably, but when I add 2-3 more sometimes it works and sometimes I get into loop mode where it never gets to the last address.

It doesn't make sense to me that a network would need to be split with just 5 sensors on a board.

  • using latest code, parasite power....

any thoughts would be greatly appreciated

Can you address more than 5 individually?
In other words not using the search function but send the command to an individual device by its id?

It could be inconvenient to get the id for each device first, depending on how many you are using.
When I got the id's for mine I used the search function in the 1-wire library and touched each in turn to raise the temperature then made a note of the ID. Keep swapping them out till youve done them all. Then I addressed each device directly to get it to send back the temperature.

I was only working with 2 devices but it was more convenient for me to know exactly which device gave which reading. Im not using the one wire library but a cut down version Ive cobbled together from numerous sources. No search functions. Just the ability to send and receive data on the bus.

If there are limitations in the 1-wire library maybe this would help?

Gordon

Excellent suggestion! I now have 20 working. So the strategy is:

  • test 3-4 at a time
  • get their ids
  • add ids to an array of known devices

thanks!

hi all,

any ideas about how to connect multiple 1-wire temp sensor DALLAS 18B20 to arduino? (not in parasite mode)......i mean the full code to view the temp of each sensor ..

thanks

hello,all, thanks jim for his onewire library.But i used the arduino 12, i got the following errors when the Arduino environment (11) starts up:

OneWire.cpp: In constructor 'OneWire:neWire(uint8_t)':
OneWire.cpp:74: error: 'digital_pin_to_port' was not declared in this scope
OneWire.cpp:76: error: 'port_to_output' was not declared in this scope
OneWire.cpp:77: error: 'port_to_input' was not declared in this scope
OneWire.cpp:78: error: 'port_to_mode' was not declared in this scope

so i have to fix it myself for i cannot open the link on background to get the recent files.

in onewire.h i add #include <pins_arduino.h>
in onewire.cpp

OneWire::OneWire( uint8_t pinArg)
{
    pin = pinArg;
    /*
    port = digital_pin_to_port[pin].port;
    bit =  digital_pin_to_port[pin].bit;
    outputReg = port_to_output[port];
    inputReg = port_to_input[port];
    modeReg = port_to_mode[port];
    */
    port = digitalPinToPort(pin);
    bit =  digitalPinToBitMask(pin);
    outputReg = port_to_output_PGM[port];
    inputReg = port_to_input_PGM[port];
    modeReg = port_to_mode_PGM[port];
#if ONEWIRE_SEARCH
    reset_search();
#endif
}

now the error is gone, but i want to know that it is right ? maybe anybody can help me or give me the right link to get recent file.thanks.

Anyone have used DS2406 switch or similar with OneWire library?

Please help, have a look on my post here
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1236262942

Thanks!!

To bring this up again.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1267881314

Maybe we find a solution some day :-/