Go Down

Topic: printAddress out of scope using OneWire and DallasTemperature (Read 802 times) previous topic - next topic

justjed

Well, probably something really obvious here, and I haven't written C for quite a while.

This is mostly just copy/paste from the Dallas example for multi-sensor, except I modified it to store the sensor addresses in an array. I'm using the TLC 3.6.0 library from Miles Burton, and the 1-wire v.2 from pjrc.

Code: [Select]

// just messing about with DS18B20

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

// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

int i;                 // loop counter
int numSensors;        // number of 1-wire sensors

// 1-wire device addresses using type defined in Dallas header
DeviceAddress owsAddr[8];

void setup()
{
  Serial.begin(9600);          //  setup serial

  // Start up the library
  sensors.begin();
  numSensors = sensors.getDeviceCount();
  oneWire.reset_search();
  for (i = 0; i < numSensors; i++) {
    if (oneWire.search(owsAddr[i])) {
      Serial.print("DS18B20: ");
      printAddress(owsAddr[i]);
//    ^^^^^^^^^^^^ is the error line
      Serial.println();
    } else {
      Serial.println("Something sure is goofy here!");
      delay(2000);
    }
  }
}

Error pane
Code: [Select]

onewiretest.cpp: In function 'void setup()':
onewiretest:30: error: 'printAddress' was not declared in this scope

Assuming this function had to be defined in either the OneWire or Dallas libraries, I grepped the header and .cpp files for both of those, and found nothing. I find that interesting, but of course, it could be defined someplace else.

BTW, I know I can code something up and bitshift the address out. At the moment, I just want to label my sensors so when I actually place them, I know what's where. But it bugs me that I'm getting an error on something direct from example code. Of course, that code could be wrong (did they test it before posting?).
... it is poor civic hygiene to install technologies that could someday
facilitate a police state. -- Bruce Schneier

PaulS

Quote
This is mostly just copy/paste from the Dallas example for multi-sensor

For which you didn't provide a link.

justjed


For which you didn't provide a link.


Because the way you'd get to it (provided you have the library) is from the IDE:
File->Examples->DallasTemperature->Multiple
... it is poor civic hygiene to install technologies that could someday
facilitate a police state. -- Bruce Schneier

PaulS

I downloaded the zip file. I opened, in a text editor, the Multiple.pde file that was in the zip file. On lines 90 through 98, the printAddress function is defined. Is that not the case in your copy?

justjed


I downloaded the zip file. I opened, in a text editor, the Multiple.pde file that was in the zip file. On lines 90 through 98, the printAddress function is defined. Is that not the case in your copy?


Yep, there it is. Completely obvious! :smiley-red:

Thanks, Paul.
... it is poor civic hygiene to install technologies that could someday
facilitate a police state. -- Bruce Schneier

Go Up