For fast transaction call 0916.457.0748
Wemos D1 Temperature Reading with Display

Wemos D1 Temperature Reading with Display

 The D1 mini Pro is designed to allow Wemos compatible shields to be plugged into the board in a similar way to the Arduino development board platform which greatly expands its capabilities.

This tutorial, we'll be using two of the Wemos compatible shield for us to get Temperature and show it on our Display.

Things you'll need:

  • Wemos D1 Mini
  • Wemos D1 Shield DHT11
  • Wemos D1 Shield OLED
  • Wemos D1 Shield Dual Base

Building the Code:

Before you can upload the code to your Wemos.
Download and include first the following library:

Instruction here how to install Wemos Board.
Please follow Installing with Boards Manager!

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_SSD1306.h"
#include <DHT.h>

#define OLED_RESET 0 // GPIO0
Adafruit_SSD1306 display(OLED_RESET);

#define DHTPIN D4
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

void setup()
{
Serial.begin(115200);
dht.begin();

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.display();
}

void loop()
{
delay(1000);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(32,8);

float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
float bat = ESP.getVcc();// / 1024;
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

//Temperature in Celcius
display.print("T: ");
display.print(t);
display.println(" C");
//Humidity in %
display.setCursor(32,18);
display.print("H: ");
display.print(h);
display.println(" %");
display.display();
}

 

Copy code to your Arduino IDE.

Select Board: "Wemos D1 R2 & mini"

 Please take note of the following details:

 

Upload the code.
That's it!

 

Happy Coding!


0 comments

Leave a comment

Please note, comments must be approved before they are published

Payment Methods

Facebook Rewards Program