We research and compare products using published specifications, features and owner feedback. When you buy through our links, we may earn a commission. As an Amazon Associate I earn from qualifying purchases. Learn more›

Arduino Auto Top Off Optical: Build a Sensor-Based ATO for Reef Tanks

Learn how an arduino auto top off optical sensor works, how to wire and calibrate it, and how to avoid common reef tank mistakes. Step-by-step build guide.

Updated November 2026

An arduino auto top off optical system uses an infrared sensor and a small microcontroller to detect when your sump water level drops, then switches a pump or solenoid to replace evaporated water. Done right, it keeps salinity stable and protects your pumps from running dry. This guide covers the parts, wiring logic, sensor placement and calibration you need to get a reliable build.

How an Optical Arduino ATO Works

An optical sensor pairs an infrared LED with a phototransistor. When the water is at the correct level, the sensor’s beam is interrupted or reflected in a known way, and the Arduino reads that as “level OK.” When the level drops below the sensor, the reading changes and the Arduino energizes a relay that runs your RO/DI top-off pump until the level returns. Because the sensor never touches the water, there is no corrosion or conductivity drift to worry about, which is the main advantage over conductive probes.

Shopping for one? See our guide: 6 Best Aquarium Auto Top Off System Picks for Reef Tanks (2026).

Parts and Setup Steps

Gather these before you start:

  • An Arduino board (Uno or Nano work well for this job)
  • An infrared optical level sensor or a reflective IR pair
  • A relay module rated for your pump’s voltage and current draw
  • A 12V or 24V DC supply, or a 120V-rated enclosure if you switch mains loads
  • A float reservoir or sensor housing that mounts above the sump’s maximum level
  • Silicone-safe tubing, a shutoff valve and a dedicated RO/DI reservoir
  • Wiring the Sensor and Relay

    Mount the sensor in a short, clear-walled section of the sump or a sight tube so the beam crosses the water surface cleanly. Route its signal wire to a digital input on the Arduino, power it from the Arduino’s 5V rail if its current draw allows, and connect the relay control pin to a digital output. Keep high-voltage pump wiring physically separate from the low-voltage sensor leads. Use a proper enclosure and GFCI protection for any mains-connected pump.

    Calibrating the Sensor Threshold

    Calibration decides whether your ATO runs too often or too little. Set the sensor at the level you want maintained, then:

    1. Fill the sump to your target water line and record the analog or digital reading the Arduino sees.
    2. Lower the water by about 1/4 inch and record the new reading to confirm the difference is clear.
    3. Set the trigger threshold midway between those two readings, with a small hysteresis band so the pump does not chatter on and off.
    4. Add a maximum run timer in the code, so a stuck sensor or empty reservoir cannot pump indefinitely.

    Testing and Safety Checks

    Before leaving the system unattended, run it through several full cycles. Confirm the pump stops at the target level and that the timer cuts power if the sensor stops responding. Check that the RO/DI reservoir has enough water for at least a full day of evaporation in your tank, and add a low-reservoir alarm if you can.

    Common Mistakes

    • Mounting the sensor where splashing or bubbles cause false readings
    • Skipping hysteresis, which makes the relay cycle rapidly
    • Powering a pump directly from the Arduino pin instead of through a relay
    • Forgetting a max-run timeout, so a failed sensor floods the sump
    • Using tap water in the reservoir instead of RO/DI water, which adds dissolved solids

    If you would rather start from a tested design, read Arduino Auto Top Off: A Step-by-Step Build Guide for Reef Tanks for a full wiring diagram, or compare commercial options in Setting Up an Auto Top Off System: A Step-by-Step Guide for Reef Tanks before committing to a DIY build.

    • Arduino Uno R3 is a widely supported board with plenty of community code examples for level sensing. View on Amazon
    • Songle SRD-05VDC relay module gives a simple, isolated switching stage for the pump. View on Amazon
    • Infrared obstacle avoidance sensor is a common low-cost optical option for detecting a water line through a clear housing. View on Amazon

    FAQ

    Can an optical sensor work in saltwater?

    Yes, because it sits outside the water in a clear housing or sight tube and never contacts the saltwater. Keep it dry and free of salt film, which can alter the reading over time.

    How often should I recalibrate the threshold?

    Check it every few weeks and after any change to sump volume, sensor position or water flow. Salt creep and algae on the housing are common reasons readings drift.

    Is a DIY ATO safe to leave running overnight?

    It can be, provided you include a max-run timer, a low-reservoir alarm and tested fail-safe behavior. For mains-connected equipment, consult a licensed electrician for installation.

    Conclusion

    An arduino auto top off optical build is a practical way to keep your reef’s salinity steady without touching a conductive probe. Mount the sensor carefully, calibrate with a clear hysteresis band and always include a fail-safe timeout. Test thoroughly before you walk away from the system.

    Caleb Morgan

    About Caleb Morgan

    Caleb Morgan is part of our editorial team and reviews and edits our reef & saltwater aquariums guides, checking product details against manufacturer specifications and owner feedback.

    About the author

    Caleb Morgan
    Caleb Morgan

    Caleb Morgan writes reviews and buying guides for My Reef Aquarium.