Build Live Car Gauges with OBD2
Build a read-only web dashboard for live OBD2 gauges, codes, and CSV logs.
Introduction
30 Second Summary
A warning light can turn an ordinary drive into a guessing game. The numbers behind that light often stay hidden until you connect a diagnostic tool.
In this project, you will use Claude Code to build a read-only car gauge page that starts with simulated data. You will then connect the page to a Vgate iCar Pro Bluetooth 4.0 (BLE) adapter through Web Bluetooth for live car readings.
What You'll Build
Your finished page turns Google Chrome or Microsoft Edge into a dark seven-gauge dashboard that can run a demo or display read-only data from your parked car.
By the end of this project, you'll have:
- A seven-gauge demo that moves through an idle phase and a gentle drive while DEMO DATA stays visible.
- A read-only live dashboard that turns supported OBD-II readings into seven gauges. Unsupported readings stay visible as NO DATA.
- A read-only evidence workflow that displays stored P-codes and downloads a CSV file named car-log.csv. The final audit shows READ-ONLY: no mode 04 command.
- Secret Mission: Build a passenger-operated virtual dyno that graphs a speed curve and labels peak horsepower as an estimate.
What do I need to start?
Demo mode runs without a car or adapter using Claude Pro or another paid Claude plan, Python 3, and Google Chrome or Microsoft Edge on macOS 13.0+ or Windows 10 1809+.
Steps 3 and 4 also require a compatible petrol car and a Vgate iCar Pro Bluetooth 4.0 (BLE) adapter.
Before We Start
Before any setup, lock in why you want a read-only dashboard for a specific car. Your safety boundary keeps demo mode hardware-free while reserving live features for a compatible petrol car parked outdoors with you operating the laptop from the passenger seat.
Set Up Claude Code and Python
The dashboard needs Claude Code for AI-assisted development plus Python for its local server before it can produce a browser result.
Claude Code handles the project work from your terminal. Python serves the finished page from your computer.
Google Chrome or Microsoft Edge provides the browser features that the live connection needs later.
In this step, get ready to:
- Install Claude Code. Its version check succeeds after you sign in.
- Install Python 3. Confirm Chrome or Edge opens.
- Create the local car-gauges folder. Claude Code reports that folder as its current location.
Install Claude Code
Claude Code runs inside a terminal session. Its installer adds the command that starts this interactive workspace.
- Install Claude Code with the command for your computer:
macOS
- Press Cmd+Space to open the macOS search bar.
- Type Terminal and press Enter.
- Install Claude Code by running:
curl -fsSL https://claude.ai/install.sh | bash
What does this command do?
This command downloads the official Claude Code installer. It passes the installer to your shell so the installation can run.
Windows
- Press the Windows key to open Windows search.
- Type PowerShell and press Enter.
- Install Claude Code by running:
irm https://claude.ai/install.ps1 | iex
What does this command do?
This command downloads the official Claude Code installer script. PowerShell runs that script to complete the installation.
- Close every terminal window after the installer finishes.
- Start a fresh terminal session.
- Press Cmd+Space on macOS or the Windows key on Windows.
- Type Terminal on macOS or PowerShell on Windows.
- Press Enter to start the fresh session.
- Check the Claude Code installation by running:
claude --version
What does this command do?
The version check asks the installed Claude Code command to identify itself. A version response confirms that your fresh terminal can find the installation.
You should see a version number followed by (Claude Code).
✔️ I see a Claude Code version
Good. Claude Code is installed and available from your terminal.
ⓧ The command is not found
- Close every terminal window.
- Start a fresh terminal session using the same method as earlier.
- Repeat the installer command for your operating system if the command is still unavailable.
Still missing the command?
Confirm that you used Terminal on macOS or PowerShell on Windows. A different Windows command-line app may not support the installer command shown above.
Help me diagnose why Claude Code is unavailable after installation.
Install Python and confirm your browser
Python provides the local server that hosts the dashboard. A supported browser can then load that local page before you connect any hardware.
macOS
- Install Python 3 from the official Python downloads page for macOS.
- Download the current macOS installer package.
- Open the downloaded .pkg file.
- Complete the standard installation.
Windows
- Install the Python install manager from python.org or the Microsoft Store.
- Download the Python install manager from your chosen source.
- Open the downloaded installer.
- Complete the standard installation.
- Check the Python installation with the command for your computer:
macOS
python3 --version
What does this command do?
This asks the macOS Python 3 interpreter to print its installed version.
You should see Python 3. followed by a version number.
Windows
py --version
What does this command do?
This asks the Windows Python install manager to print the active Python version.
You should see Python 3. followed by a version number.
✔️ I see a Python 3 version
Python is ready to serve the dashboard from your computer.
ⓧ The command is not found
- Close every terminal window.
- Start a fresh terminal session using the same method as earlier.
- Repeat the Python installation for your operating system if the command remains unavailable.
- Confirm that Google Chrome or Microsoft Edge opens on your computer.
- Press Cmd+Space on macOS or the Windows key on Windows.
- Type Google Chrome or Microsoft Edge.
- Press Enter to open the browser.
You should see a Chrome or Edge browser window. This confirms that a supported browser is available for the dashboard.
✔️ Chrome or Edge opens
Your supported browser is ready for the local dashboard.
ⓧ Neither browser is installed
- Install one supported browser from the official Google Chrome or Microsoft Edge download page.
- Follow the installer instructions for your operating system.
- Open the installed browser using your operating system search.
Create the folder and sign in
Your project needs a fixed home so every generated file lands in the same place. Starting Claude Code from that folder gives it the correct workspace.
Starting Claude Code opens an interactive terminal session. First use asks you to complete authentication in your browser.
- Create the car-gauges folder on your Desktop by running the commands for your computer:
macOS
cd ~/Desktop
mkdir car-gauges
cd car-gauges
claude
What do these commands do?
- The first cd command moves the terminal to your Desktop.
- The mkdir command creates the car-gauges folder.
- The second cd command moves into that folder.
- The final command starts Claude Code inside the folder.
Windows
cd $HOME\Desktop
mkdir car-gauges
cd car-gauges
claude
What do these commands do?
- The first cd command moves PowerShell to your Desktop.
- The mkdir command creates the car-gauges folder.
- The second cd command moves into that folder.
- The final command starts Claude Code inside the folder.
- Complete the browser sign-in when Claude Code asks.
- Return to the terminal after authentication finishes.
You should see an interactive Claude Code session in the terminal.
Before you ask, which folder path do you expect Claude Code to report?
- Ask Claude Code to report its current folder by pasting:
What folder are we in?
What does this prompt do?
This asks Claude Code to inspect the workspace where its interactive session started. The answer confirms that future project files will land in the intended folder.
That is your workspace ready. Claude Code should answer with a path ending in car-gauges.
Claude reports the wrong folder?
- Close that terminal window.
- Start a fresh terminal session using the same method as earlier.
- Repeat the platform command sequence shown above.
Help me start Claude Code inside the correct car-gauges folder.
Your local workspace is ready. Next, Claude Code will turn that empty folder into a seven-gauge dashboard running in demo mode.
Build the Demo Dashboard
Your local tools are ready. Now you can turn the empty car-gauges folder into a working dashboard with Claude Code.
Demo mode exposes design and parsing mistakes with visible made-up data before hardware enters the picture.
In this step, get ready to:
- Create a self-contained index.html dashboard with seven circular gauges.
- Start a local Python server that makes the dashboard available at http://localhost:8000.
- Run Demo mode until the gauges move from idle into a gentle drive with DEMO DATA displayed.
Create the dashboard with Claude Code
A single HTML file keeps the first build focused on visible browser feedback. It also gives Claude Code one clear place to put the layout, styling, and demo logic.
- In the Claude Code session from the previous step, paste this request:
Create one file, `index.html`, with all code inside it and no libraries. Show seven round gauges in a dark dashboard: RPM 0 to 8000, Speed 0 to 240 km/h, Coolant -40 to 130 °C, Throttle 0 to 100 %, Engine load 0 to 100 %, Intake air -40 to 80 °C, Air flow 0 to 250 g/s. Add a Demo mode button that feeds made-up values twice a second: 10 seconds of idle with coolant slowly warming, then a gentle drive. Show a line at the top that says DEMO DATA while demo mode runs.
What does this request do?
- The request keeps the whole dashboard inside index.html, so there are no libraries or extra files to manage.
- The seven ranges give each gauge a fixed scale for displaying its simulated value.
- The demo sequence updates every half-second. It starts with ten seconds of idle before moving into a gentle drive.
You should see Claude Code create index.html and explain its work. That is the first build milestone done: your dashboard now lives in one browser-ready file.
✔️ Awesome, I've got everything!
Your generated index.html is ready for its first browser run.
ⓧ I'd like to double check the full code
Claude Code can organize the surrounding implementation differently. Confirm that the complete file reaches the required checkpoint.
- Confirm index.html contains its HTML, CSS, and JavaScript with no external libraries.
- Confirm the page contains a status display and a Demo mode button.
- Confirm gaugeDefs defines rpm, speed, coolant, throttle, load, intake, and maf.
- Confirm the JavaScript defines values, logs, demoTimer, and demoTick.
- Confirm the JavaScript defines setStatus, setGauge, addLog, stopDemo, and startDemo.
- Confirm Demo mode records timestamped readings twice per second.
- Confirm the simulation moves from ten seconds of idle into a gentle drive.
- Confirm the status changes to DEMO DATA while the simulation runs.
Prepare a browser-safe local address
A local HTTP server gives your page a browser address. This matters because the later Web Bluetooth connection requires a secure context, and browsers treat http://localhost as secure.
macOS
- Press Cmd+Space to open Spotlight.
- Type Terminal and press Enter to open a second terminal window.
- Move the second terminal into car-gauges and serve the dashboard by running these commands:
cd ~/Desktop/car-gauges
python3 -m http.server 8000
What does this command do?
The cd command moves this terminal into your existing project folder. The http.server module serves that folder through port 8000.
You should see a line beginning with Serving HTTP on. Your dashboard now has a local web address, and this terminal stays occupied while the server runs.
Windows
- Press the Windows key to open search.
- Type PowerShell and press Enter to open a second terminal window.
- Move the second terminal into car-gauges and serve the dashboard by running these commands:
cd $HOME\Desktop\car-gauges
py -m http.server 8000
What does this command do?
The cd command moves this terminal into your existing project folder. The http.server module serves that folder through port 8000.
You should see a line beginning with Serving HTTP on. Your dashboard now has a local web address, and this terminal stays occupied while the server runs.
Can't start the local server?
- Confirm the second terminal is inside the car-gauges folder.
- Replace the port number with 8001 if port 8000 is already in use.
- Use the same replacement port in the browser address.
If the server still does not start, ask for help debugging the local server.
Run Demo mode in the browser
The browser must load the page through the running server. Double-clicking index.html skips the local address that the hardware connection needs later.
- Open http://localhost:8000 in Google Chrome or Microsoft Edge.
- Press Cmd+Space on macOS or the Windows key on Windows to open search.
- Type Google Chrome or Microsoft Edge and press Enter.
- Enter http://localhost:8000 in the address bar.
You should see the dark dashboard with seven circular gauges and a Demo mode button.
Before you start Demo mode, do you expect the values to stay at idle or begin driving immediately?
- Click Demo mode.
- Find the Demo mode button in the toolbar below the dashboard status.
- Select the button once to start the simulation.
You should see DEMO DATA at the top while all seven gauges update twice per second. The first ten seconds simulate idle before speed and the other readings shift into a gentle drive.
You have proved the dashboard can render and update live-looking readings without a car or adapter.
Gauges not moving?
- Press Cmd+Option+J on macOS or Ctrl+Shift+J on Windows to open the browser console.
- Copy the first red error from the console.
- Switch back to the Claude Code session from earlier.
- Paste the error into Claude Code and ask it to fix index.html.
If you need more guidance, ask for help debugging the motionless gauges.
Your simulated dashboard is alive. Next up, you will connect its gauges to a read-only BLE data path.
Connect to Your Car
Your demo dashboard already proves that its seven gauges can display changing values. Now Claude Code will connect those gauges to the browser's hardware interface.
Demo data cannot reveal the adapter's service or the car's supported readings. This step adds a read-only Web Bluetooth connection that discovers the BLE adapter and displays every available live value.
In this step, get ready to:
- Extend index.html with a read-only car connection that blocks mode 04 commands.
- Prepare the parked car outdoors with the adapter connected and you in the passenger seat.
- Connect through the browser and display live readings or NO DATA on the seven gauges.
Add the read-only connection path
The browser uses BLE GATT services to find characteristics that accept commands or send notifications. The dashboard waits for the adapter's readiness prompt before it sends the next request.
Why Web Bluetooth for this adapter?
The specified adapter communicates over Bluetooth Low Energy. Web Bluetooth lets the page request the device and work with its GATT characteristics directly.
System pairing and Web Serial use different connection paths. The browser approach matches the Bluetooth 4.0 model used in this project.
Claude Code may ask for permission to edit index.html. Review the requested file before you approve the change.
- Add the read-only connection behavior by pasting this exact request into Claude Code:
Add a Connect to car button that uses Web Bluetooth. Request any device, with optionalServices `0000fff0-0000-1000-8000-00805f9b34fb`, `0000ffe0-0000-1000-8000-00805f9b34fb` and `e7810a71-73ae-499d-8c15-faa9aef0c3f2`, and use whichever the adapter has: write commands to the characteristic you can write to and listen for replies on the one that notifies. Send `ATZ`, `ATE0`, `ATL0`, `ATS0`, `ATH0`, `ATSP0`, each ending in a carriage return, waiting for `>` after each. Then poll `010C`, `010D`, `0105`, `0111`, `010F`, `0110`, `0104` in a loop, one at a time, waiting for `>`, and decode them with the standard formulas into the gauges. Show `NO DATA` on a gauge the car doesn't report. Only send commands from an allowlist of these AT commands and mode 01 and 03 requests. Never send mode 04.
What does this request do?
- The three service IDs give the browser candidate connection paths for the adapter.
- The setup commands configure the ELM327 interface before polling begins.
- The OBD-II PIDs request the seven readings one at a time.
- The allowlist rejects mode 04 before any command reaches the adapter.
- Approve the edit to index.html if Claude Code requests permission.
- Review the file name shown in the terminal before responding to the permission request.
You should see Claude Code update index.html with the Connect to car button and read-only connection logic.
- Refresh http://localhost:8000 in the browser.
- Press Cmd+R on macOS or Ctrl+R on Windows.
You should see a Connect to car button beside Demo mode. The seven existing gauges should remain visible.
✔️ Awesome, I've got everything!
Great. Confirm that index.html is saved before you prepare the car.
ⓧ I'd like to double check the full code
Compare your index.html with this cumulative reference for the demo and live connection features.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Read-Only Car Gauges</title>
<style>
:root{color-scheme:dark;font-family:system-ui,sans-serif;background:#09111d;color:#eef6ff}
body{margin:0;padding:24px;max-width:1100px;margin:auto}h1{margin:.2rem 0}button,input{font:inherit;padding:.7rem 1rem;border-radius:.7rem;border:1px solid #46627e;background:#13263a;color:#fff}button{cursor:pointer}.toolbar{display:flex;gap:.7rem;flex-wrap:wrap;margin:1rem 0}.status{color:#55d6be;min-height:1.5rem}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:16px}.gauge{--p:0;aspect-ratio:1;border-radius:50%;display:grid;place-items:center;background:conic-gradient(#4cc9f0 calc(var(--p)*1%),#17283a 0);position:relative}.gauge:after{content:"";position:absolute;inset:14px;border-radius:50%;background:#0e1a28}.readout{z-index:1;text-align:center}.value{font-size:2rem;font-weight:800}.unit,.label{color:#9fb4c9}
</style>
</head>
<body>
<h1>Read-Only Car Gauges</h1>
<div id="status" class="status">Ready</div>
<div class="toolbar">
<button id="demo">Demo mode</button>
<button id="connect">Connect to car</button>
</div>
<div id="gauges" class="grid"></div>
<script>
const gaugeDefs={rpm:{label:"RPM",min:0,max:8000,unit:"rpm"},speed:{label:"Speed",min:0,max:240,unit:"km/h"},coolant:{label:"Coolant",min:-40,max:130,unit:"°C"},throttle:{label:"Throttle",min:0,max:100,unit:"%"},load:{label:"Engine load",min:0,max:100,unit:"%"},intake:{label:"Intake air",min:-40,max:80,unit:"°C"},maf:{label:"Air flow",min:0,max:250,unit:"g/s"}};
const values={};let logs=[],demoTimer=null,demoTick=0,polling=false,writeChar=null,replyBuffer="",replyWaiter=null;
const statusEl=document.querySelector("#status"),gaugeBox=document.querySelector("#gauges");
for(const [key,d] of Object.entries(gaugeDefs)){gaugeBox.insertAdjacentHTML("beforeend",`<div class="gauge" id="g-${key}"><div class="readout"><div class="value">NO DATA</div><div class="unit">${d.unit}</div><div class="label">${d.label}</div></div></div>`);}
function setStatus(text){statusEl.textContent=text}
function setGauge(key,value){const d=gaugeDefs[key],el=document.querySelector(`#g-${key}`);if(value==null||Number.isNaN(value)){values[key]="NO DATA";el.querySelector(".value").textContent="NO DATA";el.style.setProperty("--p",0);return}values[key]=value;el.querySelector(".value").textContent=Number(value).toFixed(key==="rpm"||key==="speed"?0:1);el.style.setProperty("--p",Math.max(0,Math.min(100,(value-d.min)*100/(d.max-d.min))));}
function addLog(){logs.push({timestamp:new Date().toISOString(),...Object.fromEntries(Object.keys(gaugeDefs).map(k=>[k,values[k]??"NO DATA"]))});}
function stopDemo(){if(demoTimer)clearInterval(demoTimer);demoTimer=null}
function startDemo(){stopDemo();polling=false;demoTick=0;logs=[];setStatus("DEMO DATA");demoTimer=setInterval(()=>{demoTick++;const s=demoTick/2,idle=s<=10;const wave=Math.sin(s*1.4);setGauge("rpm",idle?760+wave*35:1500+Math.max(0,wave)*1800);setGauge("speed",idle?0:Math.min(85,(s-10)*4));setGauge("coolant",Math.min(92,35+s*.7));setGauge("throttle",idle?8:18+Math.max(0,wave)*25);setGauge("load",idle?20:30+Math.max(0,wave)*35);setGauge("intake",24+Math.sin(s/4)*3);setGauge("maf",idle?3.2:8+Math.max(0,wave)*35);addLog()},500)}
const profiles=[
{service:"0000fff0-0000-1000-8000-00805f9b34fb",read:"0000fff1-0000-1000-8000-00805f9b34fb",write:"0000fff2-0000-1000-8000-00805f9b34fb"},
{service:"0000ffe0-0000-1000-8000-00805f9b34fb",read:"0000ffe1-0000-1000-8000-00805f9b34fb",write:"0000ffe2-0000-1000-8000-00805f9b34fb"},
{service:"0000ffe0-0000-1000-8000-00805f9b34fb",read:"0000ffe1-0000-1000-8000-00805f9b34fb",write:"0000ffe1-0000-1000-8000-00805f9b34fb"},
{service:"e7810a71-73ae-499d-8c15-faa9aef0c3f2",read:"bef8d6c9-9c21-4c9e-b632-bd58c1009f9f",write:"bef8d6c9-9c21-4c9e-b632-bd58c1009f9f"}
];
const serviceIds=[...new Set(profiles.map(p=>p.service))];
const allowedAT=new Set(["ATZ","ATE0","ATL0","ATS0","ATH0","ATSP0"]),allowed01=new Set(["010C","010D","0105","0111","010F","0110","0104"]);
function assertReadOnly(command){const c=command.replace(/\s/g,"").toUpperCase();if(/^04/.test(c))throw new Error("Blocked read-only violation");if(!allowedAT.has(c)&&!allowed01.has(c)&&c!=="03")throw new Error(`Blocked command: ${c}`);return c}
function onNotify(event){replyBuffer+=new TextDecoder().decode(event.target.value);if(replyBuffer.includes(">")&&replyWaiter){const done=replyWaiter;replyWaiter=null;done(replyBuffer);}}
async function send(command,timeout=3000){const safe=assertReadOnly(command);replyBuffer="";const reply=new Promise(resolve=>{replyWaiter=resolve;setTimeout(()=>{if(replyWaiter){replyWaiter=null;resolve("NO DATA>")}},timeout)});const bytes=new TextEncoder().encode(safe+"\r");if(writeChar.writeValueWithResponse)await writeChar.writeValueWithResponse(bytes);else await writeChar.writeValue(bytes);return reply}
async function connectCar(){stopDemo();if(!navigator.bluetooth){setStatus("Bluetooth is not supported here");return}setStatus("Choose the BLE adapter");try{const device=await navigator.bluetooth.requestDevice({acceptAllDevices:true,optionalServices:serviceIds});const server=await device.gatt.connect();let found=false;for(const p of profiles){try{const service=await server.getPrimaryService(p.service),read=await service.getCharacteristic(p.read),write=await service.getCharacteristic(p.write);await read.startNotifications();read.addEventListener("characteristicvaluechanged",onNotify);writeChar=write;found=true;break}catch{}}if(!found)throw new Error("No supported BLE service was exposed");for(const c of ["ATZ","ATE0","ATL0","ATS0","ATH0","ATSP0"])await send(c,5000);logs=[];polling=true;setStatus("LIVE DATA, READ-ONLY");pollLoop()}catch(error){setStatus(`Connection failed: ${error.message}`)}}
function hexBytes(reply,pid){const clean=reply.toUpperCase().replace(/[^0-9A-F]/g,"");const mark=`41${pid}`,i=clean.lastIndexOf(mark);if(i<0)return null;return (clean.slice(i+4).match(/../g)||[]).map(x=>parseInt(x,16))}
function decodePid(command,reply){const pid=command.slice(2),b=hexBytes(reply,pid);if(!b)return null;const A=b[0],B=b[1];return {"0C":()=>((A*256+B)/4),"0D":()=>A,"05":()=>A-40,"11":()=>100*A/255,"0F":()=>A-40,"10":()=>((A*256+B)/100),"04":()=>100*A/255}[pid]?.()??null}
const pollMap={"010C":"rpm","010D":"speed","0105":"coolant","0111":"throttle","010F":"intake","0110":"maf","0104":"load"};
async function pollLoop(){while(polling){for(const [command,key] of Object.entries(pollMap)){try{setGauge(key,decodePid(command,await send(command,4000)))}catch{setGauge(key,null)}}addLog()}}
document.querySelector("#demo").onclick=startDemo;document.querySelector("#connect").onclick=connectCar;
</script>
</body>
</html>
Prepare the parked car safely
An idling car produces exhaust that can contain carbon monoxide. This setup happens outdoors with the car stationary throughout the connection test.
This part deserves care. Each action keeps the driver focused on the car while you operate the laptop from the passenger seat.
- Park the car outdoors in open air.
- Keep the car out of every garage.
- Apply the parking brake.
- Set an automatic transmission to park or a manual transmission to neutral.
- Start the engine and leave it idling.
- Plug the Vgate iCar Pro Bluetooth 4.0 (BLE) adapter into the diagnostic port under the driver's side of the dashboard.
- Leave the adapter unpaired in macOS or Windows Bluetooth settings.
- Move to the passenger seat with the laptop.
You should now have the car parked outdoors with the engine idling. The adapter should be connected to the diagnostic port while you remain in the passenger seat.
Connect and verify live data
The device chooser appears only after you press the connection button. The browser then tries each candidate service until it finds characteristics that can write commands and receive replies.
Before you connect, which gauges do you expect your car to support?
- Refresh http://localhost:8000.
- Press Cmd+R on macOS or Ctrl+R on Windows.
- Press Connect to car.
- Find Connect to car in the toolbar above the gauges.
- Approve the browser's Bluetooth permission request if one appears.
- Respond to the operating system permission dialog shown over the browser.
- Select the Vgate adapter in the browser's device chooser.
- Select the row whose device name matches the connected adapter.
The chooser should now show the adapter as the selected device.
- Press Pair.
- Find Pair at the bottom of the browser's device chooser.
You should see DEMO DATA disappear. Supported gauges should change to live values while unavailable readings show NO DATA.
The exact gauge values depend on the car. Connection speed also depends on the adapter and the car's replies.
Connection not settling?
- Confirm that the dashboard is open in Chrome or Edge at http://localhost:8000 if the page reports that Bluetooth is unsupported.
- Confirm that the adapter is the Bluetooth 4.0 model if it is absent from the chooser.
- Confirm that the computer's Bluetooth is enabled.
- Confirm that the car's ignition remains on.
- Ask Claude Code to reduce the number of polled PIDs if every gauge remains on NO DATA.
- Ask Claude Code to increase the wait between requests if replies arrive too slowly.
- Open System Settings on macOS.
- Select Privacy & Security.
- Select Bluetooth.
- Confirm that Chrome or Edge has Bluetooth access.
If the connection still fails, ask for help diagnosing the BLE connection.
That is the hardware bridge working: your dashboard can now replace simulated readings with read-only replies from the car. Next, you will read stored codes and export the gauge history.
Read Codes and Export a Log
Your dashboard already reads live OBD-II values through Web Bluetooth. Now you can preserve those readings and reveal stored faults without changing anything in the car.
Live gauges cannot preserve readings, reveal stored faults, or prove that clearing commands are blocked.
In this step, get ready to:
- Add Read codes and Save log controls that work in demo mode and with live data.
- Read stored P-codes while the car remains parked outdoors.
- Export a non-empty car-log.csv file and pass the no-mode-04 audit.
Add codes and logging
A stored diagnostic trouble code identifies the system where the car detected a fault. The dashboard treats each code as a clue for further investigation.
- Return to Claude Code in the car-gauges folder and paste this request exactly:
Add a Read codes button. Send `0101`, read the number of stored codes and whether the check engine light is on, then send `03` and decode each pair of bytes into a code like P0133 using the standard first-digit table, skipping `0000` padding. Show each code, or `No stored codes`. Add a Save log button that downloads `car-log.csv` with a timestamp and every gauge value for each reading since connecting. Don't add any button that clears codes.
What does this prompt add?
- The 0101 request reads the check-engine-light state and stored-code count.
- The 03 request reads stored codes without clearing them.
- The logging feature stores each gauge reading with a timestamp before exporting car-log.csv.
Claude Code adds Read codes and Save log buttons. It also adds a Stored codes panel to index.html.
- Refresh the dashboard at http://localhost:8000.
- Press Cmd+R on macOS or Ctrl+R on Windows.
You should see Read codes and Save log beside the existing controls. You should also see the Stored codes panel below the gauges.
- Start simulated readings by selecting Demo mode.
- Find Demo mode in the toolbar above the gauges.
You should see DEMO DATA above seven moving gauges.
- Let demo mode collect readings for several seconds.
You should see the gauge values continue to change as timestamped rows accumulate.
- Read the simulated code result by selecting Read codes.
- Find Read codes in the toolbar above the gauges.
You should see DEMO DATA: P0133 (sample only) in the Stored codes panel.
- Download the simulated readings by selecting Save log.
- Find Save log beside Read codes in the toolbar.
You should see car-log.csv download through your browser.
Good progress. Your dashboard now turns simulated readings into a stored-code result and a downloadable log.
The reference implementation below shows the complete file at this checkpoint.
✔️ Awesome, I've got everything!
Your file now contains the read-code and logging features.
ⓧ I'd like to double check the full code
Your completed index.html should contain this reference implementation.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Read-Only Car Gauges</title>
<style>
:root{color-scheme:dark;font-family:system-ui,sans-serif;background:#09111d;color:#eef6ff}
body{margin:0;padding:24px;max-width:1100px;margin:auto}h1{margin:.2rem 0}button,input{font:inherit;padding:.7rem 1rem;border-radius:.7rem;border:1px solid #46627e;background:#13263a;color:#fff}button{cursor:pointer}.toolbar{display:flex;gap:.7rem;flex-wrap:wrap;margin:1rem 0}.status{color:#55d6be;min-height:1.5rem}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:16px}.gauge{--p:0;aspect-ratio:1;border-radius:50%;display:grid;place-items:center;background:conic-gradient(#4cc9f0 calc(var(--p)*1%),#17283a 0);position:relative}.gauge:after{content:"";position:absolute;inset:14px;border-radius:50%;background:#0e1a28}.readout{z-index:1;text-align:center}.value{font-size:2rem;font-weight:800}.unit,.label{color:#9fb4c9}.codes{margin-top:20px;padding:16px;border:1px solid #29445e;border-radius:12px;background:#0e1a28}.warning{color:#ffd166}
</style>
</head>
<body>
<h1>Read-Only Car Gauges</h1>
<div id="status" class="status">Ready</div>
<div class="toolbar">
<button id="demo">Demo mode</button>
<button id="connect">Connect to car</button>
<button id="codes">Read codes</button>
<button id="save">Save log</button>
</div>
<div id="gauges" class="grid"></div>
<section class="codes"><h2>Stored codes</h2><div id="codeOutput">Not read yet</div><p class="warning">Codes are clues, not a diagnosis. This app never clears codes.</p></section>
<script>
const gaugeDefs={rpm:{label:"RPM",min:0,max:8000,unit:"rpm"},speed:{label:"Speed",min:0,max:240,unit:"km/h"},coolant:{label:"Coolant",min:-40,max:130,unit:"°C"},throttle:{label:"Throttle",min:0,max:100,unit:"%"},load:{label:"Engine load",min:0,max:100,unit:"%"},intake:{label:"Intake air",min:-40,max:80,unit:"°C"},maf:{label:"Air flow",min:0,max:250,unit:"g/s"}};
const values={};let logs=[],demoTimer=null,demoTick=0,polling=false,writeChar=null,replyBuffer="",replyWaiter=null;
const statusEl=document.querySelector("#status"),gaugeBox=document.querySelector("#gauges"),codeOutput=document.querySelector("#codeOutput");
for(const [key,d] of Object.entries(gaugeDefs)){gaugeBox.insertAdjacentHTML("beforeend",`<div class="gauge" id="g-${key}"><div class="readout"><div class="value">NO DATA</div><div class="unit">${d.unit}</div><div class="label">${d.label}</div></div></div>`);}
function setStatus(text){statusEl.textContent=text}
function setGauge(key,value){const d=gaugeDefs[key],el=document.querySelector(`#g-${key}`);if(value==null||Number.isNaN(value)){values[key]="NO DATA";el.querySelector(".value").textContent="NO DATA";el.style.setProperty("--p",0);return}values[key]=value;el.querySelector(".value").textContent=Number(value).toFixed(key==="rpm"||key==="speed"?0:1);el.style.setProperty("--p",Math.max(0,Math.min(100,(value-d.min)*100/(d.max-d.min))));}
function addLog(){logs.push({timestamp:new Date().toISOString(),...Object.fromEntries(Object.keys(gaugeDefs).map(k=>[k,values[k]??"NO DATA"]))});}
function stopDemo(){if(demoTimer)clearInterval(demoTimer);demoTimer=null}
function startDemo(){stopDemo();polling=false;demoTick=0;logs=[];setStatus("DEMO DATA");demoTimer=setInterval(()=>{demoTick++;const s=demoTick/2,idle=s<=10;const wave=Math.sin(s*1.4);setGauge("rpm",idle?760+wave*35:1500+Math.max(0,wave)*1800);setGauge("speed",idle?0:Math.min(85,(s-10)*4));setGauge("coolant",Math.min(92,35+s*.7));setGauge("throttle",idle?8:18+Math.max(0,wave)*25);setGauge("load",idle?20:30+Math.max(0,wave)*35);setGauge("intake",24+Math.sin(s/4)*3);setGauge("maf",idle?3.2:8+Math.max(0,wave)*35);addLog()},500)}
const profiles=[
{service:"0000fff0-0000-1000-8000-00805f9b34fb",read:"0000fff1-0000-1000-8000-00805f9b34fb",write:"0000fff2-0000-1000-8000-00805f9b34fb"},
{service:"0000ffe0-0000-1000-8000-00805f9b34fb",read:"0000ffe1-0000-1000-8000-00805f9b34fb",write:"0000ffe2-0000-1000-8000-00805f9b34fb"},
{service:"0000ffe0-0000-1000-8000-00805f9b34fb",read:"0000ffe1-0000-1000-8000-00805f9b34fb",write:"0000ffe1-0000-1000-8000-00805f9b34fb"},
{service:"e7810a71-73ae-499d-8c15-faa9aef0c3f2",read:"bef8d6c9-9c21-4c9e-b632-bd58c1009f9f",write:"bef8d6c9-9c21-4c9e-b632-bd58c1009f9f"}
];
const serviceIds=[...new Set(profiles.map(p=>p.service))];
const allowedAT=new Set(["ATZ","ATE0","ATL0","ATS0","ATH0","ATSP0"]),allowed01=new Set(["010C","010D","0105","0111","010F","0110","0104","0101"]);
function assertReadOnly(command){const c=command.replace(/\s/g,"").toUpperCase();if(/^04/.test(c))throw new Error("Blocked read-only violation");if(!allowedAT.has(c)&&!allowed01.has(c)&&c!=="03")throw new Error(`Blocked command: ${c}`);return c}
function onNotify(event){replyBuffer+=new TextDecoder().decode(event.target.value);if(replyBuffer.includes(">")&&replyWaiter){const done=replyWaiter;replyWaiter=null;done(replyBuffer);}}
async function send(command,timeout=3000){const safe=assertReadOnly(command);replyBuffer="";const reply=new Promise(resolve=>{replyWaiter=resolve;setTimeout(()=>{if(replyWaiter){replyWaiter=null;resolve("NO DATA>")}},timeout)});const bytes=new TextEncoder().encode(safe+"\r");if(writeChar.writeValueWithResponse)await writeChar.writeValueWithResponse(bytes);else await writeChar.writeValue(bytes);return reply}
async function connectCar(){stopDemo();if(!navigator.bluetooth){setStatus("Bluetooth is not supported here");return}setStatus("Choose the BLE adapter");try{const device=await navigator.bluetooth.requestDevice({acceptAllDevices:true,optionalServices:serviceIds});const server=await device.gatt.connect();let found=false;for(const p of profiles){try{const service=await server.getPrimaryService(p.service),read=await service.getCharacteristic(p.read),write=await service.getCharacteristic(p.write);await read.startNotifications();read.addEventListener("characteristicvaluechanged",onNotify);writeChar=write;found=true;break}catch{}}if(!found)throw new Error("No supported BLE service was exposed");for(const c of ["ATZ","ATE0","ATL0","ATS0","ATH0","ATSP0"])await send(c,5000);logs=[];polling=true;setStatus("LIVE DATA, READ-ONLY");pollLoop()}catch(error){setStatus(`Connection failed: ${error.message}`)}}
function hexBytes(reply,pid){const clean=reply.toUpperCase().replace(/[^0-9A-F]/g,"");const mark=`41${pid}`,i=clean.lastIndexOf(mark);if(i<0)return null;return (clean.slice(i+4).match(/../g)||[]).map(x=>parseInt(x,16))}
function decodePid(command,reply){const pid=command.slice(2),b=hexBytes(reply,pid);if(!b)return null;const A=b[0],B=b[1];return {"0C":()=>((A*256+B)/4),"0D":()=>A,"05":()=>A-40,"11":()=>100*A/255,"0F":()=>A-40,"10":()=>((A*256+B)/100),"04":()=>100*A/255}[pid]?.()??null}
const pollMap={"010C":"rpm","010D":"speed","0105":"coolant","0111":"throttle","010F":"intake","0110":"maf","0104":"load"};
async function pollLoop(){while(polling){for(const [command,key] of Object.entries(pollMap)){try{setGauge(key,decodePid(command,await send(command,4000)))}catch{setGauge(key,null)}}addLog()}}
function parseCodes(reply){const clean=reply.toUpperCase().replace(/[^0-9A-F]/g,"");const i=clean.lastIndexOf("43");if(i<0)return[];const data=clean.slice(i+2),out=[];for(let n=0;n+3<data.length;n+=4){const pair=data.slice(n,n+4);if(pair==="0000")continue;const a=parseInt(pair.slice(0,2),16),prefix=["P","C","B","U"][a>>6],digit=(a>>4)&3;out.push(prefix+digit+pair.slice(1))}return out}
async function readCodes(){if(demoTimer){codeOutput.textContent="DEMO DATA: P0133 (sample only)";return}if(!writeChar){codeOutput.textContent="Connect to the car first";return}try{const statusReply=await send("0101",4000),bytes=hexBytes(statusReply,"01"),count=bytes?bytes[0]&127:null,mil=bytes?Boolean(bytes[0]&128):null;const codes=parseCodes(await send("03",5000));codeOutput.textContent=`Check engine light: ${mil==null?"NO DATA":mil?"on":"off"}. Stored count: ${count??"NO DATA"}. ${codes.length?codes.join(", "):"No stored codes"}`}catch(error){codeOutput.textContent=`Read failed: ${error.message}`}}
function saveLog(){if(!logs.length){setStatus("No readings to save yet");return}const keys=["timestamp",...Object.keys(gaugeDefs)],csv=[keys.join(","),...logs.map(r=>keys.map(k=>r[k]).join(","))].join("\n"),a=document.createElement("a");a.href=URL.createObjectURL(new Blob([csv],{type:"text/csv"}));a.download="car-log.csv";a.click();URL.revokeObjectURL(a.href)}
document.querySelector("#demo").onclick=startDemo;document.querySelector("#connect").onclick=connectCar;document.querySelector("#codes").onclick=readCodes;document.querySelector("#save").onclick=saveLog;
</script>
</body>
</html>
Read stored codes safely
Reading a live car can feel higher stakes. The dashboard stays within its read-only boundary because it sends permitted requests without exposing a clear-codes control.
The car remains parked outdoors with the engine idling. You remain in the passenger seat while the existing connection supplies live readings.
- Switch back to the dashboard in your browser.
- Request the live stored-code result by selecting Read codes.
- Find Read codes in the toolbar above the live gauges.
You should see one or more P-codes or No stored codes. You should also see the check-engine-light state and stored-code count when the car reports them.
- Consult the car's manual or a qualified mechanic for any displayed P-code.
An error code points toward a system that needs investigation. A proper diagnosis still depends on the car's symptoms and further testing.
Export the log and audit read-only commands
A CSV file stores each reading as a row. This creates a portable record that you can inspect after the live session ends.
- Let the live gauges collect several readings.
You should see supported gauge values continue to update while timestamped rows accumulate.
- Export the collected readings by selecting Save log.
- Find Save log in the dashboard toolbar.
You should see a new car-log.csv download.
- Open the downloaded car-log.csv file.
- Select the recent car-log.csv download in your browser.
You should see a header row followed by timestamped gauge readings. The file should contain more than one line.
- Switch back to Claude Code in the car-gauges folder.
- Pause to predict whether the audit will find any command that starts with 04.
- Audit every adapter command by pasting this request exactly:
Search `index.html` and tell me every command the app can send to the adapter. Print `READ-ONLY: no mode 04 command` only if none of them starts with 04.
What does this audit prove?
The audit searches the complete file instead of checking only the visible buttons. It confirms that the send path contains no mode 04 command.
Mode 03 reads stored codes. Mode 04 clears them, so the second command must remain blocked.
Claude Code should list the allowed AT requests, mode 01 requests, and mode 03. The final line should be exactly READ-ONLY: no mode 04 command.
Audit or export not right?
- Ask Claude Code to delete any reported mode 04 code.
- Repeat the exact audit after Claude Code removes the command.
- Ask Claude Code to skip 0000 padding if P0000 appears.
- Collect several demo or live readings before selecting Save log if the file is empty.
Ask for help with an unexpected result by selecting help me inspect my read-only audit or empty gauge log.
Secret mission
Build Rob's Virtual Dyno
Turn the dashboard's speed readings into a passenger-operated virtual dyno. You will graph a run and calculate a smoothed peak horsepower estimate while keeping the driver's attention on the road.
Clean Up Your Resources
Clean Up Your Resources
Your local folder and Python server have no ongoing cloud cost. Your Claude Pro subscription can keep renewing until you cancel it.
Choose whether to keep the dashboard available, pause the local server, or remove the project files entirely.
Cost warning
Claude Pro costs $20 if billed monthly before applicable tax. It can continue renewing until you cancel it.
Your local project files and Python server do not add a cloud charge.
Resources you used:
- The ~/Desktop/car-gauges folder on macOS or $HOME\Desktop\car-gauges folder on Windows. It contains index.html and your completed dashboard.
- The local Python HTTP server available at http://localhost:8000.
- Your downloaded car-log.csv files.
- The Vgate iCar Pro Bluetooth 4.0 (BLE) adapter connection if you completed a live test.
- Your Claude Pro subscription if you purchased it for this project.
Keep everything running
No project cleanup is needed. Choose this option while you are still testing the dashboard or improving its gauges.
- Keep the car-gauges folder on your Desktop.
- Keep your downloaded car-log.csv files for later analysis.
- Leave the Python server running while you are actively using the dashboard.
- Unplug the Vgate adapter when your parked live-testing session is finished.
- Keep your Claude Pro subscription only if you plan to continue using Claude Code.
Your dashboard remains available at http://localhost:8000 while the server is running.
Pause - I'll come back to this later
Pause the running processes while preserving your dashboard and logs. You can restart the same local server when you return.
- Press Ctrl+C in the server terminal to stop the Python HTTP server.
- Unplug the Vgate adapter from the car.
- Leave the car-gauges folder on your Desktop.
- Keep any downloaded car-log.csv files you want to review.
You should see the command prompt return in the server terminal.
macOS
- Restart the dashboard later by running these commands:
cd ~/Desktop/car-gauges
python3 -m http.server 8000
What does this command do?
The first line returns to your project folder. The second line serves index.html on port 8000.
Windows
- Restart the dashboard later by running these commands in PowerShell:
cd $HOME\Desktop\car-gauges
py -m http.server 8000
What does this command do?
The first line returns to your project folder. The second line serves index.html on port 8000.
- Return to Chrome or Edge at http://localhost:8000 after restarting the server.
You should see the completed dashboard with its seven gauges and Virtual dyno estimate panel.
Delete - I don't want to use this again
Deleting the project folder is permanent. Copy any logs you want to keep before continuing.
- Press Ctrl+C in the server terminal to stop the Python HTTP server.
- Unplug the Vgate adapter from the car.
- Close the terminal window that contains Claude Code.
macOS
- Press Cmd+Space to open macOS search.
- Type Terminal into the search field.
- Press Enter to open Terminal.
- Delete the car-gauges folder by running this command:
rm -rf ~/Desktop/car-gauges
What does this command do?
This permanently removes the car-gauges folder and everything stored inside it.
Windows
- Press the Windows key to open Windows search.
- Type Command Prompt into the search field.
- Press Enter to open Command Prompt.
- Delete the car-gauges folder by running this command:
rmdir /s /q %USERPROFILE%\Desktop\car-gauges
What does this command do?
This permanently removes the car-gauges folder and everything stored inside it.
- Use your browser's downloads list to locate every downloaded car-log.csv file.
- Delete each downloaded car-log.csv file you no longer want.
- Check your Desktop for the car-gauges folder.
- Search your computer for any retained car-log.csv copies.
- Cancel Claude Pro through Claude's billing settings if you subscribed only for this project.
- Confirm the billing settings no longer show an upcoming Claude Pro renewal.
You should no longer see the car-gauges folder on your Desktop. Your local server should also be stopped.
Nice Work!
Nice Work!
You did it! Your Claude Code project is now a read-only car diagnostics dashboard.
You've learned how to:
- Built a seven-gauge demo dashboard that runs without a car. Served it at http://localhost:8000 so the gauges update in the browser.
- Added a Web Bluetooth connection for the Vgate iCar Pro Bluetooth 4.0 (BLE) adapter. Kept every adapter request behind a read-only allowlist with no mode 04 command.
- Treated stored P-codes as diagnostic clues. Exported timestamped gauge readings to car-log.csv for review.
- Completed the Secret Mission by building a passenger-operated virtual dyno. It plots a speed curve and reports a labeled peak horsepower estimate.
Ready to quiz yourself?