DIY Optical Liquid Level Sensor: Build & Parts Guide
He diy optical liquid level sensor can be built in two practical ways: assemble your own optical head from an IR LED, whakawhitiwhiti whakaahua, and prism tip, or start with a ready optical level module and focus on wiring, whakamau, me te tōkarikari. The first path teaches you how photoelectric liquid detection really works. The second path is faster, horoi, 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.
Ina hau te pito poroporo, the IR light reflects internally and returns strongly to the receiver. Ina taupoki te wai i te pororua, 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, tirohia te HojellyTek's pūoko taumata ōmata aratohu.
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, aquariums, kura wai, and small reservoirs. The optical head, emitter, kaiwhiwhi, whare nohoanga, and basic circuit are already built. You only handle the low-voltage supply, signal reading, whakamau, me te tōkarikari.
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, whakawhitiwhakaahua, diode whakaahua rānei, 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, whakangungu rama taiao, parewai, 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, kounga, rauemi whare, and quantity, so use this table as a planning guide rather than a price quotation.
| Part or Material | Purpose in the Build | DIY Cost Impact | What to Check Before Buying |
|---|---|---|---|
| ARAHI IR | Sends infrared light into the optical tip | Hakahaka | Wavelength, viewing angle, package size, stable output |
| Phototransistor or photodiode | Receives reflected IR light | Hakahaka | Tūtohutanga, tere urupare, package alignment |
| Prism or clear optical tip | Creates the wet/dry optical change | Waenga | Optical clarity, āhua, hototahitanga wai, polish quality |
| Ngā Ātete | Set LED current and receiver signal level | Hakahaka | Correct values for your board voltage |
| Comparator or transistor stage | Converts analog signal into stable digital output | Low to medium | Threshold adjustment, noise immunity |
| Arduino, ESP32, or MCU board | Reads the signal and controls logic | Waenga | Ngaohiko tāuru, ADC/digital pin behavior |
| Ready optical level module | Replaces separate LED, kaiwhiwhi, and prism design | Waenga | Ngaohiko tuku, momo huaputa, cable sealing |
| Housing or enclosure | Protects electronics from splashes | Waenga | Waterproofing, putanga taura, kaha pūkaha |
| Cable gland or sealed cable | Keeps moisture away from wiring | Waenga | Seal quality, whakaora uaua, tank environment |
| Te whakamau i te miro, taiapa rānei | Holds the tip at the correct level | Waenga | Rahi miro, mātotoru o te pakitara, takotoranga |
| Finished industrial sensor | Production-ready alternative | Higher upfront, lower rework risk | Huaputa, papanga, whakamau, taura, OEM fit |
The hidden cost in DIY is usually not the LED or receiver. It is waterproofing, whakamaunga tukurua, 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.
- Identify the low-voltage pins. Most simple modules provide power, whenua, and signal. Some modules may provide digital output, huaputa tairitenga, ngā mea e rua rānei. Do not assume wire colors; check the supplier diagram.
- 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.
- Test in air first. Read the dry-state output before putting the sensor into liquid.
- Submerge only the optical tip. Record the wet-state output. If the signal is analog, note the difference between dry and wet values.
- 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, tirohia te Kaiārahi Arduino. For general signal connection reference, use the hoahoa waea.
Assembly Route 2: Building from IR LED, Whakawhitiwhakaahua, 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. Ina pā te wai ki te pororua, 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. Mō te wai, a clear plastic optical tip may work for learning. Mō te hinu, Kora, matū, horoi horoi, or hot liquids, material choice becomes much more serious.
Wetted Materials: kirihou, PTFE, tīra poapoa, me te Karaehe
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, kirihou pūkaha rānei 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 tīra poapoa is common for industrial housings because it gives mechanical strength, ātete waikura, and a professional threaded body.
Ngā aki ōmata karaehe are often used where optical clarity, parenga pāmahana, or chemical stability is important. Glass can also help with repeatable sensing at the prism surface.
For DIY learning, simple plastic may be acceptable. For OEM equipment, taputapu, fuel/oil projects, or exported products, confirm material compatibility before ordering any sensor.
Output Types You May See: Mamati, NPN, PNP, me te 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.
Huaputa NPN is common where the sensor sinks current to the control input.
huaputa PNP is common where the sensor sources current to the control input.
4–20 mA huaputa 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.
I mua i te tono, 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.
Mō ngā taputapu whakanao, common decisions include straight vs right-angle body, threaded vs flange mounting, plastic vs stainless housing, me te roanga taura.
tōkarikari: Turn Wet and Dry Readings into a Reliable Signal
Calibration is simple but should not be skipped.
Tuatahi, 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
- tārewa
- mirumiru
- huka
- 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.
pororua paruparu: Kiriata hinu, mineral scale, almue, puehu, 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: Ngā Ngaru, huka, 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 poapoa, Karaehe, or other wetted-material options
- Whakaritenga OEM/ODM
- production quantity consistency
- export-ready supplier communication
- fewer field failures
Ko HojellyTek he kaiwhakanao Shenzhen me te kawekawe e arotahi ana ki te pūoko ōmata whakaahua, R ā-whare&D, and OEM/ODM liquid level sensor projects for customers in the US, MATOU, Īnia, me ētahi atu mākete. If your DIY prototype is moving toward a real product, to tatou 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, whakaritea ēnei taipitopito:
- momo wai: wai, hinu, Kora, horoi horoi, waiwhakao, or chemical
- tank material and wall thickness
- mounting position and required thread style
- wet/dry logic requirement
- momo huaputa: NPN, PNP, tairitenga, tētahi atu atanga rānei
- supply voltage required by your control board
- cable length and connector preference
- manakohanga rauemi mākū: kirihou, PTFE, 316 poapoa, Karaehe
- whether the project needs OEM body size, tapanga tūmataiti, 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.
FQ
Can I build a diy optical liquid level sensor with an IR LED and phototransistor?
Āe. You can build a basic optical point-level detector with an IR LED, whakawhitiwhiti whakaahua, pito pororua, resistors, and a low-voltage control board. The difficult parts are optical alignment, parewai, whakangungu rama taiao, and stable calibration.
Is a ready optical level module better than building from separate parts?
For most practical projects, Āe. 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, hiri koretake, 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, rahinga kiato, special wetted material, Whakaritenga OEM/ODM, or production-ready consistency. Tukua tō momo wai, aratuka whakamau, whakaritenga huaputa, and quantity plan by WhatsApp or email to request a quote.