tableau_bord.py
The duo's best in 25 lines: the MCU pin and the PC counters merge into one auto-refresh HTML page. Any phone on the network becomes the machine's interface.
Hardware required
A LattePanda Alpha (x86 Intel m3-7Y30, Windows 10 or Linux) with its ATmega32U4 co-processor, Arduino Leonardo compatible, on the 50-pin headers. Network access (the board's cable or Wi-Fi).
Wiring
No wiring for the demo; sensor on A0 for the value. Open port 8080 if a firewall is on.
How it works
Each HTTP request re-reads the pin via PinPong and queries psutil; the 2 s refresh keeps the page live without JavaScript. http.server is plenty on a LAN. The ATmega32U4 is a genuine Leonardo: flash it as « Arduino Leonardo » in the IDE through its internal COM port. Host-side, DFRobot's lattepanda Python library talks to it over serial.
Going further
Write control (HTML buttons → POST → servo), or exposure to an MQTT dashboard.
tableau_bord.py
#!/usr/bin/env python3
# Tableau de bord : mesures MCU (PinPong) + etat hote, en HTTP local.
from pinpong.board import Board, Pin
import psutil
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
Board().begin()
capteur = Pin(Pin.A0, Pin.IN)
class Gestionnaire(BaseHTTPRequestHandler):
def do_GET(self):
brut = capteur.read_analog()
html = f"""<meta http-equiv=refresh content=2>
<h1>LattePanda</h1>
<p>A0 : {brut} / 1023 ({brut * 5 / 1023:.2f} V)</p>
<p>CPU : {psutil.cpu_percent():.0f} % — RAM : {psutil.virtual_memory().percent:.0f} %</p>
<p>Uptime : {time.time() - psutil.boot_time():.0f} s</p>"""
self.send_response(200)
self.send_header("Content-Type", "text/html; charset=utf-8")
self.end_headers()
self.wfile.write(html.encode())
print("http://<ip-de-la-panda>:8080")
HTTPServer(("0.0.0.0", 8080), Gestionnaire).serve_forever()