Simulator

A DS18B20 simulator: two temperature sensors on one wire

Mokxi is a free online DS18B20 temperature sensor simulator that runs in your browser, with nothing to install and no account needed. Two DS18B20 sensors sharing one data wire on pin 2 of an Arduino Uno, with the 4.7 k pull-up the bus needs. The sketch finds both by their addresses and prints each temperature; drag either sensor’s slider and its reading follows.

  • 505parts on the bench
  • 45boards running now
  • 1.00xreal time, on every board
Arduino Uno: two DS18B20 sensors on pin 2live0.000 s 0.00x
Click to open it in the editor
Click the circuit to open it in the editor and watch the serial monitor list both sensors. Drag a sensor’s temperature, or delete the 4.7 k resistor to see the bus fail.

What you can do here

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

  • Read temperature with the OneWire and DallasTemperature libraries
  • Put several sensors on one pin and tell them apart by address
  • Set each sensor anywhere from -55 to 125 °C
  • Remove the pull-up resistor and watch every sensor vanish
  • Read to a sixteenth of a degree
  • Add an LCD or a relay and build a thermostat

What the running circuit shows

One pin, two sensors, two addresses.

Every DS18B20 has a 64-bit address set at the factory, so any number of them can share one wire. On start the sketch searches the bus and prints “2 sensors on the wire”, then each address: “sensor 0 is 28F4FF7BC63CD0F0” and “sensor 1 is 280D057CC63CD36B”. Then it reads both, over and over: “sensor 0: 4.00 C sensor 1: 21.50 C”. One sensor starts in the cold, one at room temperature, so you can tell which is which.

Set them to -10.5 and 85.06 °C and the line becomes “sensor 0: 85.06 C sensor 1: -10.50 C”: negative readings and fractions come through as they should. Now delete the 4.7 k resistor between the data wire and 5 V. The sketch prints “0 sensors on the wire”. Nothing on a 1-Wire bus ever drives the line high; the resistor does, and without it there is no bus. It is the first thing to check when a DS18B20 reads -127.

How the DS18B20 is modeled

The bus timing, the addresses and the conversion time.

The sensors answer the real 1-Wire protocol: the reset pulse, the search that finds each address, and the scratchpad with its checksum. Each covers -55 to 125 °C in steps of a sixteenth of a degree, and a conversion takes as long as the datasheet says, from 93.75 ms at 9 bits to 750 ms at 12.

What it leaves out: parasite power, where the sensor runs from the data wire alone, so wire all three legs; the sensor’s half degree of error; and the time a real probe takes to warm up or cool down. The reading follows the slider at the next conversion.

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.

Why does my DS18B20 read -127?

The library got no answer from the sensor. Usually the 4.7 k pull-up from the data wire to the supply is missing, or the data wire is on a different pin from the one in the sketch. Delete the resistor in this circuit to see the bus go quiet.

How many DS18B20 sensors can share one pin?

Many. Each has its own 64-bit address, so the sketch can ask each one in turn. This circuit runs two on pin 2 with a single 4.7 k pull-up for the whole bus.

How accurate is a DS18B20?

A real one is within half a degree from -10 to 85 °C and reports in steps of 0.0625 °C at 12 bits. The simulated sensor reports exactly the temperature you set, to that step.

More simulators

Each one opens on a circuit that is already running.

Read two temperatures

Open the circuit, drag a sensor’s temperature and watch its line change. Nothing to install, and no account needed.