π‘οΈ 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:
SSD1306via I2C (address0x3C)
π Resources¶
β‘ Built for hacking, tinkering, and learning β this sensor is just the start of a larger IoT ecosystem.