//#include <stdlib.h>
#include <U8glib.h>
#include <dht.h>
dht DHT;
#define DHT22_PIN 5
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_NO_ACK | U8G_I2C_OPT_FAST); // Fast I2C / TWI
int progress = 0;
//int temperatur = 0;
String tmp_string ="";
void setup() {
Serial.begin(115200);
u8g.setFont(u8g_font_tpssb);
u8g.setColorIndex(1);
// progress = skalierung();
Serial.println("Starte Aufzeichnung");
//Serial.println(progress);
}
void loop() {
progress = skalierung();
//Serial.println(progress);
u8g.firstPage();
do {
u8g.drawStr(25, 41, "Thermometer");
u8g.drawFrame(0, 10, 128, 20);
u8g.drawBox(10, 15, progress, 10);
//u8g.drawStr(50, 55, tmp_string);
} while ( u8g.nextPage() );
}
int skalierung(){
DHT.read2302(DHT22_PIN);
delay(500);
float i = (DHT.temperature);
//itoa(i, tmp_string, 10);
tmp_string = String(i);
Serial.println(tmp_string);
return map(i, 12, 30, 0, 108); //map(value, fromLow, fromHigh, toLow, toHigh);
}