Written by: ekwoster.dev on Thu Oct 16

πŸ’» MicroPython on a $3 Board: Real-Time IoT Dashboard with Zero Cloud Costs!

πŸ’» MicroPython on a $3 Board: Real-Time IoT Dashboard with Zero Cloud Costs!

Cover image for πŸ’» MicroPython on a $3 Board: Real-Time IoT Dashboard with Zero Cloud Costs!

πŸ’» MicroPython on a $3 Board: Real-Time IoT Dashboard with Zero Cloud Costs!

If you think you need a Raspberry Pi, AWS, or thousands of dollars to build real-time IoT dashboards, you’ll be blown away by what MicroPython and a $3 ESP8266 board can do.

In this post, we’ll walk through how to use MicroPython on the popular ESP8266 microcontroller to stream sensor data (like temperature and humidity) directly to a real-time web dashboard β€” no cloud platform, no third-party services, and no cost beyond your WiFi and coffee.

This is not a toy example. We'll build an actual live dashboard that runs entirely on the chip using HTTP and WebSocket protocols. This is the power of embedded servers + Python + modern web tech.


🧠 Why MicroPython?

Most people know Python as a desktop/server scripting language, but MicroPython is a lean, efficient implementation of Python meant to run on microcontrollers.

Benefits:

  • Full control in Python β€” ditch the C headaches
  • Tiny memory footprint (can run with 128KB RAM!)
  • Rapid prototyping for IoT and hardware hacking
  • Built-in modules for networking, file I/O, and peripherals

Supported Boards: ESP8266, ESP32, STM32, and many others.


πŸ› οΈ The Hardware Setup

  • Microcontroller: NodeMCU / WeMos D1 Mini (ESP8266, ~$3)
  • Sensor: DHT11 or DHT22 (Temperature + Humidity)
  • USB cable + Laptop

Wiring:

DHT11 -> ESP8266
VCC   -> 3.3V
GND   -> GND
DATA  -> D4 (GPIO2)

πŸ§ͺ Step 1: Flashing MicroPython

Download MicroPython firmware.

Flash it using esptool.py:

pip install esptool
esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 <firmware-file>.bin

Now connect with REPL via screen or Thonny IDE.


πŸ“¦ Step 2: The MicroPython Web Server

Let’s host a tiny server that:

  • Reads the sensor values
  • Serves a basic HTML page
  • Uses WebSocket for real-time updates

main.py

import network
import socket
import uasyncio as asyncio
from machine import Pin
import dht
...

loop = asyncio.get_event_loop()
loop.create_task(asyncio.start_server(serve_client, "0.0.0.0", 80))
loop.run_forever()

Upload main.py using ampy or WebREPL.


πŸš€ Run and View

  1. Power up the ESP8266
  2. Open your browser and navigate to the IP (e.g., 192.168.1.42)
  3. Watch real-time sensor data update every 2 seconds β€” no refresh!

🧠 What's Happening Under the Hood?

  • ESP8266 runs both a simple HTTP server and WebSocket logic
  • On every connection, the WebSocket stream pushes fresh sensor data
  • The client reads and updates the DOM β€” all without any cloud services

🚨 Downsides to Be Aware Of

  • The ESP8266 has limited RAM (~50KB usable)
  • No SSL/TLS support in MicroPython (don't expose over the internet unprotected)
  • WebSocket over HTTP, not secure WebSocket (wss)

But for LAN dashboards, DIY home sensors, or educational demos, this is magic.


🧱 How to Scale This Up

You can extend the setup to multiple sensors or rooms:

  • Add routing paths to serve different sensors
  • Hook in a lightweight frontend framework like Vue.js or HTMX
  • Push data to a local server on a Raspberry Pi or local NAS

Want historical data? Use SPIFFS on the flash or store logs over HTTP to your own backend.


πŸ”Œ TL;DR

  • MicroPython turns $3 boards into real-time web servers
  • No cloud, no Node.js, no database required
  • Great for hobbyists & pros alike looking to prototype fast

With simple Python scripts and a basic HTML front, you can run your own server at the edge β€” powered by 3 bucks and your love for code.


⚑ Related Tools You Might Love

  • mpfshell: File management on MicroPython devices
  • uasyncio: Async tasks in MicroPython
  • Thonny IDE: Friendly IDE with MicroPython support

πŸ’¬ Let’s Chat!

Have a question or want to share your setup? Drop it in the comments β€” or tweet it with hashtag #MicroPythonDash πŸπŸ“Š


πŸ‘‰ If you need help taking your IoT or hardware idea from prototype to production – we offer research and development services.