ESP8266 with ALL the sensors

Well, maybe not all of them, but the whole lot that you get with "AOQDQDQD® ESP8266 Weather Station Kit with Temperature Humidity Atmosphetic Pressure Light Sensor 0.96 Display for Arduino IDE IoT Starter".

I'm not going to review the connections for the DHT11 & 1306 (those are on the first Arduino related page).
You'll need the breadboard (or some wire wrapping skills) to connect everything at once)
The BMP (pressure & temperature) sensor uses exactly the same connections as the screen.
VCC to 3V
GND to G
SCL to D1
SDA to D2

The BH1750 light sensor is connected the same too, but has an extra pin labelled ADD. Either leave it unconnected or connect it to ground.

That was simple! You'll need to install those extra libraries BMP085 & hp_1750 in order to use the sensors.

Now all that we need is a sketch to read the sensors, show them on the screen & to broadcast them to the MQTT broker. It's fairly long, but is really just an extension of the shorter ones on the previous page. Credit to randomnerdtutorials, Stefan Armborst & probably someone else - I've just merged these into a single sketch that is entirely self hosted.

Copy the sketch to your Arduino IDE, then edit: ssid, password, TOPIC_BASE, xxx, yyy (& any of the other #define lines that you want to ) & you should be good to go.
N.B. the server only shows the DHT11 temp & pressure - I'm sure that you could extend it to show more if you wanted to.

// Import required libraries
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <Hash.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <Ticker.h>
#include <AsyncMqttClient.h>
// Extra for display
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Extra for BMP180 sensor
#include <Adafruit_BMP085.h>
// Extra for BH1750FVI
#include <hp_BH1750.h>

// Replace with your network credentials
const char* ssid = "MY_WIFI_SSID";
const char* password = "MY_WIFI_PASSWORD";

//server ID
#define TOPIC_BASE "8266"

#define DHTPIN 0         // Digital pin connected to the DHT sensor (marked D3 on the board!)
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define SCREEN_ADDRESS 0x3C // For the Geekcreit 1306 displays
#define OLED_RESET -1

// Uncomment the type of sensor in use:
#define DHTTYPE    DHT11     // DHT 11
//#define DHTTYPE    DHT22     // DHT 22 (AM2302)
//#define DHTTYPE    DHT21     // DHT 21 (AM2301)

//  Mosquitto MQTT Broker
#define MQTT_HOST IPAddress(192, 168, xxx, yyy)
// For a cloud MQTT broker, type the domain name
//#define MQTT_HOST ""
#define MQTT_PORT 1883

// MQTT Topics
#define MQTT_PUB_TEMP TOPIC_BASE "/dht/temperature"
#define MQTT_PUB_HUM TOPIC_BASE "/dht/humidity"
#define MQTT_PUB_TEMP2 TOPIC_BASE "/bmp/temperature"
#define MQTT_PUB_PRESS TOPIC_BASE "/bmp/pressure"
#define MQTT_PUB_LUX TOPIC_BASE "/bh/light"

// Initialize DHT sensor

//Initialise display
// SDA = pin D2
// SCL = pin D1

// Initialise the BMP180 sensor
Adafruit_BMP085 bmp;

// Initialise the BH1750 light sensor
hp_BH1750 BH1750;

// Variables to hold sensor readings
// current temperature & humidity, updated in loop()
float t = 0.0;
float h = 0.0;
bool d = true;

AsyncMqttClient mqttClient;
Ticker mqttReconnectTimer;

WiFiEventHandler wifiConnectHandler;
WiFiEventHandler wifiDisconnectHandler;
Ticker wifiReconnectTimer;

// Create AsyncWebServer object on port 80
AsyncWebServer server(80);

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;    // will store last time DHT was updated

// Updates DHT readings every 10 seconds
const long interval = 10000;

void connectToWifi() {
  Serial.println("Connecting to Wi-Fi...");
  WiFi.begin(ssid, password);

void onWifiConnect(const WiFiEventStationModeGotIP& event) {
  Serial.println("Connected to Wi-Fi.");

void onWifiDisconnect(const WiFiEventStationModeDisconnected& event) {
  Serial.println("Disconnected from Wi-Fi.");
  mqttReconnectTimer.detach(); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi
  wifiReconnectTimer.once(2, connectToWifi);

void connectToMqtt() {
  Serial.println("Connecting to MQTT...");

void onMqttConnect(bool sessionPresent) {
  Serial.println("Connected to MQTT.");
  Serial.print("Session present: ");

void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
  Serial.println("Disconnected from MQTT.");

  if (WiFi.isConnected()) {
    mqttReconnectTimer.once(2, connectToMqtt);

void onMqttPublish(uint16_t packetId) {
  Serial.print("Publish acknowledged.");
  Serial.print("  packetId: ");

const char index_html[] PROGMEM = R"rawliteral(
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
    html {
     font-family: Arial;
     display: inline-block;
     margin: 0px auto;
     text-align: center;
    h2 { font-size: 3.0rem; }
    p { font-size: 3.0rem; }
    .units { font-size: 1.2rem; }
      font-size: 1.5rem;
      padding-bottom: 15px;
  <h2>ESP8266 DHT Server</h2>
    <i class="fas fa-thermometer-half" style="color:#059e8a;"></i> 
    <span class="dht-labels">Temperature</span> 
    <span id="temperature">%TEMPERATURE%</span>
    <sup class="units">&deg;C</sup>
    <i class="fas fa-tint" style="color:#00add6;"></i> 
    <span class="dht-labels">Humidity</span>
    <span id="humidity">%HUMIDITY%</span>
    <sup class="units">%</sup>
setInterval(function ( ) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("temperature").innerHTML = this.responseText;
  };"GET", "/temperature", true);
}, 10000 ) ;

setInterval(function ( ) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("humidity").innerHTML = this.responseText;
  };"GET", "/humidity", true);
}, 10000 ) ;

// Replaces placeholder with DHT values
String processor(const String& var) {
  if (var == "TEMPERATURE") {
    return String(t);
  else if (var == "HUMIDITY") {
    return String(h);
  return String();

void show(float temp,float hud, int pres, float lux) {
  if (d = true) {
    float p = pres/1000;
    display.printf("%.1f", p);
    display.print(" kPa");
    display.printf("%.1f", temp);
    display.printf("%.1f", lux);
    display.print(" lux");
    display.printf("%.1f", hud);

void setup() {
  // Serial port for debugging purposes
  // Give us a chance to get things running
  // Initialize the I2C bus
  // On esp8266 devices you can select SCL and SDA pins using Wire.begin(D4, D3);
  Serial.println("Starting up...");
  // Start the DHT11 sensor readings
  // Start the BMP180 sensor readings
  if (!bmp.begin()) {
  // BMP180 Error display
    Serial.println("Didn't find the BMP180 sensor");
  //Start Up the light sensor
  bool avail = BH1750.begin(BH1750_TO_GROUND);

  // Start up the display
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    d = false;
   }  else {
    // Show initial display buffer contents on the screen --
    // the library initializes this with an Adafruit splash screen.
    delay(2000); // Pause for 2 seconds
    // Clear the buffer

  wifiConnectHandler = WiFi.onStationModeGotIP(onWifiConnect);
  wifiDisconnectHandler = WiFi.onStationModeDisconnected(onWifiDisconnect);

  mqttClient.setServer(MQTT_HOST, MQTT_PORT);
  // If your broker requires authentication (username and password), set them below
  //mqttClient.setCredentials("REPlACE_WITH_YOUR_USER", "REPLACE_WITH_YOUR_PASSWORD");


  // Print ESP8266 Local IP Address

  // Route for root / web page
  server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send_P(200, "text/html", index_html, processor);
  server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send_P(200, "text/plain", String(t).c_str());
  server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send_P(200, "text/plain", String(h).c_str());

  // Start server

void loop() {
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    // save the last time you updated the DHT values
//    showTemp(t,h);   // show temp on screen
    previousMillis = currentMillis;
    // Read temperature as Celsius (the default)
    float newT = dht.readTemperature();
    // Read temperature as Fahrenheit (isFahrenheit = true)
    //float newT = dht.readTemperature(true);
    // if temperature read failed, don't change t value
    if (isnan(newT)) {
      Serial.println("Failed to read from DHT sensor!");
    else {
      t = newT;
      // Publish an MQTT message on topic MQTT_PUB_TEMP
      uint16_t packetIdPub1 = mqttClient.publish(MQTT_PUB_TEMP, 1, true, String(t).c_str());
      Serial.printf("Publishing on topic %s at QoS 1, packetId: %i ", MQTT_PUB_TEMP, packetIdPub1);
      Serial.printf("Message: %.2f \n", t);
    // Read Humidity
    float newH = dht.readHumidity();
    // if humidity read failed, don't change h value
    if (isnan(newH)) {
      Serial.println("Failed to read from DHT sensor!");
    else {
      h = newH;
      // Publish an MQTT message on topic MQTT_PUB_HUM
      uint16_t packetIdPub2 = mqttClient.publish(MQTT_PUB_HUM, 1, true, String(h).c_str());
      Serial.printf("Publishing on topic %s at QoS 1, packetId %i: ", MQTT_PUB_HUM, packetIdPub2);
      Serial.printf("Message: %.2f \n", h);
   //Read Pressure
   int newP = bmp.readPressure();
   if (isnan(newP)) {
      Serial.println("Failed to read from BMP180 sensor!");
    else {
      uint16_t packetIdPub3 = mqttClient.publish(MQTT_PUB_PRESS, 1, true, String(newP).c_str());
      Serial.printf("Publishing on topic %s at QoS 1, packetId %i: ", MQTT_PUB_PRESS, packetIdPub3);
      Serial.print("Message: ");
    //Read BMP180 Temperature
   float BMPt = bmp.readTemperature();
   if (isnan(BMPt)) {
      Serial.println("Failed to read from BMP180 sensor!");
    else {
      uint16_t packetIdPub4 = mqttClient.publish(MQTT_PUB_TEMP2, 1, true, String(BMPt).c_str());
      Serial.printf("Publishing on topic %s at QoS 1, packetId %i: ", MQTT_PUB_TEMP2, packetIdPub4);
      Serial.printf("Message: %.2f \n", BMPt);
   //Read BH1750 Light level
   if (BH1750.hasValue() == true) {
      float lux = BH1750.getLux();
      uint16_t packetIdPub5 = mqttClient.publish(MQTT_PUB_LUX, 1, true, String(lux).c_str());
      Serial.printf("Publishing on topic %s at QoS 1, packetId %i: ", MQTT_PUB_LUX, packetIdPub5);
      Serial.print("Message: ");
      show(t,h,newP,lux);   // show data on screen
    else {
    show(t,h,newP,0);   // show data on screen