Dallas Onewire thermometer

Hello,
Trying to get a Dallas DS18B20 sensor going and copied code from Examples>Onewire>Onewire>Sample.
Uploaded to Duemilanove but got error "Onewire does not name a type" at third line- very new to this - any help appreciated - eventually hoping to get some some temperature and humidity data to control an extract fan when temperature drops and humidity rises. I have downloaded Onewire library but that is all.

Thanks

You have to download and import the OneWire library:

http://www.arduino.cc/playground/Learning/OneWire

Thanks for your help so far. I have downloaded the Onewire library and copied onewire.h into hardware>tools>avr>include+compat+util
Also imported library but result is the same. I have tried the Sheepdogsguide sketch for the Dallas which compiles OK, but just needs the wiring sorted and looks optimistic. I will persevere with this until something works.

tigger:
Hello,
Trying to get a Dallas DS18B20 sensor going and copied code from Examples>Onewire>Onewire>Sample.
Uploaded to Duemilanove but got error "Onewire does not name a type" at third line- very new to this - any help appreciated - eventually hoping to get some some temperature and humidity data to control an extract fan when temperature drops and humidity rises. I have downloaded Onewire library but that is all.

Thanks

FWIW, there are much, much simpler ways of getting temperature and humidity data than 1-Wire. Don't get me wrong, I do love the protocol (and have spent an outrageous sum of money on 1-wire parts over the last decade), but it's a heavy protocol. It really shines when you have a lot of devices sharing a single bus. For single, simple designs, you may want to look into one of the many i2c or SPI solutions available.

Just a suggestion...

tigger:
Thanks for your help so far. I have downloaded the Onewire library and copied onewire.h into hardware>tools>avr>include+compat+util

The library should be placed in a sub-folder within the library folder at:
\Arduino\arduino-xxxx\libraries (where xx is the version number of Arduino IDE you are using)

ie. for the current version of the Arduino IDE 0022 and the OneWire library the path would like like:
\Arduino\arduino-0022\libraries\OneWire

Also, after importing a library you usually need to restart the Arduino IDE before it recognizes it.

FYI - Not sure which version of the OneWire library you are using, but the current version is here:
http://www.pjrc.com/teensy/td_libs_OneWire.html

willnue

I’m new too and I’m trying to get a couple of Dallas 18B20s to go. I cannot get past the first few lines when compiling. I have read the above posts but still cannot get off the ground.

These are the relevant lines, the sketch is is My_1_wire. It is Miles Burton but I am calling the bus on pin3. I have not made any other changes. It is called My_1_wire.ino and loads into the IDE OK. Tghere is only the ino file in the folder.

#include <onewire .h>
#include <dallastemperature .h>
#define ONE_WIRE_BUS 3
OneWire oneWire(ONE_WIRE_BUS);

The last line above gets a yellow band over it but I see in the report below that “DallasTemperature” apparently has the same problem.

I have two folders under E:\Arduino\Arduino-1.0.1\libraries, they being OneWire and DallasTemperature, and there is a .cpp and a .h file in each, along with the text files and examples. In other wortds, I believe I have the right information in the right place. I have started the IDE from scratch after ensuring the libraries are in(/) the right place. I don’t even know if I am looking in the right place to solve this problem.

This is the error list

My_1_wire:14: error: ‘OneWire’ does not name a type
My_1_wire:17: error: ‘DallasTemperature’ does not name a type
My_1_wire.cpp: In function ‘void setup()’:
My_1_wire:28: error: ‘sensors’ was not declared in this scope
My_1_wire.cpp: In function ‘void printTemperaturesToSerial()’:
My_1_wire:45: error: ‘sensors’ was not declared in this scope
My_1_wire.cpp: In function ‘int discoverOneWireDevices()’:
My_1_wire:70: error: ‘oneWire’ was not declared in this scope
My_1_wire:82: error: ‘OneWire’ has not been declared
My_1_wire:90: error: ‘oneWire’ was not declared in this scope

I hope the problem is something simple.

willnue:
The library should be placed in a sub-folder within the library folder at:
\Arduino\arduino-xxxx\libraries (where xx is the version number of Arduino IDE you are using)

No, it should be in the Libraries folder in your sketchbook folder. See http://arduino.cc/en/Reference/Libraries, under the “Contributed Libraries” heading. On a Mac, by default, that’s in /Users//Documents/Arduino; I expect it’d be somewhere under My Documents on a Windows box.

NickPyner:

#include <onewire .h>

On my system it’s called <OneWire.h>

Did you re-start the Arduino IDE after installing the library?

Does OneWire show up under Sketch->Import library…? If not you have not installed it correctly.

Hi
I missed that and have just fixed both lines, and started over. It didn't make any difference.

What version of the IDE? If it is 1.0.1, I'd recommend not using that version until they get the damn bug fixed where missing include files are considered OK.

In my 1.0.1 installation, the OneWire example scripts don’t compile because of missing declarations, presumably due to the (expletive deleted) way the standard include files have been mucked about at version 1. Breaking all the 3rd part libraries and sketches is one thing, but is it expected that the standard examples shipped with the IDE will be broken? I know it’s free and the result of a lot of hard work and I’m grateful for that, but I can’t help rolling my eyes at the current state of it.

PeterH:
Breaking all the 3rd part libraries and sketches is one thing, but is it expected that the standard examples shipped with the IDE will be broken?

Your copy of Arduino 1.0.1 came with a OneWire library? Mine didn't. My third-party OneWire library is in the middle list of Examples, not the top list (included examples) or the bottom list (included libraries).

Oh, boy. Did I stir all this up?

Yes, I have v1.0.1. No, OneWire is not included, I followed Miles Burton recommendation and sources. He seems to be the OneWire guru. I wasn't aware of any buggy stuff. Everything seems to be fine with 1.0.1 otherwise. I guess the thing to do here is re-establish myself on a laptop using an older version. I think I have done the right thing with the files but I'm struggling to understand what the system is with files, if there is, or needs to be, one. Most of my work so far has been by copy/paste in the IDE windows. I suspect the .PDE is an invention by somebody playing the knowledge-is-power game and much the same can be said of using .rar files.

I will pursue this in parallel on a laptop, essentially as an intellectual exercise. At the moment I only have two 18B20s and at least two available pins, so I will go the Sheepdog route.

johnwasser:

PeterH:
Breaking all the 3rd part libraries and sketches is one thing, but is it expected that the standard examples shipped with the IDE will be broken?

Your copy of Arduino 1.0.1 came with a OneWire library? Mine didn't.

I thought it did - but from your comment obviously I was wrong.