I have a question for the knowledgeable members of the forum , with regards to Temp, Humi, and Press.
Question 1. I have a 12864J display running U8glib, DS3231, DHT11, showing time and date but am having trouble to get the DHT11 to show temp C/F on the display, I have looked at the tutorial on U8g and am having trouble understanding the draw.str function to show temp C/F.
Have includes the program for Q1,
#include "U8glib.h"
#include <DS1307.h>
#include "DHT.h"
U8GLIB_ST7920_128X64_4X u8g(4,3,2); //12864J display
//U8GLIB_ST7920_128X64_1X u8g(10); //12864ZW display
DS1307 rtc(A4, A5);
#define DHTPIN 7
#define DHTTYPE DHT11
float t=0;
int a,b;
int tempC, rh, tempF, tempI;
byte zero = 0x00;
DHT dht(DHTPIN,DHTTYPE);
void setup()
{
// flip screen, if required
//u8g.setRot180();
// Set the clock to run-mode
rtc.halt(false);
// The following lines can be commented out to use the values already stored in the DS1307
//rtc.setDOW(WEDNESDAY); // Set Day-of-Week to SUNDAY
//rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format)
//rtc.setDate(3, 10, 2010); // Set the date to October 3th, 2010
}
void loop()
{
/* Start of a picture loop */
u8g.firstPage();
/* Keep looping until finished drawing screen */
do
{
/* Set the font */
u8g.setFont(u8g_font_courB14);
u8g.drawStr( 22, 22, rtc.getTimeStr());
u8g.setFont(u8g_font_6x10);
u8g.drawStr( 50, 35, rtc.getDateStr());
u8g.setFont(u8g_font_6x10);
u8g.drawStr( 23, 35, rtc.getDOWStr(FORMAT_SHORT));
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
float i = dht.computeHeatIndex(f, h); //Heat Index
tempF = (int)(tempC * 9.0 / 5.0) + 32.0;
tempC = (int)t;
tempI = (int)i;
rh = (int)h;
/* Draw a simple border */
u8g.drawFrame(3,3,121,58);
u8g.setFont(u8g_font_6x10);
u8g.drawStr( 15, 45, "Temp");
//u8g.drawStr( 45, 45, ); //Temp C here
u8g.setFont(u8g_font_6x10);
u8g.drawStr( 60, 45, "C");
u8g.setFont(u8g_font_6x10);
//u8g.drawStr( 70, 45, ); //Temp F here
u8g.drawStr( 90, 45, "F");
}while(u8g.nextPage());
}
Hope someone can help.
How to part 2 has been re posted