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.
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 UNO | LJC18A3-BZ/BX Sensor |
|---|---|
| GND | GND (blue wire) |
| 5V | Through 10k R to Signal |
Sensor Signal pin connects to Arduino digital pin 2.
Part 2: Connect Buzzer Module
| Arduino UNO | Active Buzzer Module |
|---|---|
| 5V | VCC |
| GND | GND |
| Digital Pin 3 | I/O |
Part 3: Power Sensor with 12V
| 12V Adapter | Sensor |
|---|---|
| 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.
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
- Connect USB cable from computer to Arduino UNO
- Open Arduino IDE and paste the code above
- Go to Tools → Port and select the COM port
- Go to Tools → Board and select Arduino UNO
- Click Upload (Ctrl+U)
- When “Done uploading” appears, open Serial Monitor
- 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
อยากทำโปรเจคแบบนี้?
รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน
If you need Arduino project service or urgent IoT development, see full service details on the home page
จ้างทำโปรเจคเลย