u8g.setFont(u8g_font_profont11); // select font
u8g.drawStr(0, 15, "Temp: "); // put string of display at position X, Y
u8g.drawStr(0, 35, "Humd: ");
u8g.setPrintPos(33, 15); // set position //u8g.print("(oF): "); //u8g.print(Fahrenheit(DHT.temperature), 0);
u8g.print(DHT.temperature, 0); // display temperature from DHT11
u8g.drawStr(50, 15, "F ");
u8g.setPrintPos(33, 35);
u8g.print(DHT.humidity, 0); // display 0 umidity from DHT11
u8g.drawStr(50, 35, "% ");
}
void setup(void) {
analogWrite(backlight_pin, 50); /* Set the Backlight intensity */
}
void loop(void) {
DHT.read11(DHTPIN); // Read apin on DHT11
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
delay(1000); // Delay of 5sec before accessing DHT11 (min - 2sec)
}
"I am trying to get the code to display in Fahrenheit not Celsius.
Fahrenheit = Celsius * (212 - 32)/100 + 32
ANY SUGGESTIONS!!!!!"
Fahrenheit = (1.8 * Centigrade) + 32
Fahrenheit = ((9 * Centigrade) / 5) + 32
[More parentheses used than order of operations requires for purpose of emphasis.]
If you use CTRL-T in the IDE you get some auto formatting,
together with some blank lines the code becomes more readable. (especially when using code tags)
See below:
#include "U8glib.h"
#include "dht.h"
#define DHTPIN 2
#define backlight_pin 11
dht DHT;
U8GLIB_PCD8544 u8g(8, 4, 7, 5, 6); // CLK=8, DIN=4, CE=7, DC=5, RST=6
void draw(void) {
u8g.setFont(u8g_font_profont11); // select font
u8g.drawStr(0, 15, "Temp: "); // put string of display at position X, Y
u8g.drawStr(0, 35, "Humd: ");
u8g.setPrintPos(33, 15); // set position
//u8g.print("(oF): ");
//u8g.print(Fahrenheit(DHT.temperature), 0);
u8g.print(DHT.temperature, 0); // display temperature from DHT11
u8g.drawStr(50, 15, "F ");
u8g.setPrintPos(33, 35);
u8g.print(DHT.humidity, 0); // display 0 umidity from DHT11
u8g.drawStr(50, 35, "% ");
}
void setup(void) {
analogWrite(backlight_pin, 50); /* Set the Backlight intensity */
}
void loop(void) {
DHT.read11(DHTPIN); // Read apin on DHT11
u8g.firstPage();
do {
draw();
} while ( u8g.nextPage() );
delay(1000); // Delay of 5sec before accessing DHT11 (min - 2sec)
}