Pages: [1]   Go Down
Author Topic: printAddress out of scope using OneWire and DallasTemperature  (Read 749 times)
0 Members and 1 Guest are viewing this topic.
CO, USA
Offline Offline
God Member
*****
Karma: 5
Posts: 711
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
// 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:
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?).
Logged

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 50243
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
This is mostly just copy/paste from the Dallas example for multi-sensor
For which you didn't provide a link.
Logged

CO, USA
Offline Offline
God Member
*****
Karma: 5
Posts: 711
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 50243
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

CO, USA
Offline Offline
God Member
*****
Karma: 5
Posts: 711
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

Pages: [1]   Go Up
Jump to: