กลับหน้าหลัก
views
How to Use Arduino with LJC18A3-BZ/BX Capacitive Liquid Detection Sensor
Last updated on

How to Use Arduino with LJC18A3-BZ/BX Capacitive Liquid Detection Sensor


How to Use Arduino with LJC18A3-BZ/BX Capacitive Liquid Detection Sensor

This tutorial covers wiring and coding Arduino to read the LJC18A3-BZ/BX NPN Capacitive Proximity Sensor, which detects liquids at 0-10mm range. When liquid is detected, it triggers a Buzzer alarm.

Circuit diagram showing connections between Arduino UNO, LJC18A3-BZ/BX Sensor, Buzzer Module, and 12V power supply on Breadboard

Required Components

  • Arduino UNO R3
  • LJC18A3-BZ/BX NPN Capacitive Proximity Sensor M18
  • Active Buzzer Module (3.3-5V)
  • 10k Ohm Resistor (Pull-down)
  • 12V 2A Power Adapter (for sensor power)
  • MB-102 Breadboard 830 Point
  • Jumper wires: Male-Male, Male-Female, Female-Female (40 pcs each)

Wiring the LJC18A3-BZ/BX with Arduino

Key point: This sensor uses 12V power and has NPN output. When detecting an object, the output sinks current to GND (LOW), rather than sourcing voltage.

Part 1: Connect Sensor to Arduino

Arduino UNOLJC18A3-BZ/BX Sensor
GNDGND (blue wire)
5VThrough 10k R to Signal

Sensor Signal pin connects to Arduino digital pin 2.

Detail of blue GND wire and black Signal wire connection from sensor to Arduino with 10k Pull-down resistor

Part 2: Connect Buzzer Module

Arduino UNOActive Buzzer Module
5VVCC
GNDGND
Digital Pin 3I/O

Part 3: Power Sensor with 12V

12V AdapterSensor
Positive (+)VCC (brown wire)
Negative (-)GND (blue wire)

Note: Use a separate 12V power source for the sensor because it requires more current than Arduino can supply.

Complete circuit showing 12V Power Adapter connection to sensor with shared GND to Arduino and Buzzer

Arduino Code for LJC18A3-BZ/BX

This working skeleton code reads the sensor and triggers the Buzzer when liquid is detected.

// Define pin connections
const int SENSOR_PIN = 2;    // Sensor Signal pin
const int BUZZER_PIN = 3;    // Buzzer I/O pin

void setup() {
  Serial.begin(9600);
  pinMode(SENSOR_PIN, INPUT);
  pinMode(BUZZER_PIN, OUTPUT);
  
  // Initially turn off Buzzer
  digitalWrite(BUZZER_PIN, LOW);
  
  Serial.println("Waiting for liquid detection...");
}

void loop() {
  // Read sensor value (NPN: LOW = detected, HIGH = not detected)
  int sensorValue = digitalRead(SENSOR_PIN);
  
  if (sensorValue == LOW) {
    // Liquid detected
    Serial.println("Liquid detected");
    digitalWrite(BUZZER_PIN, HIGH);  // Turn on Buzzer
  } else {
    // No liquid
    Serial.println("No liquid detected");
    digitalWrite(BUZZER_PIN, LOW);   // Turn off Buzzer
  }
  
  delay(500);  // Wait 0.5 seconds before next read
}

Upload and Test Steps

  1. Connect USB cable from computer to Arduino UNO
  2. Open Arduino IDE and paste the code above
  3. Go to Tools → Port and select the COM port
  4. Go to Tools → Board and select Arduino UNO
  5. Click Upload (Ctrl+U)
  6. When “Done uploading” appears, open Serial Monitor
  7. Set Baud Rate to 9600

[image: Serial Monitor window displaying “No liquid detected” and “Liquid detected” messages]

Test Results

With no liquid within 8mm of the sensor, Serial Monitor displays “No liquid detected” and Buzzer remains silent.

When bringing a container with liquid close to the sensor (approximately 8mm), Serial Monitor shows “Liquid detected” and the Buzzer sounds.

Precautions

  • Never connect 12V to Arduino’s 5V pin - this will damage the board
  • Always use the 10k Pull-down resistor to ensure correct HIGH reading when no liquid is present
  • Adjust liquid distance to stay within 8mm from sensor surface for stable results
  • Avoid reverse polarity connections - this sensor has no polarity protection

Summary

LJC18A3-BZ/BX is a Capacitive liquid detection sensor suitable for Arduino projects monitoring water or chemical levels in containers. The main challenge is managing 12V power separately from the 5V logic system, but once wired correctly, it works out of the box without additional libraries.

Reference Video

https://www.youtube.com/embed/2iFsw0Yg9TU

อยากทำโปรเจคแบบนี้?

รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน

If you need Arduino project service or urgent IoT development, see full service details on the home page

จ้างทำโปรเจคเลย

ประเมินราคาอัตโนมัติ + Reference Code

ขอให้ AI ประเมินราคาโปรเจคนี้

กรอกข้อมูลให้ครบ ระบบจะสร้างรหัสอ้างอิงและประเมินราคา/ระยะเวลาคร่าว ๆ จากรายละเอียดงาน แล้วให้กด Add LINE พร้อมพิมพ์รหัสนี้เพื่อคุยต่อ

คำถามให้ AI ประเมินแม่นขึ้น

หลังส่งฟอร์ม ระบบจะโชว์ Reference Code ให้ copy แล้วกด Add LINE เพื่อคุยต่อ ข้อมูลส่วนตัวจะไม่ถูกส่งเข้า GA4

ความคิดเห็น

รีวิวจากคนใช้งานจริง

รีวิวจากลูกค้าและคนที่เคยใช้งาน

ถ้าเคยสั่งงาน เคยอ่านหน้านี้แล้วได้ประโยชน์ หรือมีข้อเสนอแนะ ฝากรีวิวไว้ได้เลย

กำลังโหลดรีวิว...