» DIY Optical Liquid Level Sensor: Build & Parts Guide

DIY Optical Liquid Level Sensor: Build & Parts Guide

6월 8, 2026

A diy optical liquid level sensor can be built in two practical ways: assemble your own optical head from an IR LED, 광트랜지스터, 그리고 프리즘 팁, or start with a ready optical level module and focus on wiring, 장착, 및 교정. The first path teaches you how photoelectric liquid detection really works. The second path is faster, 청소기, and usually more reliable for a working tank project.

This guide explains both routes, including parts, cost factors, mounting choices, calibration steps, common failure modes, and when it makes more sense to buy a finished sensor from HojellyTek instead of continuing a DIY build.

How an Optical Liquid Level Sensor Detects Wet and Dry States

An optical level sensor uses photoelectric sensing. Inside the sensor head, an infrared LED sends light into a clear prism or optical tip. A phototransistor, photodiode, or receiver detects the returned light.

프리즘 팁이 공기 중에 있을 때, the IR light reflects internally and returns strongly to the receiver. 액체가 프리즘을 덮을 때, the light behavior changes because the liquid has a different refractive index than air. The receiver sees a lower or different signal, and the circuit converts that change into a wet/dry output.

For a deeper product-level explanation, 호젤리텍의 항목을 참조하세요 광학 레벨 센서 가이드.

For DIY use, this means you are not measuring the full tank height. You are building a point-level detector: empty at this point, full at this point, overflow reached, pump protection level reached, or reservoir refill needed.

Choose Your DIY Build Path First

Path A: Use a Ready Optical Sensor Module

This is the easiest option for Arduino, ESP32, Raspberry Pi Pico, hobby automation, 수족관, 물 탱크, and small reservoirs. The optical head, emitter, 수신기, 주거, and basic circuit are already built. You only handle the low-voltage supply, signal reading, 장착, 및 교정.

A ready module is best when you want a working result quickly and do not need to design the optical geometry yourself.

Path B: Build the Optical Head from Parts

This is the educational route. You use an IR LED, 광트랜지스터 또는 포토다이오드, resistors, a comparator or microcontroller input, and a prism or clear optical tip. It is useful for learning, custom shapes, or lab prototypes.

This route is harder because optical alignment, 주변 광 차폐, 방수, prism clarity, and repeatable calibration all matter. A small change in angle or surface finish can change the reading.

Parts and Cost Planning Table

Exact prices vary by supplier, 질, 하우징 재료, 그리고 양, so use this table as a planning guide rather than a price quotation.

Part or MaterialPurpose in the BuildDIY Cost ImpactWhat to Check Before Buying
IR LEDSends infrared light into the optical tip낮다Wavelength, viewing angle, package size, stable output
Phototransistor or photodiodeReceives reflected IR light낮다감광도, 응답 속도, package alignment
Prism or clear optical tipCreates the wet/dry optical change보통Optical clarity, 모양, 액체 호환성, polish quality
저항기Set LED current and receiver signal level낮다Correct values for your board voltage
Comparator or transistor stageConverts analog signal into stable digital outputLow to mediumThreshold adjustment, noise immunity
아두이노, ESP32, or MCU boardReads the signal and controls logic보통입력 전압, ADC/digital pin behavior
Ready optical level moduleReplaces separate LED, 수신기, and prism design보통공급 전압, 출력 유형, 케이블 밀봉
Housing or enclosureProtects electronics from splashes보통Waterproofing, 케이블 출구, 기계적 강도
Cable gland or sealed cableKeeps moisture away from wiring보통Seal quality, 긴장 완화, tank environment
장착 나사 또는 브래킷Holds the tip at the correct level보통실 크기, 벽 두께, 방향
Finished industrial sensorProduction-ready alternativeHigher upfront, lower rework risk출력, 재료, 장착, 케이블, OEM fit

The hidden cost in DIY is usually not the LED or receiver. It is waterproofing, 반복 장착 가능, optical alignment, and time spent fixing false readings.

Assembly Route 1: Using a Ready Optical Module

For most builders, a ready module is the best starting point.

  1. Identify the low-voltage pins. Most simple modules provide power, 그라운드, and signal. Some modules may provide digital output, analog output, 아니면 둘 다. Do not assume wire colors; check the supplier diagram.
  2. Connect only to a compatible low-voltage control board. Use Arduino, ESP32, a data logger, or a low-voltage PLC input where suitable. Do not connect the sensor directly to mains power or AC pump wiring.
  3. Test in air first. Read the dry-state output before putting the sensor into liquid.
  4. Submerge only the optical tip. Record the wet-state output. If the signal is analog, note the difference between dry and wet values.
  5. Set your threshold. Use a clear midpoint between dry and wet readings, then add a small time delay in code to avoid false switching from waves or splashes.

For low-voltage microcontroller examples, 참고하세요 아두이노 가이드. For general signal connection reference, use the 배선도.

Assembly Route 2: Building from IR LED, 광트랜지스터, and Prism

If you want to make the sensing head yourself, the optical layout is the most important part.

The IR LED should shine into the prism or clear tip at a repeatable angle. The receiver should be positioned where reflected light returns strongly in the dry state. 액체가 프리즘에 닿을 때, the reflected light drops or shifts. Your circuit then detects that change.

A basic prototype can be arranged like this:

  • IR LED aimed into the clear prism body
  • Phototransistor placed to receive reflected IR
  • Resistor to limit LED current
  • Pull-up or pull-down resistor for receiver signal
  • Microcontroller analog input or comparator input
  • Shielding around the optical pair to block room light
  • Sealed mechanical head so liquid reaches only the prism tip

The hardest part is making the prism. A rough plastic tip, scratched surface, cloudy epoxy, or misaligned LED can make the sensor unstable. 물에 대해, a clear plastic optical tip may work for learning. 석유, 연료, 화학 물질, 세제, or hot liquids, material choice becomes much more serious.

Wetted Materials: 플라스틱, PTFE, 스테인리스, 그리고 유리

The “wetted material” is the part that touches the liquid. For a DIY project, people often focus only on the circuit, but the material in contact with the liquid decides whether the sensor survives.

PSU 또는 엔지니어링 플라스틱 can be useful for compact water-level designs where chemical exposure is mild. It is easier to machine or mold than metal.

PTFE is chosen when stronger chemical resistance or anti-stick behavior is needed. It can be useful where residue or aggressive liquid is a concern.

316 스테인리스 스틸 is common for industrial housings because it gives mechanical strength, 내식성, and a professional threaded body.

유리 광학 팁 are often used where optical clarity, 온도 저항, or chemical stability is important. Glass can also help with repeatable sensing at the prism surface.

For DIY learning, simple plastic may be acceptable. OEM 장비 사용, 가전 제품, fuel/oil projects, or exported products, confirm material compatibility before ordering any sensor.

Output Types You May See: 디지털, NPN, PNP, 그리고 4–20 mA

Small hobby modules usually provide a simple digital signal or analog voltage. Industrial sensors may use NPN, PNP, relay-style interface, or 4–20 mA output depending on the control system.

NPN 출력 is common where the sensor sinks current to the control input.

PNP 출력 is common where the sensor sources current to the control input.

4–20 mA 출력 is usually used for industrial analog transmission, especially where long cable runs or noise immunity are important. For a simple point-level DIY sensor, digital output is usually enough.

주문하기 전, check the input type of your controller. A sensor with the wrong output may still be a good sensor, but it will not connect cleanly to your board without interface electronics.

Mounting the Sensor Correctly

Mounting decides whether your optical sensor gives clean readings.

Side mounting is common for point-level detection. The prism tip passes through the tank wall and sits exactly at the level you want to detect. Threaded mounting is stronger than glue or tape, especially when the tank vibrates or the cable is pulled.

For small DIY containers, a bracket can hold the sensor from above, but the tip must stay fixed at the chosen height. If the sensor moves, your trigger level moves too.

Check these mounting points:

  • Keep the prism tip clean and exposed to the liquid.
  • Avoid placing the tip too close to reflective walls or shiny metal parts.
  • Do not let cables hang in a way that pulls on the sensor.
  • Seal the tank opening properly.
  • Keep the electronics side away from condensation and splashes.
  • Choose thread and mounting style before drilling the tank.

생산 장비를 위한, common decisions include straight vs right-angle body, threaded vs flange mounting, plastic vs stainless housing, 그리고 케이블 길이.

교정: Turn Wet and Dry Readings into a Reliable Signal

Calibration is simple but should not be skipped.

첫 번째, power the sensor in air and record the dry reading. Then wet the prism completely and record the wet reading. If using analog input, choose a switching threshold between those two values. If using digital output, confirm whether the module reads HIGH when wet or HIGH when dry.

Then test real conditions:

  • slow filling
  • fast filling
  • 첨벙거리는 소리
  • 거품
  • 거품
  • droplets clinging to the tip
  • dirty water or residue
  • ambient light exposure
  • vibration near the tank

Add debounce in code or logic. A short delay before confirming wet or dry prevents false alarms when liquid briefly touches the prism.

Common DIY Mistakes and How to Avoid Them

Ambient light interference: IR receivers can be affected by sunlight, strong lamps, or reflective surroundings. Shield the LED and receiver, and test near the final installation environment.

더티 프리즘: 유막, mineral scale, 조류, 먼지, or sticky liquid can change the optical path. Clean the tip and choose a material that matches the liquid.

Wrong output assumption: Some sensors switch ON when wet; others switch ON when dry. Always test both states before connecting control logic.

Poor waterproofing: A working bench prototype may fail inside a humid tank area. Seal cable exits, protect the circuit board, and avoid exposed solder joints near liquid.

Bad prism geometry: DIY prisms need clean surfaces and repeatable angles. Rough-cut acrylic or cloudy adhesive can reduce reflection.

No mechanical strain relief: Cable movement can loosen the sensor or crack a seal.

No debounce: 파도, 거품, and droplets can create short false transitions. Confirm the state for a short period before acting on it.

When Buying a Finished Sensor Is Cheaper Than DIY

DIY is cheaper when you are learning, testing one idea, or building a quick prototype from parts you already have. But a finished optical level sensor is often cheaper when you count the full project cost.

Buy a finished sensor when you need:

  • repeatable wet/dry detection
  • sealed cable and housing
  • stable NPN, PNP, or industrial output
  • compact body for limited space
  • PTFE, 316 스테인리스, 잔, or other wetted-material options
  • OEM/ODM 맞춤화
  • production quantity consistency
  • export-ready supplier communication
  • fewer field failures

HojellyTek은 광전 광학 감지에 중점을 둔 선전의 제조업체이자 수출업체입니다, 내부 R&D, and OEM/ODM liquid level sensor projects for customers in the US, 우린, 인도, 그리고 기타 시장. If your DIY prototype is moving toward a real product, 우리의 finished micro optical sensor may reduce rework, sealing risk, and assembly time.

What to Confirm Before Ordering a Finished Optical Level Sensor

Before sending an RFQ, 이 세부사항들을 준비하세요:

  • 액체형: 물, 기름, 연료, 세정제, 냉각수, or chemical
  • tank material and wall thickness
  • mounting position and required thread style
  • wet/dry logic requirement
  • 출력 유형: NPN, PNP, 아날로그, 또는 다른 인터페이스
  • supply voltage required by your control board
  • cable length and connector preference
  • 습윤 재료 선호: 플라스틱, PTFE, 316 스테인리스, 잔
  • whether the project needs OEM body size, private label, or custom cable
  • whether the sensor is for prototype, pilot run, or mass production

For smart tank monitoring or connected appliance projects, you can also discuss integration needs such as controller boards, wireless modules, or Tuya/Smart Life-related system design where relevant.

FAQ

Can I build a diy optical liquid level sensor with an IR LED and phototransistor?

예. You can build a basic optical point-level detector with an IR LED, 광트랜지스터, 프리즘 팁, resistors, and a low-voltage control board. The difficult parts are optical alignment, 방수, 주변 광 차폐, and stable calibration.

Is a ready optical level module better than building from separate parts?

For most practical projects, 예. A ready module saves time because the optical head and basic circuit are already assembled. Building from separate parts is better for learning, custom experiments, or understanding how the sensing principle works.

Can this sensor measure the full tank level?

A basic optical level sensor detects liquid at one point. It tells you whether the prism tip is wet or dry. For continuous tank level measurement, you need a different sensing approach or multiple sensing points.

Why does my optical sensor trigger incorrectly?

Common causes include sunlight, dirty prism surfaces, droplets stuck on the tip, reflective tank walls, loose wiring, 밀봉 불완전, and no debounce in the control logic. Test dry and wet readings under real mounting conditions.

Can I use this sensor to control a pump?

You can use the low-voltage sensor signal as an input to a suitable controller. Do not wire the sensor directly to mains power or an AC pump. Any pump power circuit should be designed with proper isolation and safety protection by a qualified person.

When should I contact HojellyTek instead of continuing DIY?

Contact HojellyTek when your prototype needs a sealed body, stable output, 컴팩트한 크기, special wetted material, OEM/ODM 맞춤화, or production-ready consistency. 액체 타입을 보내세요, 장착 방법, 출력 요구사항, and quantity plan by WhatsApp or email to request a quote.