3D Printable Virtual Wall for iRobot Roomba

Sometimes it is useful to keep a Roomba robot vacuum out of a particular area. You can buy a factory virtual wall for this, but you can also build one yourself with an Arduino and a few inexpensive parts.

Modern mapping robots offer a different solution: you can mark no-go zones in their app. This project is mainly intended for compatible older models.

Difficulty: Intermediate / Advanced

Created: January 2021

Technically checked: October 2026

First, we will try an updated version of the earlier, simple virtual-wall sketch that still works today. Then we will look at what our measurements revealed about the factory wall’s infrared signal and build a second version that follows its measured pattern more closely.

The simple virtual wall – an updated version of the earlier sketch

At the heart of the virtual wall is an infrared LED. It emits light we cannot see, but the Roomba’s sensors may detect. The sketch repeatedly sends a short burst of infrared light and then pauses for the same length of time. This setup worked with the Roomba 530 and 531, other models may not respond in the same way.

Arduino virtual wall circuit

Parts and wiring

  • Arduino Uno or Nano,
  • an infrared LED with a wavelength around 940 nm,
  • a series resistor for the LED: 220 Ω in the tested setup,
  • connecting wires; for standalone use, a suitable power supply and switch.

Connect D3 through the resistor to the IR LED’s anode (the longer lead), and connect its cathode to GND. The resistor limits the current through both the LED and the Arduino output. In the earlier battery-powered Nano build, the positive terminal of the 9 V battery went through the switch to VIN, while the negative terminal went to GND. The LED wiring and sketch are the same if you use a USB-powered Uno for your first test.

Do not omit the resistor! We tested 220 Ω with the LED driven directly from D3. Do not choose a lower value simply in the hope of extending the range. The current ratings of the output and the LED matter; a higher LED current calls for a properly designed, separate driver circuit.

Arduino D3 pin to series resistor to infrared LED to GND; on the Nano, the switched 9 V supply connects to VIN
Wiring the Roomba virtual wall. The series resistor helps protect both the LED and the Arduino output.

The updated Arduino sketch

Install version 4.7.1 of the Arduino-IRremote library. The earlier sketch used the IRremote.h header and IRsend API of its time. The version below keeps the same simple signal-generation idea while using the current library interface.

#include <IRremote.hpp>

const uint8_t irLedPin = 3;

void setup() {
  IrSender.begin(irLedPin);
  IrSender.enableIROut(38);
}

void loop() {
  IrSender.mark(1000);
  IrSender.space(1000);
}

IrSender.begin() configures the D3 output. enableIROut(38) selects a 38 kHz carrier: while the LED is transmitting, it flashes rapidly rather than shining continuously. mark(1000) sends that carrier for roughly 1000 µs (1 ms), and space(1000) pauses for 1 ms. loop() repeats the pair continuously.

This is not a copy of the factory wall’s complete signal. Even so, it can be enough for a tested Roomba to treat the beam as a barrier. Start by placing the LED at the height of the robot’s sensor and testing it from close range. If the robot turns away, increase the distance gradually.

3D-printable virtual wall enclosure
A 3D-printable virtual wall enclosure.

I previously designed a simple 3D-printed enclosure for the Arduino Nano virtual wall. You can download the design here.

Closer to the factory signal: measurements and a new sketch

Once the simple wall was working, we became curious: what kind of signal does the factory virtual wall actually transmit? We needed two types of measurement. An infrared receiver tuned to 38 kHz revealed the slower on–off rhythm of the signal, but not the details of the carrier. To examine those, we built a small test circuit.

Connect the photodiode’s cathode to +5 V and its anode through a 10 kΩ resistor to GND. Oscilloscope channel 1 measures the junction between the anode and resistor; its COM lead connects to GND. When light reaches the photodiode, a voltage pulse appears at that junction. This is a reverse-biased arrangement for the BPW34. See the Vishay BPW34 datasheet.

BPW34 photodiode with a 10 kΩ resistor connected to an oscilloscope
The BPW34 photodiode test circuit and oscilloscope.

With the BPW34 photodiode and a Hantek DSO5072P oscilloscope, we could also see the rapid flashing. We measured the factory wall and the Arduino wall from the same position using the same oscilloscope settings.

Factory Roomba virtual-wall infrared burst compared with the Arduino burst at a 4 ms-per-division timebase
The rhythm of the two recorded bursts is similar, but this does not prove that the devices are identical.

In the clean recordings, we found eight transmitting intervals separated by seven pauses. The approximate short-and-long pattern of the transmitting intervals is 3–1–3–1–1–1–3–1 ms; a complete burst lasts about 30 ms. Both carriers are around 38 kHz. These are approximate measured values, not protocol specifications published by the manufacturer.

Factory and Arduino IR carriers measured with the same BPW34 photodiode and oscilloscope settings
The shorter timebase shows the roughly 38 kHz carrier and the difference in duty cycle.

In our sample, the factory signal’s optical duty cycle was approximately 56–58%. The usual 30% electrical setting of Arduino-IRremote produced a lower optical duty cycle in this measurement. Setting it to 50 brought the Arduino’s measured optical signal to around 55%. That is closer to the factory measurement, but it does not by itself establish equal light output or equal range.

The ZIP below contains the original .rec files saved by the Hantek DSO5072P. The comparison images above were generated from these recordings.

The measured-pattern version we tested

This version uses the same D3 → series resistor → IR LED → GND wiring. In our recent Uno test, we used a 220 Ω resistor, secured the wire connections and positioned the LED roughly 84 mm above the floor, matching the height of the factory wall’s LED. The sketch sends a pattern lasting almost 30 ms and schedules the start of successive bursts about 140 ms apart.

#define IR_SEND_DUTY_CYCLE_PERCENT 50
#include <IRremote.hpp>

constexpr uint8_t kIrLedPin = 3;
constexpr uint8_t kCarrierKHz = 38;

const uint16_t kFactoryFrameUs[] = {
  3080, 1020, 1040, 3060,
  3060, 1040, 1060, 3080,
  1000, 3080, 1020, 3080,
  3080, 1040, 1040
};

constexpr uint32_t kFramePeriodUs = 140000UL;
uint32_t nextFrameStartUs;

void setup() {
  IrSender.begin(kIrLedPin);
  nextFrameStartUs = micros();
}

void loop() {
  if ((int32_t)(micros() - nextFrameStartUs) < 0) {
    return;
  }

  IrSender.sendRaw(
    kFactoryFrameUs,
    sizeof(kFactoryFrameUs) / sizeof(kFactoryFrameUs[0]),
    kCarrierKHz
  );

  nextFrameStartUs += kFramePeriodUs;
}

The array alternates between mark (transmission) and space (pause) durations in microseconds. sendRaw() sends them in that order using a 38 kHz carrier. For timing, we use the micros() clock: each scheduled burst start is advanced by 140,000 µs. This fixed repetition interval works in our build. We are not claiming that the factory wall always transmits at that exact interval.

In the recordings of this version, the burst length and pattern were close to the factory measurement. In the practical test, the robot clearly turned away. With the LED carefully positioned and under favourable lighting conditions, it worked at distances of around 4 m. That is a result for this tested setup, not a guarantee for every room, LED or Roomba model.

A stable position for the infrared LED was essential to a successful test. A cardboard mock-up was perfectly adequate during development, but a neater enclosure would be better for lasting use. You can find the plans for an earlier 3D-printable version in the first part of this article.

Arduino Uno virtual-wall test stand with the infrared LED positioned 84 mm above the floor
The stand is still experimental, but the LED’s height and reliable electrical connections made a real difference.

What have we established, and what remains open?

The simple, updated sketch works with the newer library. In recordings of the factory and Arduino walls, the carrier frequencies and burst patterns are close. With the second sketch, the tested Roomba turned away, even from roughly 4 m when the LED was positioned correctly. Those are the results supported by our measurements and hands-on tests.

The factory wall’s longer-term repetition pattern remains an open question. The gaps between observed bursts were not always identical, so the 140 ms schedule in our sketch is a deliberate simplification. We did not measure calibrated optical power or establish the LED’s exact wavelength and beam angle, and we have not tested every Roomba series. A final enclosure, the shape of its LED opening and perhaps a separate LED driver are all worthwhile subjects for further experiments.

If you would like to refine it, change just one thing at a time – for example, the LED’s height or direction – and test the range again in the same room with the same robot. An LED with a different beam angle or a well-designed enclosure may help more than blindly reducing the resistor value.

Troubleshooting

The LED emits no signal, or the Roomba does not respond

Check the LED polarity, D3 connection, resistor and common GND. Make sure you have Arduino-IRremote 4.7.1 installed and that your Uno or Nano has a stable power supply. A phone camera can sometimes show the LED flashing, but not every camera can detect infrared light. If you cannot see it on the screen, that alone does not prove there is no signal.

It only works nearby, or the robot passes under the beam

Adjust the LED’s direction and height first. In our recent test, the factory wall’s LED was 84 mm above the floor, so we set our own holder to that height. If the LED points too high or too low, the Roomba can miss its light. Beam angle, ambient light and the robot’s direction of approach may also affect the result. The range achieved with a 220 Ω resistor is not a reason to reduce that value further when driving the LED directly from an Arduino pin.

The signal cuts out intermittently

Check the power supply and wiring: a loose contact can interrupt the signal. On our test stand, we eventually replaced a wobbly connection with soldered wires. For a standalone Nano build, check the switch, battery connector and battery as well. In a permanent enclosure, secure the LED and wires so they cannot move.

A different Roomba model behaves differently

Both working signals prompted the tested Roomba 530 and 531 models to turn away. For other series, begin with a supervised test at close range; we cannot promise compatibility in advance.

For a broader introduction to infrared signals, the NodeMCU infrared remote-control tutorial offers more ideas.


← Further Arduino Tutorials

← More Arduino / ESP Examples and Projects