error message help

Hi! I am currently trying to program a DS18B20 temperature sensor on a Moteino using Arduino. I have had some trouble with errors and I wanted to know if anyone could help me out.

Has anyone seen these errors before or does anyone have tips?

temp.ino: In function 'void printTemp()': temp:24: error: 'Temp' was not declared in this scope 'Temp' was not declared in this scope

WARNING: Category 'Sensor' in library DallasTemperature is not valid. Setting to 'Uncategorized' WARNING: Category 'Sensor' in library DallasTemperature is not valid. Setting to 'Uncategorized'

Thank you!

Please post your code, you'll get faster help.

Sounds like the Temp variable is not declared within the scope you're trying to call it from on line 24. You've either forgotten to declare it, or you've defined it elsewhere, but it's out of scope where you reference it.

Beyond that, we can't help, since you haven't posted your code.

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

void setup(void) {
Serial.begin(9600);
}

double Thermister(int RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 50000));
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
Temp = Temp - 273.15; // Convert Kelvin to Celcius
return Temp;
}

void printTemp(void) {
double fTemp;
double temp = Thermister(analogRead(0)); // Read sensor
Serial.print(“Temperature is:”);
Serial.print(temp);
Serial.print(" C / “);
Temp = (temp * 1.8) + 32.0; // Convert to USA
Serial.print(fTemp);
Serial.println(” F");
}

void loop(void) {
printTemp();
delay(1000);
}

Temp = (temp * 1.8) + 32.0;    // Convert to USA

What is the scope of this reference to Temp? What is the scope of this reference to temp? Case matters.

What is the scope of the variable Temp?

Do you understand what scope means?

I think it connects a variable to an entity, but I'm not sure. Thank you so much for your help!

This may help: https://www.arduino.cc/en/Reference/Scope

I think it connects a variable to an entity

No. It defines the portion of the program where the variable is accessible. The Temp variable is defined in the Thermister() function, which means that it is accessible only in that function. The temp variable is defined in the printTemp() method, which means that it is accessible only in that function.

Scope can be limited to a block, a function, a file or an entire application.

You should also read Nick Gammon's two posts at the top of this Forum for guidelines on posting here, especially the use of code tags. It will help us help you.