- 关于我们
Temperatur-Messer
Messen von Luftfeuchtigkeit und Temperatur
Nico S.
German
Advanced
In diesem Projekt wird gezeigt, wie man mit Arduino Nano und OLED die Temperatur und Luftfeuchtigkeit messen kann.
Hier ist der Arduino Code:
int temp=0;
int hum=0;
void setup(){
i2c_oled_initall(i2coledssd);
Wire.begin();
Serial.begin(9600);
Serial.println(“Temperature misuration”);
Serial.println();
Serial.println(“Type,\tstatus,\tHumidity (%),\tTemperature (C)”);
}
void loop(){
char buffer[30];
char buffe [20];
disp_buffer_clear(COLOR_BLACK);
disp_print_xy_lcd(0, 0, (unsigned char*) “DEGREES”, COLOR_WHITE, 0);
disp_print_xy_lcd(0, 24, (unsigned char*) “HUMIDITY”, COLOR_WHITE, 0);
disp_lcd_frombuffer();
int stat;
Serial.print(“DHT11, \t”);
stat = DHT.read(DHT11_PIN);
switch (stat){
case DHTLIB_OK:
Serial.print(“OK,\t”);
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print(“Checksum error,\t”);
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print(“Time out error,\t”);
break;
default:
Serial.print(“Unknown error,\t”);
break;
}
// DISPLAT DATA
Serial.print(DHT.humidity,1);
Serial.print(“,\t”);
Serial.println(DHT.temperature,1);
temp = DHT.temperature ;
hum = DHT.humidity;
sprintf(buffer, “%4d Celsius”, temp);
sprintf(buffe, “%4d / 100”, hum);
disp_print_xy_lcd(0, 11 ,(unsigned char*)buffer, COLOR_WHITE, 0);
disp_print_xy_lcd(0, 35 ,(unsigned char*)buffe, COLOR_WHITE, 0);
disp_lcd_frombuffer();
delay(4000);
}