Help converting pointer to integer, please?!

I am almost done with a project in which I have 2 DallasOneWire sensors and a DHT11 returning temps. I want to compare the dewpoint from the DHT11 to the temps on the Dallas sensors. I have the dewpoint converted to an integer but when I try to convert the dallas sensors to an integer I keep running into issues. They are set as pointers and I don't know how to convert to integer.

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#include <dht11.h>
#include <math.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
dht11 DHT11;

#define ONE_WIRE_BUS 3
#define DHT11PIN 2

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

DeviceAddress OTA={0x28, 0x94, 0xBB, 0x60, 0x03, 0x00, 0x00, 0x38};
DeviceAddress EP={0x28, 0xFE, 0xF6, 0xB6, 0x03, 0x00, 0x00, 0x39};

void setup() {

Serial.begin(9600);

sensors.begin();
sensors.setResolution(OTA, 10);
sensors.setResolution(EP, 10);

lcd.begin(16,2);
lcd.clear();

pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
}

void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);


Serial.println(DallasTemperature::toFahrenheit(tempC));
if (tempC == -127.00) {
lcd.print("XX");
} else {
lcd.print((int)(DallasTemperature::toFahrenheit(tempC)));
}
}

void loop(void)
  {

int chk = DHT11.read(DHT11PIN);

//Lcd display for ambient temp, humidity and dew point on line 1.  Remote temps for OTA and EP on line 2.
lcd.setCursor(0,0);
lcd.print("T");
lcd.print((int)DHT11.fahrenheit(), DEC);
lcd.setCursor(5,0);
lcd.print("H");
lcd.print((int)((float)DHT11.humidity), DEC);
lcd.print("%");
lcd.setCursor(10,0);
lcd.print("Dew");
lcd.print((int)((DHT11.dewPointFast()*1.8+32)), DEC);

sensors.requestTemperatures();
lcd.setCursor(0,1);
lcd.print("OTA ");
printTemperature(OTA);
lcd.print(" ");
lcd.setCursor(9,1);
lcd.print("EP ");
printTemperature(EP);
lcd.print("  ");

int DEW = ((int)((DHT11.dewPointFast()*1.8+32))); //converts dewpoint to an integer for comparison at end of code
int Scope = (char)OTA; 

//if(OTA <= DEW){
//digitalWrite(6,HIGH);
//Serial.print("The heater is on");
//}

delay(2000);

  }}

this is the source of the issue int Scope = (char)OTA;

lcd.print((int**)**(DallasTemperature::toFahrenheit(tempC)));

I've bolded what appears to be an errant right parenthesis. I think you want:

lcd.print(int(DallasTemperature ...

Delta_G:
No, that's the right way to do a cast. But in this case you don't want to cast. You want to dereference. To get the thing that a pointer points to, use the * operator.

Also, here's the function being called:

float DallasTemperature::getTempC(uint8_t* deviceAddress)
{
  // TODO: Multiple devices (up to 64) on the same bus may take some time to negotiate a response
  // What happens in case of collision?

  ScratchPad scratchPad;
  if (isConnected(deviceAddress, scratchPad)) return calculateTemperature(deviceAddress, scratchPad);
  return DEVICE_DISCONNECTED;
}

Been a while since I messed with this, but I believe it returns a float, not a pointer.

justjed:
Been a while since I messed with this, but I believe it returns a float, not a pointer.

As others have pointed out getTempC is a function that takes a pointer to the device address:

float DallasTemperature::getTempC(uint8_t* deviceAddress);

If you say ((int)DallasTemperature::getTempC) you are trying to convert the address of the function to an integer. You need to add the opening '(', arguments, and close ')' to call the function.

Also I think the line:
lcd.print((int)((float)DHT11.humidity), DEC)

should be:
lcd.print((int)((float)DHT11.humidity()), DEC);

Also I think the line:
lcd.print((int)((float)DHT11.humidity), DEC)

should be:
lcd.print((int)((float)DHT11.humidity()), DEC);

This returned the following error: 'DHT11.dht11::humidity' cannot be used as a function

Did you try it the way I suggested?

JustJed,
when i copy your code and add it in, I get this error: a function-definition is not allowed here before '{' token

I haven't been able to fix it, but I am fishing in the dark as I don't have a clue what I am doing. This is my first project ever.

It means you have put the function inside another function.
Put the added code at the end after the last }
Then call the function from where you are trying to put it at the moment.

Okay, got it put in the right place. I am using 2 Dallas sensors and think that is the next hurdle. Now a new set of errors:

DallasTemperature\DallasTemperature.cpp.o: In function DallasTemperature::getTempC(unsigned char*)': C:\Users\User\Downloads\Arduino\arduino-1.0\libraries\DallasTemperature/DallasTemperature.cpp:463: multiple definition of DallasTemperature::getTempC(unsigned char*)'
Dual_sensor_DHT11_and_LCD_simplified.cpp.o:C:\Users\User\AppData\Local\Temp\build8552269310572340016.tmp/Dual_sensor_DHT11_and_LCD_simplified.cpp:83: first defined here

multiple definition of `DallasTemperature::getTempC(unsigned char*)'

Seems pretty clear to me - you've defined the same function more than once.
I'd be able to help better if I could see the code.

Here is the updated code. The error comes from the loop section near the bottom.

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#include <dht11.h>
#include <math.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
dht11 DHT11;

#define ONE_WIRE_BUS 3
#define DHT11PIN 2

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

DeviceAddress OTA={0x28, 0x94, 0xBB, 0x60, 0x03, 0x00, 0x00, 0x38};
DeviceAddress EP={0x28, 0xFE, 0xF6, 0xB6, 0x03, 0x00, 0x00, 0x39};

void setup() {

Serial.begin(9600);

sensors.begin();
sensors.setResolution(OTA, 10);
sensors.setResolution(EP, 10);

lcd.begin(16,2);
lcd.clear();

pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
}

void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);


Serial.println(DallasTemperature::toFahrenheit(tempC));
if (tempC == -127.00) {
lcd.print("XX");
} else {
lcd.print(int(DallasTemperature::toFahrenheit(tempC)));
}

}

void loop(void)
  {

int chk = DHT11.read(DHT11PIN);

//Lcd display for ambient temp, humidity and dew point on line 1.  Remote temps for OTA and EP on line 2.
lcd.setCursor(0,0);
lcd.print("T");
lcd.print((int)DHT11.fahrenheit(), DEC);
lcd.setCursor(5,0);
lcd.print("H");
lcd.print((int)((float)DHT11.humidity), DEC);
lcd.print("%");
lcd.setCursor(10,0);
lcd.print("Dew");
lcd.print((int)((DHT11.dewPointFast()*1.8+32)), DEC);

sensors.requestTemperatures();
lcd.setCursor(0,1);
lcd.print("OTA ");
printTemperature(OTA);
lcd.print(" ");
lcd.setCursor(9,1);
lcd.print("EP ");
printTemperature(EP);
lcd.print("  ");
  }

int DEW = ((int)((DHT11.dewPointFast()*1.8+32))); //converts dewpoint to an integer for comparison at end of code
//int Scope = (char)OTA; 
float DallasTemperature::getTempC(uint8_t* deviceAddress)
{
  // TODO: Multiple devices (up to 64) on the same bus may take some time to negotiate a response
  // What happens in case of collision?

  ScratchPad scratchPad;
  if (isConnected(deviceAddress, scratchPad)) return calculateTemperature(deviceAddress, scratchPad);
  return DEVICE_DISCONNECTED;



Serial.print("OTA:");
printTemperature(OTA);
Serial.print("Scope:");
//Serial.println(Scope);
Serial.print("EP:");
printTemperature(EP);
Serial.print("DewPoint:");
Serial.println((int)((DHT11.dewPointFast()*1.8+32)));
Serial.print("Dew:");
Serial.println(DEW);
Serial.println();

//if(OTA <= DEW){
//digitalWrite(6,HIGH);
//Serial.print("The heater is on");
//}

delay(2000);

  }

If you applied the auto format tool to your code, I'd bet you'd be able to spot your error.

Did that. No changes necessary for auto format.

Looks better though, doesn't it?

Is it anything to do with this line?

float DallasTemperature::getTempC(uint8_t* deviceAddress)

(I don't have your libraries, so you're going to have to work the problem a little more)

Yes, that seems to be the line causing problems. I have no clue what i am doing. I have never done coding before and never taken a class on it either.

The compiler is telling you that it already knows about a function called

float DallasTemperature::getTempC(uint8_t* deviceAddress)

Why are you telling it it needs another?

I put it in because someone else suggested it. Ultimately all i want is to be able to compare OTA and EP to DewPoint.

mitaccio:
I put it in because someone else suggested it. Ultimately all i want is to be able to compare OTA and EP to DewPoint.

Well, no. That code that I posted was the code found in the DallasTemperature library. I posted it to show that it doesn't return a pointer. I did not suggest that you paste that into your code.

I understand that this can be frustrating, but if you want to succeed, you will need to learn to read more carefully, and also don't just paste code into your sketch willy-nilly.

Sorry JustJed. You were right. I was frustrated and tired. I am looking over the Dallas library for ways to convert from 'uint8_t*' to 'int'. Not finding it, but I am learning.

mitaccio:
Sorry JustJed. You were right. I was frustrated and tired. I am looking over the Dallas library for ways to convert from 'uint8_t*' to 'int'. Not finding it, but I am learning.

There is no reason I can think of for you to do that. The unsigned int there is the device address. In fact, you declared these in your code:

DeviceAddress OTA={0x28, 0x94, 0xBB, 0x60, 0x03, 0x00, 0x00, 0x38};

So there's no need to cast them when using them in function calls. For example:

    sensors.requestTemperaturesByAddress(OTA);
    tempF = sensors.getTempF(OTA);

In the above, tempF is a float. Once you've retrieved that, then

  Serial.println(int(tempF));

Now, Delta_G has said some generic stuff about using pointers in C and C++ and that's good to know. But don't get wrapped in any of these comments too much, because you don't need to use and dereference any pointers to get your sketch to do what you want it to do.

Now, if you want to know what a 'DeviceAddress' is, then look in the DallasTemperature.h file, where you'll find the typedef which defines it.