Simulator

A DHT11 simulator with a temperature and humidity you set

Mokxi is a free online DHT11 simulator that runs in your browser, with nothing to install and no account needed. An Arduino Uno reads a DHT11 on pin 2 with the DHT library and prints the temperature and humidity every two seconds. Change the sensor’s readings on the canvas and the next line follows.

  • 505parts on the bench
  • 45boards running now
  • 1.00xreal time, on every board
Arduino Uno: DHT11 temperature and humiditylive0.000 s 0.00x
Click to open it in the editor
Change the sensor’s temperature or humidity on the canvas, or click anything else to open it in the editor.

What you can do here

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

  • Read temperature and humidity with the DHT library
  • Set the sensor to any reading and watch the sketch follow
  • Switch the part between a DHT11 and a DHT22
  • Pull the data wire and see the sketch report the missing reading
  • Show the readings on an LCD or an OLED
  • Run the same sensor on an ESP32 or a Raspberry Pi Pico

What the running circuit shows

Forty bits on one wire.

The DHT11 has a small chip of its own. The Uno pulls the data line low to wake it, and it answers with forty bits: humidity, temperature and a checksum, each bit a high pulse whose length says 0 or 1. The DHT library does that handshake and checks the sum; the sketch only asks for the two numbers.

In the engine the sensor starts at 22 °C and 45 percent, and the serial monitor prints “temperature 22 C, humidity 45 %” every two seconds. Set it to 31 °C and 81 percent and the next reading says so. Pull the data wire and the sketch prints “no reading: check the DATA wire”.

DHT11 or DHT22

The same three pins, different answers.

The part is a DHT11 or a DHT22, picked in the properties panel. The DHT11 reports whole degrees and whole percent, from 0 to 50 °C and 20 to 90 percent, and the part holds a setting outside that range to the edge of it, as the real sensor would: set it to 60 °C and the sketch reads 50. The DHT22 reports tenths and reaches further. They frame their forty bits differently, so the sketch has to name the right one: make the part a DHT22 while the sketch still says DHT11 and the serial monitor reads “temperature 0 C, humidity 1 %”, the nonsense a real mismatched pair gives.

What it leaves out: a real DHT11 is slow to follow a change in the room and only good to a couple of degrees, and here it reports exactly what you set. The data line’s pull-up is built into the part, a 5.1 k as on the three-pin modules, and it is a property you can turn off to watch the line fail.

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.

Can I simulate a DHT22?

Yes. Set the part’s model to DHT22 and change DHT11 to DHT22 in the sketch’s DHT dht(2, DHT11) line. The DHT22 tutorial has a weather station circuit ready to open.

Why does my DHT11 read nan?

The library got no answer, or an answer whose checksum did not add up. Check the data wire and the pull-up, and that the sketch names the sensor you have. This sketch prints “no reading: check the DATA wire” instead of nan.

How often can I read a DHT11?

Not much faster than it can measure, so the sketch waits two seconds between readings. Ask too soon and the sensor answers with the reading it already had.

More simulators

Each one opens on a circuit that is already running.

Read a DHT11

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