Simulator

A water level sensor simulator on an Arduino

Mokxi is a free online water level sensor simulator that runs in your browser, with nothing to install and no account needed. The red water level sensor from the starter kits, with its signal on A0 of an Arduino Uno. Drag the water up the sensor’s traces and the reading climbs through dry, low, half and full on the serial monitor.

  • 505parts on the bench
  • 45boards running now
  • 1.00xreal time, on every board
Arduino Uno: a water level sensor on A0live0.000 s 0.00x
Click to open it in the editor
Click the circuit to open it in the editor, then drag the sensor’s water level up. The serial monitor prints a new line each time the level crosses into another band.

What you can do here

In the circuit above, or in the editor it opens.

  • Set how far the water reaches up the sensor, in millimeters
  • Read the level with analogRead on A0
  • Sort the reading into dry, low, half and full
  • See why the reading is not a straight line in depth
  • Add a buzzer or a pump and build a tank alarm
  • Find your own thresholds before you wet a real sensor

What the running circuit shows

A big first step, then smaller and smaller ones.

The sensor is a set of bare copper traces. Water bridges them, and the more trace is under water the more current reaches the signal pin. Dry, the sketch prints “reading 0: dry”. The first millimeter of water takes it to 127 and “low”, with A0 at 0.62 V. At 10 mm it reads 506, “half”, 2.48 V. At 20 mm, 608 and “full”, and at the top of the traces, 40 mm, about 675, or 3.30 V.

So the first 10 mm are worth 506 counts and the next 30 mm only about 170. The reading tells you clearly whether there is water and roughly how much, but it is not a ruler, and the sketch treats it that way: four bands, not millimeters. It also prints only when the band changes, which keeps the monitor readable.

How the sensor is modeled

The shape of the curve, for clean tap water.

The model gives the curve this sensor has in ordinary tap water: a jump at first contact, then a flattening climb that tops out well under the supply. Set thresholds on that shape and your logic will carry over to the real part.

The exact numbers will not carry over. A real sensor’s reading depends on how conductive the water is, so salty water reads higher and distilled water barely reads at all. The traces also corrode when powered all the time, and the readings drift as they do; neither effect is modeled. On hardware, power the sensor from a digital pin and switch it on only for the moment you read it.

How it works

Three steps from a blank tab to a running circuit.

  1. Open the editor

    It runs in your browser tab. Nothing to install, and you need no account to start.

    Your first project
  2. Wire it and write the code

    Drag parts onto a breadboard, run each wire from pin to pin, and write the sketch beside it.

    Wiring
  3. Press Run

    Your sketch compiles in the tab and runs on a model of the chip, with the Serial Monitor beside it.

    Run and serial
Reviews

What makers say about Mokxi.

“The AI checker helps check and correct my circuits, and it has way more components than Tinkercad. As a student I really appreciate the tool.”

ChloeEngineering student

“I’d been looking for a real online electronic simulator that was intuitive and complete when I found Mokxi. I was able to quickly import a Fritzing file and my Arduino sketch and start testing. Mokxi has all of the makings for the best online Arduino simulator I have been able to find!”

JayModel builderFeatured in his DioramaOS post

“I’m using Mokxi to develop and simulate an STM32-based four-wheel-drive robot car before building the actual hardware. It allows me to experiment with DC motor control, PWM, RPM measurement using photointerrupters, and different acceleration, braking, and reversing strategies, helping me understand and refine the system before implementing it in real life.”

NusretRobot car builder, Hamburg

Share your story

FAQ

Questions, answered.

Is it free?

Yes. The circuit on this page, every part in it and the editor it opens in are on the free plan, with no card.

Do I need an account?

No. The circuit runs the moment the page does, and the editor opens without one. A free account is only for saving a project to the cloud and sharing it by link.

What value does a water level sensor give on an Arduino?

A count from 0 when dry up to somewhere near 700 when fully covered, on a 5 V Uno. In this circuit 1 mm of water reads 127, 10 mm reads 506 and 40 mm about 675.

Can a water level sensor measure depth in centimeters?

Only roughly. The reading rises quickly at first and then flattens, and it changes with the water’s mineral content. Use it for bands such as empty, low and full. For a real depth, measure down to the surface with an ultrasonic sensor.

Why did my water level sensor stop working after a few weeks?

Corrosion. With power on all the time the traces plate away. Feed its supply pin from a digital output and turn it on only while reading.

More simulators

Each one opens on a circuit that is already running.

Fill the tank

Open the circuit, drag the water up and watch the bands change. Nothing to install, and no account needed.