Go-Parts
Cart 0
Your cart is empty
Add an item to see it appear here.
Wrenchy
Go-Parts Garage
Expert guides for diagnosing, troubleshooting, and replacing auto parts Expert guides for diagnosing and replacing auto parts
Browse All Articles →
🧭 Diagnostic Flowchart 🎬 Helpful Videos 🛍️ Shop This Part

P0340 on 2005-2015 Nissan Xterra 4.0L V6: Camshaft Sensor Causes and Fixes

On a 2005-2015 Xterra with the 4.0L V6, code P0340 almost always points to a failing passenger-side (Bank 1) camshaft position sensor. The part is relatively inexpensive, but access is notoriously difficult against the firewall. Using an OEM (Nissan) or the original manufacturer, Hitachi, brand sensor is critical for a lasting repair, as cheaper aftermarket parts are known to fail quickly.

19 minutes to read 2005-2015 Nissan Xterra
Most Likely Cause
Failing Bank 1 (Passenger Side) Camshaft Position Sensor
Difficulty
3/5
Est. Time
1.8 hrs
DIY Doable?
✅ Yes
Shop Labor
$150 – $450
Parts Price
$40 – $125
⚠️ Drivable, but... — You can drive, but there is a high risk of the engine stalling at any time, including in traffic, which is unsafe. The engine may also be difficult or impossible to restart, especially when warm, potentially leaving you stranded. It's best to get it fixed promptly.
Key Takeaways
  • P0340 on a 2005-2015 Xterra specifically means the passenger-side camshaft position sensor circuit is faulty.
  • The most common fix is to replace the sensor itself. This is a known weak point on the 4.0L V6 engine.
  • ALWAYS use a genuine Nissan or Hitachi brand sensor. Cheaper aftermarket parts are known to fail quickly.
  • The repair is mechanically simple (one 10mm bolt) but physically difficult due to the sensor's location against the firewall.
  • Consider replacing the driver-side sensor (for code P0345) and the crankshaft sensor (for code P0335) at the same time to prevent future breakdowns.
The trouble code P0340 stands for "Camshaft Position Sensor 'A' Circuit Malfunction". This means the engine control module (ECM) has detected an incorrect, intermittent, or missing signal from the camshaft position sensor for Bank 1. On the VQ40DE engine, Bank 1 is the cylinder bank on the passenger side of the vehicle. This sensor is critical for the ECM to control ignition timing and fuel injection synchronization. A bad signal can cause significant drivability problems, including stalling and hard starts.

What's Unique About the 2005-2015 Nissan Xterra

Failure of the camshaft position sensors is a well-documented, extremely common issue for the second-generation Nissan Xterra and other Nissan models using the VQ40DE engine, often occurring between 100,000 and 170,000 miles. The sensors are located at the back of the engine against the firewall, where high heat contributes to their premature failure. Due to the high failure rate, many owners consider these sensors a routine maintenance item and often replace both camshaft sensors (and sometimes the crankshaft sensor) at the same time as a preventative measure.

Symptoms You May Notice

  • Engine is hard to start or cranks for a long time before turning over.
  • Engine stalls unexpectedly while driving or at idle, sometimes with a complete loss of electrical power until restarted.
  • Check Engine Light (Service Engine Soon) is on.
  • VDC OFF and SLIP warning lights are illuminated on the dashboard simultaneously with the Check Engine Light.
  • Noticeable loss of engine power and poor acceleration.
  • Rough or unstable idle.
  • Transmission may seem locked in a gear, but the issue resolves after restarting the engine.
⚠️ Don't Waste Money on the Wrong Fix
  • Replacing the sensor with a cheap, non-OEM/Hitachi part. Many owners report that low-quality aftermarket sensors fail within a short period, causing the code to return.
  • Replacing the wrong sensor. P0340 specifically refers to Bank 1, which is the passenger side. The driver's side sensor is Bank 2 (P0345).
  • Assuming the sensor is the only possible cause. A bad connection at the wiring harness clip is also a frequent culprit, especially if the green locking tab is broken.

Most Likely Causes

  1. Failing Bank 1 (Passenger Side) Camshaft Position Sensor 🔴 High Probability → Shop Engine Camshaft Position Sensor The sensor is located in a high-heat area at the rear of the engine against the firewall, which causes the internal electronics to fail over time. This is a very common failure point on the VQ40DE engine, often considered a 'rite of passage' by owners.
    How to confirm: Scan the vehicle for codes; P0340 specifically points to the Bank 1 sensor. An oscilloscope provides a definitive test of the sensor's signal, but given the extremely high failure rate and low part cost, direct replacement is the most common 🎬 Watch this step-by-step P0340 sensor replacement guide. and practical diagnostic step. Oil found inside the electrical connector is a strong sign of internal sensor failure.
    Typical fix: Replace the Bank 1 camshaft position sensor. It is highly recommended to use an OEM (Nissan) or Hitachi brand sensor, as aftermarket sensors are known to fail quickly, causing the code to return. Many owners also replace the Bank 2 (driver's side) sensor (P0345) and the crankshaft sensor (P0335) at the same time as preventative maintenance.
    Est. part cost: $40-$100
  2. Wiring Harness or Connector Issue 🟡 Medium Probability The connector and wiring are also exposed to high heat, which can make them brittle. The green locking tab on the connector frequently breaks, leading to a poor connection. Oil from a leaking valve cover gasket or a failed o-ring on the sensor itself can contaminate the connector, causing a poor signal.
    How to confirm: Visually inspect the sensor's electrical connector and nearby wiring for signs of damage, brittleness, corrosion, or oil contamination. Wiggle the connector while the engine is running to see if it causes stalling or stumbling. Ensure the connector is securely clipped in place.
    Typical fix: Clean the connector with electrical contact cleaner if it is oily or corroded. If the connector or wiring is damaged, it will need to be repaired or replaced with a new pigtail. If the locking tab is broken, a zip tie can be used to hold the connector securely as a temporary or permanent fix.
    Est. part cost: $5-$30 for a new pigtail connector.

Rare But Worth Checking

  • Failing Crankshaft Position Sensor: → Shop Engine Crankshaft Position Sensor While P0340 points to the camshaft sensor, a failing crankshaft position sensor can sometimes cause related timing codes and symptoms. It's common practice for owners to replace all three sensors (two cam, one crank) at once due to similar failure patterns and age.
  • Timing Chain Issues: → Shop Engine Timing Chain On high-mileage vehicles (especially 2005-2010 models), a stretched timing chain or worn plastic tensioner guides can affect camshaft timing and trigger this code, often accompanied by a whining noise. This is a much more complex and expensive repair and should be considered only after the sensors and wiring have been ruled out.
  • Failing IPDM (Intelligent Power Distribution Module): On earlier models (2005-2007), a faulty ECM relay inside the IPDM can cause stalling and no-start conditions that mimic a bad cam sensor. If new sensors don't fix the issue, investigating the IPDM is a valid next step.
  • Failing Powertrain Control Module (PCM): → Shop Engine Control Module (ECM) A faulty PCM is very rare but can be the cause if all other possibilities have been exhausted. This would require advanced diagnostics by a professional technician.

Diagnosis Steps

  1. Confirm the presence of code P0340 using an OBD-II scanner.
  2. Locate the Bank 1 (passenger side) camshaft position sensor at the rear of the engine, against the firewall. It has a straight connector, unlike the angled Bank 2 sensor.
  3. Inspect the electrical connector for a secure fit, corrosion, or oil contamination. The green locking tab is often brittle and breaks.
  4. Inspect the wiring leading to the sensor for any signs of damage, fraying, or melting.
  5. If the wiring and connector are okay, the most likely cause is the sensor itself. The job is often done by feel, sometimes by laying across the top of the engine. A 10mm socket or ratcheting wrench is required.
  6. 🎬 Watch a mechanic demonstrate the best way to reach the sensor.
  7. It is often easier to unbolt the 10mm bolt and pull the sensor out first, then wrestle with the difficult electrical connector once you have more room to move it.
  8. A useful trick for visibility is to use a smartphone camera with the light on to see the sensor and bolt location while working.
  9. When installing the new sensor, lubricate the new O-ring with a small amount of fresh engine oil to ensure it seats properly without damage.
  10. After installing the new sensor and ensuring the connector clicks securely, clear the trouble code with the scanner and start the engine to confirm the fix.
  11. For potentially easier access, some owners have had success by removing the front passenger wheel and inner fender liner, though access is still tight.

Parts You'll Likely Need

  • Camshaft Position Sensor (Bank 1, Passenger Side) (OEM #23731-EA20C (supersedes 23731-EA20A, 23731-EA20B)) — This is the direct cause of code P0340 in the vast majority of cases on this vehicle due to heat-related failure. This sensor has a straight connector.
    Trusted brands: Nissan (OEM), Hitachi (OEM Supplier)
    OEM price range: $80-$125
    Aftermarket price range: $40-$70
  • Camshaft Position Sensor (Bank 2, Driver Side) (OEM #23731-AL61D (supersedes 23731-AL61A)) — It is highly recommended to replace both camshaft sensors at the same time as a preventative measure, since they fail under the same conditions. This sensor has an angled connector.
    Trusted brands: Nissan (OEM), Hitachi (OEM Supplier)
    OEM price range: $80-$125
    Aftermarket price range: $40-$70

Related Codes That Often Appear With This One

  • P0345 — This code is for the Bank 2 (driver's side) camshaft position sensor. Since both sensors are exposed to the same conditions and have a similar lifespan, it's common for them to fail around the same time. Many owners replace both as a pair.
  • 🎬 See how to replace both cam sensors in one job.
  • P0335 — This code indicates a fault with the crankshaft position sensor. The cam and crank sensors work together for engine timing, and it's a common preventative maintenance practice to replace all three sensors at once.

Technical Service Bulletins (TSBs) & Recalls

  • NTB07-069c: While not directly for P0340, this TSB addresses stalling and no-start issues related to a faulty ECM relay in the IPDM on 2005-2006 models, which can present with similar symptoms.

Platform-Specific Known Issues

  • The location of the sensors at the rear of the engine against the firewall makes replacement notoriously difficult due to tight access. Most of the work must be done by feel.
  • The electrical connectors can become brittle and the green locking tab is very easy to break, making it difficult to release. Some owners find it easier to unbolt the sensor first before attempting to unplug the connector.
  • The new replacement sensors from Nissan/Hitachi often feature an O-ring that was not present on the original part, likely to provide a better seal against oil.

Mechanic-Grade Diagnostic Values

  • Sensor Connector Voltage (Key On, Engine Off) — expected: Pin 3 (Power): Battery Voltage (approx. 12V). Pin 1 (Ground): <1.0 Ohm continuity to ground.. Failure: Missing voltage on the power pin or high resistance on the ground pin indicates a wiring or ECM issue, not a sensor failure.
  • Sensor Resistance (Sensor Unplugged) — expected: The VQ40DE uses a Hall-effect sensor, which cannot be accurately tested with a resistance check. A YouTuber measured a bad sensor at 5.91 Mega-ohms and a good one at 63.4 Kilo-ohms, but these values are not from a service manual and should be used with caution.. Failure: Extremely high or infinite resistance might indicate a failed sensor, but voltage/signal testing is the correct method.
  • Signal Wire Voltage (While Cranking) — expected: Using an oscilloscope, a clean square wave should be visible, alternating between low (near 0V) and high (5V or 12V) voltage.. Failure: A missing signal, a noisy or erratic signal, or a flat-line voltage indicates a failed sensor or a wiring problem.

Scan Tool Commands That Help

  • Nissan CONSULT: Data Monitor for CMP SENSOR (PHASE) — This function allows a technician to view the live signal from the camshaft position sensor as the ECM sees it. It's used to confirm if the signal is present, consistent, or dropping out while the engine is running, which helps differentiate between a hard failure and an intermittent one.

Wiring & Ground Locations

  • Bank 1 Camshaft Sensor Connector (F26) — Rear of the passenger side cylinder head, against the firewall.. This is the direct connector for the sensor triggering code P0340. The pins are typically: Pin 1 (Ground), Pin 2 (Signal), Pin 3 (12V Power). Testing at these pins is the primary electrical diagnostic step.
  • Engine Ground (F117 / F121) — Primary engine-to-chassis ground points, typically found on the front timing cover or the side of the engine block.. A corroded or loose main engine ground can create an unstable voltage reference for all engine sensors, including the camshaft sensor. This can cause erratic signals and trigger fault codes even if the sensor and its dedicated wiring are good.
  • ECM Harness Connector (F22) — At the Engine Control Module (ECM), typically located in the engine bay or behind the glove box.. Technicians test for continuity between the sensor connector (Pin 2) and the corresponding pin at the ECM connector (e.g., terminal 63 in some diagrams) to rule out an open or short in the signal wire.

Real Owner Repair Stories

  • Reddit user in r/XTerra (Nissan Xterra (year not specified, but within 2005-2015 range)) — Car started and immediately shut off. Second attempt resulted in a long 2-3 second crank before starting. SES, VDC OFF, and SLIP lights came on.
    ❌ Tried (didn't work) A commenter in the thread mentioned they still had the error after replacing only the one failed sensor (Bank 2 in their case).
    ✅ What actually fixed it The owner replaced both the Bank 1 (P0340) and Bank 2 camshaft sensors at the same time, following the recommendation that the computer is sensitive to differences between old and new sensors. This resolved the codes and symptoms.
  • Ford Boss Me - Auto / Politics / Family on YouTube (2005 Nissan Xterra 4.0L) — Intermittent stalling, P0340 code stored.
    ❌ Tried (didn't work) The previous person working on the vehicle had left the sensor connector's locking tab disengaged, leading to a poor connection.
    ✅ What actually fixed it The original sensor was found to be leaking oil through its pins into the electrical connector. Replacing the sensor with a new Hitachi unit (OEM supplier) and ensuring the connector was securely clipped in place fixed the stalling issue and cleared the code.
  • NHTSA ODI #11575665 — An owner reported that their vehicle was running well, but after five minutes it started rough idling and cutting off, throwing a check engine light for P0340.
  • NHTSA ODI #11331458 — A driver experienced the check engine light coming on for P0340 and noted this was the second time the camshaft position sensor required replacement.

OEM Part Supersession History

  • 23731-EA20A23731-EA20C, then 23731-EA20D — Standard part revision and improvement by the manufacturer.
    Heads up: The latest part number, 23731-EA20D, is the correct service replacement for all previous versions (A and C).

Model Year Variations Within This Range

  • 2005-2006: These early models may have a white-colored IPDM which was subject to a specific service bulletin (NTB07-069c) for a failing ECM relay that causes stalling. This can mimic the symptoms of a bad camshaft sensor. Later models have a black IPDM where this specific issue is less common.

Diagnostic Flowchart

Other Known Issues on This Vehicle

Issues unrelated to this code that are worth knowing about as an owner of this generation:

  • Timing Chain Tensioner/Guide Wear 🔴 High → Shop Engine Timing Chain — Common on 2005-2010 models. The plastic timing chain guides and tensioner shoes wear prematurely, causing a distinct engine whine that follows RPMs. If ignored, it can lead to chain slack, rattling, and eventual engine damage. (Ref: NTB09-128 / EM09-007)
  • SMOD (Strawberry Milkshake of Death) 🔴 High — Affects 2005 to early 2010 models with automatic transmissions. The internal transmission cooler within the radiator fails, allowing coolant and transmission fluid to mix. This destroys the transmission. (Ref: Nissan offered an extended warranty (up to 10 years/100,000 miles with a co-pay) but it was not a formal recall.)
  • IPDM-ER (Intelligent Power Distribution Module) Failure 🟠 Medium — Common on 2005-2007 models with the original white-colored IPDM. The internal ECM relay can fail, causing intermittent no-start or stalling conditions that can mimic cam/crank sensor failure. (Ref: NTB07-069c addressed a specific ECM relay issue within the IPDM for 2005-2006 models.)
  • Faulty Fuel Level Sending Unit 🟡 Low — Common across many model years, leading to inaccurate fuel gauge readings. The gauge may show fuel is present when the tank is empty, causing unexpected stalling. (Ref: Nissan issued a recall for some 2006-2008 models to address this.)
  • Valve Cover and Spark Plug Tube Seal Leaks 🟠 Medium — Becomes common on higher mileage (100,000+ miles) engines. The valve cover gaskets and integrated spark plug tube seals become brittle and leak oil, which can fill the spark plug wells, causing misfires.

Used vs. New Parts: Buying Guide for This Vehicle

When a used part is the smart pick: For this specific repair, using a used camshaft position sensor is strongly discouraged. The part has a high failure rate due to heat and age, and a used part from a junkyard is likely to have a very short remaining lifespan, if it works at all.

What to inspect on the donor part:

  • Not applicable, as used sensors are not recommended.

OEM-only on this vehicle (don't cheap out):

  • Camshaft Position Sensor

Aftermarket brands forum-validated for this vehicle:

  • Hitachi (This is the Original Equipment Manufacturer for Nissan)

Brands owners have reported issues with on this vehicle:

  • Generic, unbranded, or 'white-box' sensors from online marketplaces. Forum and owner consensus is overwhelming that these parts fail very quickly, sometimes within days or weeks, causing the P0340 code to return.

Documented NHTSA Reports

NHTSA ODI #10381768

Symptoms: An owner reported that the vehicle was able to restart with some difficulty. A dealer service department found code P0340 indicating "B1 CAM SENSOR FAILURE."

What fixed it: The sensor assembly (FP-NUMBER: 23731-69J0B) was replaced.

NHTSA ODI #10731804

Symptoms: A service invoice noted P0340 and C1130 stored, indicating a loss of engine signal.

What fixed it: The technician replaced both the camshaft and crankshaft sensors at a cost of $618.61.

NHTSA ODI #11561517

Symptoms: The car will either not start or hesitates to start, accompanied by a check engine light for P0340.

What fixed it: The owner noted that the camshaft position sensor had already been replaced once before two years prior, highlighting recurring failure patterns.

Real Owner Stories

Aggregated from forums and TSBs cited above. Mileages and costs reflect what owners reported in those sources.

2005-2015 Nissan Xterra VQ40DE 4.0L V6

Symptoms: The car started up and then immediately shut off. On the second attempt, it required a 2-3 second crank to stay on. After stopping for gas, it had a sluggish start and the 'service engine soon', VDC OFF, and SLIP lights all illuminated.

What fixed it: Replacement of the Bank 1 (passenger side) camshaft position sensor.

Source hint: Reddit r/XTerra

Frequently Asked Questions

Why are my VDC OFF and SLIP lights on along with the Check Engine Light?
On the VQ40DE engine, it is common for the VDC OFF and SLIP warning lights to illuminate simultaneously with the Check Engine Light when a camshaft position sensor fails. This is a known symptom of code P0340.
Should I use an aftermarket sensor to fix P0340 on my Xterra?
It is highly recommended to use only OEM (Nissan) or Hitachi brand sensors. Aftermarket sensors are known to fail quickly on this vehicle, often causing the P0340 code to return shortly after replacement.
Does TSB NTB07-069c apply to my stalling issue?
NTB07-069c applies to 2005-2006 models and addresses a faulty ECM relay in the IPDM. While P0340 specifically points to the cam sensor, a failing IPDM relay can cause similar stalling and no-start symptoms.
Is it true I have to remove the wheel to reach the Bank 1 sensor?
While most owners replace the sensor from the top by feel (reaching against the firewall), some have found easier access by removing the front passenger wheel and inner fender liner.
Why did my transmission feel like it was locked in gear when the light came on?
A failing camshaft sensor can cause the transmission to seem locked in a gear. This is a documented symptom that typically resolves after the engine is restarted.
Should I replace both camshaft sensors at the same time?
While P0340 only indicates the Bank 1 (passenger side) sensor, many owners choose to replace the Bank 2 sensor (P0345) and the crankshaft sensor (P0335) simultaneously as preventative maintenance due to the high failure rate of all three.
How to replace CamShaft Position Sensor on Nissan Xterra 4.0 P0340 FIX
How to replace CamShaft Position Sensor on Nissan Xterra 4.0 P0340 FIX
2005–2015 Nissan Xterra Camshaft Position Sensor Replacement P0340 Fix
2005–2015 Nissan Xterra Camshaft Position Sensor Replacement P0340 Fix
P0345 & P0340 Errors: 2010 Nissan Xterra Cam Sensor Replacement | Easy DIY
P0345 & P0340 Errors: 2010 Nissan Xterra Cam Sensor Replacement | Easy DIY
Cam Sensor Replacement on a Nissan Xterra with the 4.0L V6 engine for code P0340 or P0345.
Cam Sensor Replacement on a Nissan Xterra with the 4.0L V6 engine for code P0340 or P0345.
Wrenchy
Article researched & written by
Go-Parts' AI research assistant. Every article is backed by live web research, verified OEM data, and real technician knowledge — so you get accurate, up-to-date information you can trust.
Meet Wrenchy → Updated May 30, 2026

The information in this article is provided for general reference and educational purposes only. Vehicle specifications, procedures, and part compatibility can vary by production date, trim level, and region. Always consult your vehicle's factory service manual and verify part numbers before purchasing or performing repairs. Safety-critical components such as airbags, seat belts, and braking systems should be installed by a qualified professional.

Year Coverage
This article covers the OBD-II Code P0340 (Deep Dive) for:
  • Nissan Xterra: 20052006200720082009201020112012201320142015
In this article
🧭 Diagnostic Flowchart
Jump to ▴

Email This Guide

We'll send you a link to this article so you can read it later or share it.

Added to cart · Part