This post contains affiliate links.
A stored P0340 code means the engine computer lost a usable signal from the camshaft position sensor, and that single missing signal can turn a healthy engine into one that cranks but won’t start. It is also one of the more approachable codes to diagnose at home: the sensor is usually accessible, the wiring is short, and a multimeter plus a scan tool will get you to the answer in an afternoon. Here is what the P0340 code means, how to test the circuit properly, and how to replace the sensor without creating new problems.
What the P0340 code actually means
P0340 is defined as “Camshaft Position Sensor Circuit Malfunction (Bank 1 or single sensor).” The sensor tells the engine control module (ECM) where the camshaft is in its rotation. The ECM compares that against the crankshaft sensor signal to work out which cylinder is on its compression stroke, so it knows when to fire each injector and coil.
When the ECM sees no signal, an intermittent one, or a signal that doesn’t line up sensibly with the crankshaft sensor, it sets P0340 and turns on the check engine light. Note the wording: circuit malfunction. The code points at the whole circuit — sensor, connector, wiring and ECM input — not just the sensor. That distinction matters, because replacing the sensor on a chafed wire fixes nothing.
Related codes include P0341 (range/performance), P0342 and P0343 (signal low and high), and P0345 for the bank 2 sensor on V-engines. If P0016 or another crank/cam correlation code is stored alongside P0340, treat that as a strong hint that timing components, not just the sensor, need inspection.
Symptoms of a P0340 code
- Long crank or complete no-start. Many engines will still start using the crank sensor alone, but some will not start at all without a cam signal.
- Stalling, especially when hot. A failing sensor often drops out once underhood temperatures rise, then works again after cooling.
- Rough idle, hesitation, or a misfire feel as injector and spark timing fall back to a backup strategy.
- Reduced power under acceleration.
- Check engine light on, sometimes flashing if misfires accompany the fault.
Safety note: a car that can stall without warning is not safe in highway traffic or at busy intersections. Keep trips short and local until the fault is fixed, and pull well off the road if the engine dies.
Common causes of P0340
- A failed camshaft position sensor. These often fail intermittently and heat-related: the sensor works when cold and drops out once the engine is up to temperature.
- Oil contamination. A leaking cam seal or valve cover gasket wicks oil down the sensor and into its connector — very common on high-mileage engines.
- Damaged wiring or a corroded connector. The harness runs close to hot, moving parts, so chafed insulation and green corrosion in the plug are frequent finds.
- A loose or damaged reluctor/trigger wheel on the camshaft, or metal debris stuck to the sensor tip.
- Timing chain or belt wear. A stretched chain changes the cam-to-crank relationship enough to set cam sensor codes.
- Charging or ground faults. Low system voltage and bad engine grounds produce odd, intermittent sensor codes.
- Rarely, a failed ECM. Confirm everything else first.
Tools and materials you’ll need
- OBD2 scanner, ideally one that shows live data and freeze frame
- Digital multimeter (a low-cost automotive meter is fine)
- Back-probe pins or paperclips for testing without piercing wires
- Socket set and ratchet, plus a short extension
- Torque wrench (in-lb range for small sensor bolts)
- Replacement camshaft position sensor, a new O-ring, and clean engine oil to lubricate it
- Electrical contact cleaner and dielectric grease
- Shop towels, gloves, and safety glasses
- Your vehicle’s service manual or a repair database for the exact spec values
How to diagnose a P0340 code step by step
Step 1: Read all codes and capture freeze frame
Record every stored code, not just P0340, and save the freeze frame data. Engine temperature, RPM and load at the moment the code set tell you whether this is a hot-engine fault or a cold-start fault. If you don’t have a scanner yet, our OBD2 scanner comparison covers what to look for in a tool that reads live sensor data.
Step 2: Inspect the sensor and connector
Let the engine cool — the cylinder head and exhaust will burn you otherwise. The sensor typically sits at the end of a cylinder head or on the timing cover. Unclip the connector and look for oil inside it, green or white corrosion on the pins, spread or pushed-back terminals, and melted plastic from exhaust heat. Pull the sensor and check the tip for metal shavings and the body for cracks. Oil in the connector means there is a leak to fix too, or the new sensor will fail the same way.
Step 3: Check the wiring harness
Follow the harness back as far as you can see, flexing it gently to find hard spots, chafe marks where it crosses a bracket, and rodent damage. Wiggle-test the connector with the engine idling (if it runs) and watch for a stumble — but keep hands, sleeves and tools well clear of belts and fans.
Step 4: Test power, ground and signal
Electrical safety: disconnect the negative battery terminal before unplugging sensors or probing pins, and reconnect only when you need the circuit live for a specific test. Back-probe connectors instead of piercing insulation — a pinhole in a wire becomes tomorrow’s corrosion fault.
Most modern three-wire camshaft position sensors use a reference voltage (typically 5 or 12 volts, depending on the design), a ground, and a signal wire. With the key on and engine off, check for reference voltage on the supply pin and near-zero resistance from the ground pin to a known good engine ground. Missing reference voltage means the problem is upstream in the harness or at the ECM, not in the sensor. Two-wire magnetic sensors are tested differently — measure resistance across the pins and compare to the manufacturer’s spec, as acceptable values vary widely between engines.
Step 5: Watch the signal on live data
Reconnect everything, then use live data to watch camshaft sensor RPM or status while cranking. A sensor reading zero while the crankshaft sensor reads normal cranking RPM confirms a dead cam signal; if both read zero, suspect a shared power or ground, or a timing failure. A signal that flickers while you tap the sensor lightly points to an intermittent internal fault.
Step 6: Rule out timing problems before you buy parts
If the engine has high mileage, rattles on cold starts, or has stored a crank/cam correlation code, check timing chain condition before replacing sensors. A new sensor will not correct a chain that has jumped a tooth, and mechanical timing faults get more expensive the longer they run.
Replacing the camshaft position sensor
Step 1: Disconnect the battery
Remove the negative terminal and let it sit a couple of minutes. This clears radio presets and some adaptive settings on many vehicles.
Step 2: Remove the old sensor
Unplug the connector by pressing its lock tab — never yank the wires. Remove the retaining bolt (commonly 8 or 10 mm) and pull the sensor straight out with a gentle twist. Cover the opening with a clean towel so nothing drops into the engine.
Step 3: Fit the new sensor
Compare old and new side by side; connector shape and depth must match exactly. Lubricate the new O-ring with clean engine oil, seat the sensor fully by hand, then torque the bolt to spec — these bolts are small, and overtightening cracks the housing or strips aluminum threads. Clean the connector with contact cleaner, let it dry, add a light film of dielectric grease and click it firmly home.
Step 4: Clear the code and verify
Reconnect the battery, start the engine and let it idle to temperature. Clear the code, drive normally through a mix of speeds, then recheck for stored codes and confirm the cam sensor data reads correctly. Some vehicles need a cam/crank relearn with a capable scan tool before the fix is complete.
Common mistakes to avoid
- Replacing the sensor first and testing later. P0340 is a circuit code, and connectors, oil contamination and damaged wiring set it just as readily as a failed sensor does.
- Ignoring an oil leak. Fit a new sensor into an oil-filled connector and you’ll be doing the job again.
- Piercing wires to test. Back-probe instead.
- Overtightening the retaining bolt. Use a torque wrench in the inch-pound range.
- Reusing the old O-ring, which lets oil weep out of the timing cover.
- Clearing the code before diagnosing. You lose the freeze frame data that tells you when the fault occurs.
- Buying the cheapest sensor available. This is not a part you want to fit twice — an OE or well-regarded aftermarket unit is the safer choice.
Frequently asked questions
Can I drive with a P0340 code?
Short local trips are usually possible if it still runs, but it isn’t advisable: the engine can stall without warning, which is genuinely dangerous in traffic. Diagnose it promptly and don’t plan a long drive on it.
How much does it cost to fix P0340?
Prices vary a great deal by vehicle, region and part brand. The sensor is generally an inexpensive part and the job is often under an hour of labor when it is accessible — but a buried sensor, a damaged harness or a timing chain problem moves the cost into a very different bracket. Get a quote for your specific vehicle.
Will P0340 clear itself after I fix the fault?
The light usually goes out after several consecutive drive cycles with no fault detected, but the code stays in history until cleared or aged out. Confirming the repair with a scan tool is faster and more reliable than waiting.
Can a bad camshaft sensor cause misfires?
Yes. When cam data is missing or erratic, injector and spark timing suffer and the engine can misfire, often setting misfire codes alongside P0340. If those remain after the sensor circuit checks out, work through our guide on diagnosing and fixing an engine misfire.
When to call a professional
Call a shop if the sensor sits behind the timing cover or under an intake manifold, if testing points to a fault inside the main harness or at the ECM, if a correlation code suggests the timing chain has stretched, or if the code returns after a correct sensor replacement. Timing work and ECM diagnosis need specialist tools and manufacturer data, and a mistake there can cause serious internal engine damage.