Top Positive Review for %s on Banggood, Shop best %s with lowest price on Banggood. Browse most helpful positive review for %s before you buy., rc toys, fun sports, fashion, popular electronics
Ken201904/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();
}
Badges are related to the community, and users earn badges by creating quality content, completing missions, or by participating in special activities.Specific people will also have their own exclusive badge.
Badges are related to the community, and users earn badges by creating quality content, completing missions, or by participating in special activities.
Helpful Badges
The Badge is awarded to users who are subscribed to the Invite Answer email and signifies their gratitude to help others. The badge appearance upgrades as the user helps more people.
OK
You are the expert,can you help?
We sincerely invite you to subscribe to the Invite Answer email!
If you subscribe, we will invite you via email to answer questions people have about products. By subscribing you'll also earn the "Helpful Badge"! You can unsubscribe at any time on the privacy settings page.
Help others and be happier!
Subscribe
Thank you for subscribing! You have also earned a badge!
Thank you! Your answer will help ###name### and ###num### other people!
Subscribe to "Invite Answer" emails and use your knowledge to help more people with product questions. By subscribing you'll also earn the "Helpful Badge"!
Subscribe
About Badges
Badges are related to the community, and users earn badges by creating quality content, completing missions, or by participating in special activities.Specific people will also have their own exclusive badge.
Badges are related to the community, and users earn badges by creating quality content, completing missions, or by participating in special activities.
Helpful Badges
The Badge is awarded to users who are subscribed to the Invite Answer email and signifies their gratitude to help others. The badge appearance upgrades as the user helps more people.
OK
You are the expert,can you help?
We sincerely invite you to subscribe to the Invite Answer email!
If you subscribe, we will invite you via email to answer questions people have about products. By subscribing you'll also earn the "Helpful Badge"! You can unsubscribe at any time on the privacy settings page.
Help others and be happier!
Subscribe
Thank you for subscribing! You have also earned a badge!
Thank you! Your answer will help ###name### and ###num### other people!
Subscribe to "Invite Answer" emails and use your knowledge to help more people with product questions. By subscribing you'll also earn the "Helpful Badge"!