Simulator

A relay simulator with a real coil, contacts and a motor

Mokxi is a free online relay simulator that runs in your browser, with nothing to install and no account needed. An Arduino Uno switches a 2N2222 transistor, the transistor switches a relay’s coil, and the relay’s contacts switch a DC motor and two indicator LEDs. Every two seconds it clicks over, and the motor starts or stops.

  • 455parts on the bench
  • 43boards running now
  • 1.00xreal time, on every board
Arduino Uno: a relay switches a motorlive0.000 s 0.00x
Click to open it in the editor
The relay pulls in for two seconds, then lets go for two. Click the circuit to open it in the editor.

What you can do here

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

  • Watch a relay pull in and drop out from one pin
  • Measure the coil current and the transistor’s voltages with a multimeter
  • Wire loads to the normally open and normally closed contacts
  • Use both poles of a DPDT relay to reverse a motor
  • Swap in a one, two or four channel relay module that a pin drives directly
  • Edit the code and change the timing

What the running circuit shows

A small current switching a bigger one.

A relay is an electromagnet and a switch. Current through the coil pulls an arm across, and the arm moves the contacts: each common terminal leaves its normally closed contact and touches its normally open one. The coil and the contacts are separate circuits, so whatever the contacts switch never reaches the Uno.

In the engine the coil draws about 40 mA from 5 V, more than an Uno pin should be asked for, so pin 7 drives the transistor through 1 k instead: the pin sits at 4.88 V, the base at 0.80 V, and the transistor carries the coil. Pulled in, one pole puts 5 V on the motor, which spins up to about 160 rpm, and the other lights the green LED. Released, the motor’s lead is grounded, it stops, and the red LED lights.

How the relay is modeled

Coil, timing and contacts, each a property.

The coil is a 125 ohm load that pulls in above 75 percent of its rated 5 V and lets go below 10 percent. The arm takes 5 ms to pull in and 4 ms to drop out, and the contacts are open while it travels. The 1N4007 across the coil is there for the kick a coil gives when its current stops; leave it out of a real board and that spike can kill the transistor.

Beside this DPDT relay there are one, two and four channel relay modules with the transistor already on the board, active low: a LOW pin turns a channel on. What it leaves out: contacts here do not arc, bounce or wear, and the load is a low-voltage motor. Switching mains is a job for a rated module and someone qualified, never a breadboard.

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 a relay need a transistor?

Its coil wants about 40 mA, more than an Arduino pin should supply. The transistor carries the coil current and the pin only feeds its base. Relay modules have that transistor on the board already.

What is the difference between NO and NC?

Normally open (NO) is connected to the common terminal only while the coil is energized; normally closed (NC) is connected while it is not. In the circuit above the motor is on NO and the red LED on NC.

Can I simulate relay logic?

In a small way, yes: two relays’ contacts in series make an AND, in parallel an OR, and a normally closed contact is a NOT. Mokxi simulates the electronics, not a PLC, so ladder logic is not the tool for here.

Make a relay click

Open the circuit, change the timing and press Run. Nothing to install, and no account needed.