onewire and dallas libraries

I am looking for a general explanation of the onewire and dallas temperature libraries. I am very new to this and don't understand the example sketches very well. Even a listing of the key words and their general syntax would be helpful. There seems to be many example sketches but limited explanation.

for example the following statement;

// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;

it doesn't look like an array to me

steve

This is the page for OneWire:
http://playground.arduino.cc/Learning/OneWire

There is a slide show, click on the link for the Presentation:

You don't have to understand the Dallas Temperature libraries. The protocol for the DS18B20 contains a lot of magical numbers and timing, which I don't understand.

Nor me.

Here is the best tutorial I know of

It might be a bit over the top to say it's the only tutorial that is any good but, as far as I'm concerned, it's the only tutorial that is any good. I had a bad time starting with DS18B20, and I don't think it is over the top to say there is is a lot of badly explained junk out there.

thanks, I have studied those. Is there a place that explains the keywords?

// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;

is DeviceAddress a keyword. I just don't understand this statement

steve

murmsk:
thanks, I have studied those. Is there a place that explains the keywords?

Probably not, but I only say this because I have never heard of keywords. All you need is in the link I provided . There is no reference to keywords therein, I guess this is because you don't need them.

// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;

is DeviceAddress a keyword. I just don't understand this statement

No surprise there. It may be, but probably isn't, a keyword, it is most likely junk. I don't think you have read through the Hacktronics programme properly. Now is a really good time to do that, as the reference is perfectly clear.

DeviceAddress is a definition. It states what a device address is. Something = something

DeviceAddress dogHouse = { 0x28, 0x59, 0xBE, 0xDF, 0x02, 0x00, 0x00, 0x9F };

Henceforth every time you say dogHouse, Arduino knows that means the sensor at {0x28, ....tralala}, the address.

ah that makes sense ...... so it is like defining a data type int or byte

thanks steve

In this section

void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 8; i++)
{
// zero pad the address if necessary
if (deviceAddress < 16) Serial.print("0");
_ Serial.print(deviceAddress*, HEX);_
_
}_
_
}_
_
I don't understand the usage of DeviceAddress or deviceAddress*_
further deviceAddress is not defined anywhere that I can find
steve

murmsk:
so it is like defining a data type int or byte

It's a bit more than that.

float inTemp merely tells you that inTemp will be a float - the type. The value comes later.

DeviceAddress dogHouse = ... is followed by specific information

murmsk:
In this section

void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 8; i++)
{
// zero pad the address if necessary
if (deviceAddress < 16) Serial.print("0");
_ Serial.print(deviceAddress*, HEX);_
_
}_
_
}_
_
I don't understand the usage of DeviceAddress or deviceAddress*_
further deviceAddress is not defined anywhere that I can find
[/quote]
The line
*_ <em>*  for (uint8_t i = 0; i < 8; i++)*</em> _*
suggests this is code to retrieve the address from the DS18B20, which is read in eight blocks . It comes from God knows where and not part of the material from Hacktronics. I suggest you stick with the latter. There is a link to the separate programme for that purpose therein.

DeviceAddress is defined in the library itself in the file DallasTemperature.h

typedef uint8_t DeviceAddress[8];

Pete

I am still having a hard time conceptually understanding exactly what DeviceAddress and deviceAddress is and how to use them.

as explained the array DeviceAddress insideaddress, outsideaddress means whenever insideaddress is used it means the device at a certain address

In the dallas example there is a function that is defined as follows

void printTemperature(DeviceAddress deviceAddress) {.....

}

because there is no comma between DeviceAddress and deviceAddress it must be a single argument ..... right?

it is called with the following statement

printTemperature (insideAddress);

why are both needed to define?

I just don't understand

thanks to all who have tried to help me.

steve

void printTemperature(DeviceAddress deviceAddress) {

This says that the printTemperature function requires one argument which must be of type DeviceAddress and in the function definition it will be referred to as deviceAddress. The definition of DeviceAddress in DallasTemperature.h means that the statement is exactly equivalent to:

void printTemperature(uint8_t deviceAddress[]) {

i.e. deviceAddress is a pointer to an array of unsigned characters, and specifically an array of length 8.

printTemperature (insideAddress);

This calls the function with an address which must have been defined, and filled in, earlier in the program.

Pete