A full-stack project to visualize real-time magnetic field changes captured by the MLX90393 3-axis magnetometer on an ESP32. Data is streamed via serial port to a Node.js backend, and displayed in a browser using Vue.js and D3.js.
- Real-time visualization of X, Y, Z magnetic field components.
- Interactive dot position and rotation line representing sensor orientation.
- Time-series graph for continuous monitoring.
- Lightweight Node.js + Socket.IO backend.
- Works cross-platform (Windows, macOS, Linux).
- MLX90393 3D Magnetometer
- ESP32 development board
- USB cable for serial communication
- ESP32 firmware: Arduino sketch using Adafruit MLX90393 library
- Backend: Node.js + Express + Socket.IO + SerialPort
- Frontend: Vue.js + D3.js
- Styling: CSS for graph visualization
-
Download and install the Arduino IDE.
-
Install ESP32 board support:
- File → Preferences → Additional Boards Manager URLs:
https://dl.espressif.com/dl/package_esp32_index.json - Tools → Board → Boards Manager → Search “ESP32” → Install
- File → Preferences → Additional Boards Manager URLs:
-
Install Adafruit MLX90393 library:
- Tools → Manage Libraries → Search
Adafruit MLX90393→ Install
- Tools → Manage Libraries → Search
- Open
mlx90393-esp32/mlx90393-esp32.inoin Arduino IDE. - Select your ESP32 board and correct COM port.
- Upload the sketch.
-
Install Node.js (v14+ recommended).
-
Clone this repository:
git clone <your-repo-url>
cd <repo-directory>- Install dependencies:
npm install- Update the serial port path in
index.jsif necessary:
const port = new SerialPort('/dev/ttyUSB0', { baudRate: 9600 }) // Linux example- On Linux/macOS:
/dev/ttyUSB0or/dev/ttyACM0 - On Windows:
COM3,COM4, etc. (check Device Manager → Ports)
node index.js- Server runs on http://localhost:3000
- The server reads serial data from ESP32 and emits it via Socket.IO to the frontend.
-
Open a browser and navigate to http://localhost:3000
-
You should see:
- Table of X/Y/Z values
- Rotating line representing sensor orientation
- Movable dot and live graph
- The graph.js currently uses placeholder data; you can connect it to real sensor data by modifying the tick/update functions to consume
x, y, zfrom Vue. - Ensure your ESP32 is powered and connected before starting the Node.js server.
- On Windows, install serial drivers if the ESP32 is not recognized.
- express
- socket.io
- serialport
- @serialport/parser-readline
- Vue.js (CDN)
- D3.js (CDN)
MIT License
Christos Kalaitzis