كل الرسائل

Ken2019 04/12/2019
Here is a sample program which shows the temperature and humidity at the display and on the serial port as well #include #include #include #include DHTesp dht; #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); void setup() { Serial.begin(115200); Serial.println("\n\nThe board name is: " ARDUINO_BOARD); Wire.begin(2,14); // Initialize i2c bus dht.setup(5, DHTesp::DHT11); // Connect DHT sensor to GPIO 5 if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c)) { Serial.println(F("SSD1306 allocation failed")); for(;;); } delay(2000); display.clearDisplay(); display.setTextColor(WHITE); } void loop() { delay(2000); // read temperature and humidity delay(dht.getMinimumSamplingPeriod()); float h = dht.getHumidity(); float t = dht.getTemperature(); if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); } // clear display display.clearDisplay(); // display temperature display.setTextSize(1); display.setCursor(0,0); display.print("Temperature: "); Serial.print("Temperature: "); display.setTextSize(2); display.setCursor(0,10); display.print(t); Serial.println(t); display.print(" "); display.setTextSize(1); display.cp437(true); display.write(167); display.setTextSize(2); display.print("C"); // display humidity display.setTextSize(1); display.setCursor(0, 35); display.print("Humidity: "); display.setTextSize(2); display.setCursor(0, 45); display.print(h); Serial.print("Humidity : "); Serial.println(h); display.print(" %"); display.display(); }
0
التوصيات
تعليقات (0)

سؤال: What price will be on the packet?

السؤال بواسطة Ken2019 على 2019-06-10 05:28:56

liaohuizhen Dear customer,welcome.As for the price of the package,you could refer to the price of the front desk.Hope that could help you.Wish you a happy shopping experience.

2019-08-05 05:08:06 مساعدة (0)
عرض
أجابات (1)