A PIR sensor simulator: the HC-SR501 on an Arduino
Mokxi is a free online PIR motion sensor simulator that runs in your browser, with nothing to install and no account needed. An HC-SR501 motion sensor on an Arduino Uno’s pin 7, with an LED on pin 13 that copies its output. Click the sensor’s white dome to start something moving in front of it, and click again to stop.
- 455parts on the bench
- 43boards running now
- 1.00xreal time, on every board
What you can do here
In the circuit above, or in the editor it opens.
- Start and stop movement with a click and watch the output
- Set the hold time, the trimmer on the real board, in the properties panel
- Switch the jumper between repeat and single trigger
- See the block time that makes a fresh PIR look broken
- Switch a lamp, a relay or a buzzer from the output
- Edit the Arduino code and press Run again
What the running circuit shows
High while it moves, and a while after.
The HC-SR501 does the sensing on its own board and gives a plain digital output: high while it sees movement, low when it does not. Its OUT pin is 3.3 V whatever it is powered from, which an Uno reads as HIGH. The sketch copies it onto the LED and prints each change.
In the engine a click on the dome puts OUT at 3.3 V, the LED lights and the serial monitor prints “motion detected”. Click again and the output stays high for the 2 second hold time, then drops and the monitor prints “all still”. Click right away and nothing happens for 2.5 seconds: that is the block time, when the module ignores everything after a pulse.
How the sensor is modeled
Hold, block and retrigger, as on the board.
Hold, block and retrigger are properties. Set the hold to 5 and the output stays high 5 seconds after the movement stops. With the jumper in repeat, the default, movement that goes on keeps the output high for as long as it lasts; set it to single and one movement gives one 2 second pulse, however long it goes on.
What it leaves out: the lens and its zones, range and angle. A click stands for something warm moving in view, so the sensor cannot be fooled by a heater or miss someone walking straight at it, as a real one can. A real module also needs up to a minute to settle after power-up; this one is ready at once.
Questions
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.
Why does my PIR sensor stay on?
Its hold time keeps the output high for a while after the movement stops, 2 seconds here and adjustable by a trimmer on the real board. With the jumper in repeat, ongoing movement keeps it on.
Why does my PIR sensor not react right after it turns off?
After each pulse it ignores everything for its block time, 2.5 seconds on the HC-SR501. Wait it out and it detects again.
Do I need a resistor on the PIR output?
Not to read it. OUT drives a clean 3.3 V signal straight into a digital pin. To switch a lamp or a relay, put a transistor between them.
More simulators
Each one opens on a circuit that is already running.
Wave at a sensor
Open the circuit, click the dome and press Run. Nothing to install, and no account needed.