Skip to content

🌑️ Max's All-In-One IoT Sensor

A compact, ESP8266-powered temperature and humidity sensor featuring a 0.96" OLED display, onboard web server, and a custom 3D-printed enclosure. Designed for easy deployment, DIY hacking, and seamless integration with automation platforms like Home Assistant and Grafana.


βœ… Features

  • OLED Display (0.96") – Live temperature (Β°F) and humidity (%) readings on-device
  • Built-in Web Interface – Clean local web UI with auto-refreshing values
  • 3D-Printed Enclosure – Durable, airflow-friendly, and visually clean
  • DIY-Friendly – Built on the Wemos D1 Mini (ESP8266), fully programmable via Arduino IDE

πŸ§ͺ Planned Features

  • Wi-Fi Config Portal – No more hardcoded credentials; onboard captive portal
  • SQL Upload Support – Push readings to a backend for storage
  • Grafana Integration – Visualize long-term trends and environment history
  • Home Assistant Support – Expose data via MQTT or HTTP endpoints for automations
  • OTA Updates – Wirelessly update firmware as features improve

πŸ–₯️ Web Server UI Preview

Once connected to Wi-Fi, browse to the device’s IP address for real-time readings. The web interface is powered by ESPAsyncWebServer and updates dynamically every 10 seconds.


πŸ”§ Hardware + Firmware Details

  • Microcontroller: Wemos D1 Mini (ESP8266)
  • Sensor: DHT22 (Temperature + Humidity)
  • Display: SSD1306 OLED via I2C
  • Libraries Used: Adafruit_DHT, Adafruit_SSD1306, ESPAsyncWebServer, WiFi, etc.
  • Refresh Rate: Readings update every 10 seconds (OLED + web UI)

πŸ“Έ Hardware & Build Notes

  • Powered by USB or micro power source
  • Mountable or standalone form factor
  • OLED shows both live readings and debug info (e.g., firmware version)
  • Case design optimized for airflow + display visibility

πŸ“ Project Files

  • Arduino Code: Public GitHub repo [coming soon]
  • 3D Print Files: STL files under /downloads/
  • Build Guide: Will be included in the β€œSelf-Hosted Projects” series

πŸ”§ Current Running Configuration

The sensor currently runs on a Wemos D1 Mini + DHT22 + OLED, serving a minimal web page with live data.

πŸ“œ Click to view full Arduino code
// Full working example (ESP8266 + DHT22 + OLED + Web UI)
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/Picopixel.h>
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>

const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

#define DHTPIN 14
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

float t = 0.0;
float h = 0.0;
AsyncWebServer server(80);
unsigned long previousMillis = 0;
const long interval = 10000;

const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE HTML><html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>body{text-align:center;font-family:Arial}</style>
</head>
<body>
  <h2>ESP8266 DHT Server</h2>
  <p>Temperature: <span id="temperature">%TEMPERATURE%</span> Β°F</p>
  <p>Humidity: <span id="humidity">%HUMIDITY%</span> %</p>
</body>
<script>
setInterval(()=>{fetch('/temperature').then(r=>r.text()).then(t=>document.getElementById('temperature').innerHTML=t)},10000);
setInterval(()=>{fetch('/humidity').then(r=>r.text()).then(h=>document.getElementById('humidity').innerHTML=h)},10000);
</script>
</html>)rawliteral";

String processor(const String& var){
  if(var == "TEMPERATURE") return String(t);
  if(var == "HUMIDITY") return String(h);
  return String();
}

void setup(){
  Serial.begin(115200);
  dht.begin();
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) for(;;);
  WiFi.begin(ssid, password);
  while(WiFi.status()!=WL_CONNECTED){ delay(1000); }
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *req){req->send_P(200, "text/html", index_html, processor);});
  server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *req){req->send_P(200, "text/plain", String(t).c_str());});
  server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest *req){req->send_P(200, "text/plain", String(h).c_str());});
  server.begin();
}

void loop(){
  unsigned long currentMillis = millis();
  if(currentMillis-previousMillis>=interval){
    previousMillis=currentMillis;
    float newT = dht.readTemperature(true);
    float newH = dht.readHumidity();
    if(!isnan(newT)) t=newT;
    if(!isnan(newH)) h=newH;
  }
  display.clearDisplay();
  display.setCursor(0,0);
  display.setTextSize(1);
  display.print("IoT Sensor");
  display.setCursor(0,20);
  display.print("Temp: "); display.print(t); display.println(" F");
  display.setCursor(0,35);
  display.print("Hum: "); display.print(h); display.println(" %");
  display.display();
}

πŸ“Œ Reference Info

  • GPIO Reference: Wemos D1 Mini GPIO layout
  • Sensor Type: DHT22
  • Display Driver: SSD1306 via I2C (address 0x3C)

πŸ”— Resources


⚑ Built for hacking, tinkering, and learning β€” this sensor is just the start of a larger IoT ecosystem.