How to connect IR beam sensors?

How do I detect when someone enters my driveway, without false triggers?

Our Ring flood cam with its PIR wakes us up when a cat walks by. Every night!

Seems to me the best way would be with an IR beam sensor. Those units with a sender and receiver, which look like this:

From my search so far, it seems people aren’t doing this. Is there a reason I may have missed?

My main question is how can I integrate this with HA? What hardware do I need to add?

If you have power and wifi available at the site this would be an easy ESPhome project.

As per what Tom has suggested you can simply use them as a digital input to something as simple as a Wemos D1 mini (I like the new version which includes mounting holes) running ESPhome. Have a look at ESPhome, it’s super easy to create your own devices and you can have many sensors on the one device

1 Like

Could a Sonoff Basic work as the hardware?

I had a quick look at those links. It doesn’t yet look super easy but I have some reading to do!

It really is. Check out Frenk’s doorbell project for an excellent tutorial on how it’s done:

yes that is also an option but would require mains power and the risks involved with that.

1 Like

Aha! That’s a great article for a newby like me. Now it’s starting to look like something I could actually do.

I’ve bought the IR sensors and this will be my first try at something like this. Fair point about the Sonoff basic, no need for mains power here.

Thanks Dave and Tom!

@etude, did you manage to integrate the IR sensor? I am thinking about the same project placing those beam sensors around my house. Lessons learnt would be appreciated.


I used optex beam sensors, zero false alarms, day or night, sun or rain. Have them tied to my alarm panel, chimes when someone drives up driveway. Working on adding alarm to Home Assistant via AlarmDecoder. Certainly, any Arduino or ESPHome device could connect to it, they typically have a Normally Open relay that momentarily closes when sensor is activated. You would just need to pullup the signal to 3.3 or 5V (depending on the microcontroller) using a 10K resistor and tie the other wire to ground.

I use the same ir beam break sensors as above via tasmota on a d1 mini, they are fantastic and super cheap. I have documented my setup here

1 Like

Sadly no - I have too many projects!

hi, I’m trying to follow your guide, can’t recognize this your diagram (sorry I’m a newbie :slight_smile: )

That’s a 5v regulator to power the d1 mini which requires 5v while the sensor require at least 12v to max 24v. using the regulator lets me power both the d1 mini and the beam break off the one 12v supply.

1 Like

Thanks, Now I see you explained it, I missed it, sorry.
Didn’t the other side of the IR beam break sensors needs to be connected? It just receives the Beem? Without any power?

the “other” side is just a mirror (reflecor)

1 Like

I just implemented this for my house this week using ESP Easy and MQTT, working great so far

1 Like

Just curious how far you got with these?

I’m in the UK and just purchased some off Amazon for around £20… Although the instructions are very vague, it’s actually quite simple enough!

I’ve just tested as above using EspHome and an esp8266 node mcu (from Amazon) and works a treat!

With all the improvements over the last couple of years to ESP Web Tools - this is much easier for a novice.

If needed, I can do a write up.

Hello Im new here. Can somebody help me how to set up a d1 mini with a beam sensor to work in home assistant. The video is no longer available and this post is 2 years old.
Thank you


This is a pretty dodgy effort at drawing the circuit on a free web based circuit design program but hopefully you get the idea.

Depending on the P.E. Beam you buy/have you may need to do the power side slightly different, depending on the voltage requirements.

Thank you Dave for your time and help.
Do you know what will be a programing line in HA to make it work?

Thanx a lot

You will need to program the Wemos D1 mini first. I suggest using ESPhome. It is really easy to use once you have a read of the documentation. You will need to setup a GPIO input.

Once you have flashed to D1 mini with your ESPhome program then add that device to HA. Again, the docs will assist you here but basically you just go to setting > Devices & Integration > add integration > ESPhome > enter the fixed IP address for the D1 mini that you programmed it with.

Then you can create HA automations to have the P.E. Beam trigger whatever you want in HA.