user47425: I'm new to Arduino and trying to figure out how to convert Celsius to Fahrenheit with the parameters listed below. Do I need to create a separate file for the calculations? If so, can someone help me on how I can go about doing that? 
#include <DHT.h>
#include <DHT_U.h>

int SENSOR = 2;
int TEMPERATURE;
int HUMIDITY;

DHT dht(SENSOR, DHT11);

void setup() {
  Serial.begin(9600);
  dht.begin();
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  TEMPERATURE = dht.readTemperature();
  HUMIDITY = dht.readHumidity();
  Serial.print("Temp: ");
  Serial.print(TEMPERATURE);
  Serial.println(" celsius ");
  Serial.println(" ");
  Serial.print("Humidity: ");
  Serial.println(HUMIDITY);
  delay(2000);

  //Built In LED
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(250); // wait for a second
  digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
  delay(250);  
}


user37523: You could add a function to your sketch.
// Celsius to Fahrenheit conversion
double Fahrenheit(double celsius){
  return 1.8 * celsius + 32;
}

Then add this code to your loop().
Serial.print("Temp: ");
Serial.print(Fahrenheit(TEMPERATURE));
Serial.println(" fahrenheit ");


user7508: If you are using the Adafruit DHT sensor library, then you can get a
Fahrenheit reading by passing true as an argument to
readTemperature(). C.f. the comment in the source code. For
example:
Serial.print("Temp: ");
Serial.print(dht.readTemperature(true));  // true -> Fahrenheit
Serial.println(" deg. F");

Note that this library offers also the conversion functions
convertCtoF() and convertFtoC().

47425: <p>I'm new to Arduino and trying to figure out how to convert Celsius to Fahrenheit with the parameters listed below. Do I need to create a separate file for the calculations? If so, can someone help me on how I can go about doing that? </p>

<pre><code>#include &lt;DHT.h&gt;
#include &lt;DHT_U.h&gt;

int SENSOR = 2;
int TEMPERATURE;
int HUMIDITY;

DHT dht(SENSOR, DHT11);

void setup() {
  Serial.begin(9600);
  dht.begin();
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  TEMPERATURE = dht.readTemperature();
  HUMIDITY = dht.readHumidity();
  Serial.print("Temp: ");
  Serial.print(TEMPERATURE);
  Serial.println(" celsius ");
  Serial.println(" ");
  Serial.print("Humidity: ");
  Serial.println(HUMIDITY);
  delay(2000);

  //Built In LED
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(250); // wait for a second
  digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
  delay(250);  
}
</code></pre>
 37523: <p>You could add a function to your sketch.</p>

<pre><code>// Celsius to Fahrenheit conversion
double Fahrenheit(double celsius){
  return 1.8 * celsius + 32;
}
</code></pre>

<p>Then add this code to your loop().</p>

<pre><code>Serial.print("Temp: ");
Serial.print(Fahrenheit(TEMPERATURE));
Serial.println(" fahrenheit ");
</code></pre>
 7508: <p>If you are using the Adafruit DHT sensor library, then you can get a
Fahrenheit reading by passing <code>true</code> as an argument to
<code>readTemperature()</code>. C.f. <a href="https://github.com/adafruit/DHT-sensor-library/blob/1.3.0/DHT.cpp#L34" rel="nofollow noreferrer">the comment in the source code</a>. For
example:</p>

<pre class="lang-c++ prettyprint-override"><code>Serial.print("Temp: ");
Serial.print(dht.readTemperature(true));  // true -&gt; Fahrenheit
Serial.println(" deg. F");
</code></pre>

<p>Note that this library offers also the conversion functions
<code>convertCtoF()</code> and <code>convertFtoC()</code>.</p>
