Dual Laser Tripwire with MQTT

A few weeks ago I saw a post in the home assistant subreddit, about a device that hides things you might not want someone to see when they break a laser tripwire, based on the VL53L0X time of flight laser rangefinder. This was a self contained unit that plugs into a usb port and send a keyboard shortcut.

At the time it seemed cool, and I decided to order a couple of breakouts and see if anything could be done to attach one to an esp, maybe via esphome. Anyway, I turned to the arduino environment in the end and mashed three libraries together with the example code and got one up and running. Then I remembered i’d ordered two, so I set about making a dual laser system, so that if they are placed so someone passing breaks one, then the other, you get an indication of direction as well as the trigger.

This is now working so although there is room for improvement, it works quite well. It’s much better than a PIR and seems to work well. So here’s the code:


Wiring is easy, standard i2c bus with a couple of extra wires - the boards usually expose a “shutdown” pin, which turns the chip off to allow programming when there are multiple chips on the same bus. So I wired one each from D3 and D4 on the D1 Mini I was using, then set the pins in the code. Anyway, I drew a crude version in paint:

Anyway, thought someone might like it. I find it’s useful for switching lighting as you move from room to room, but only just scratching the surface. Could be used to detect mail coming through the letterbox, or to keep an eye on a closed door without having to damage it to mount something on it (say for renters).

I plan to keep at it for now and will be adding hardware to the prototype to allow calibration. At some point I’ll work on a better circuit diagram too :slight_smile:

Here’s a pic of the prototype:



If this was over a distance (say 2-3m outside) what sort of accuracy would be required for the connection? And would it be able to deal with that sort of distance? I assume consumer lasers are fairly low on power.

1 Like

The range is low. 1-2 meters. I’ve mounted my test version at the top of some stairs, where it monitors at night, if i walk one way it turns on low lights, when I come back it turns it off again.

1 Like

God dammit… Everytime I think I’m done…

Good work man :+1: Was waiting for someone to implement this in an esp version.


Nice, I’ve been looking for something like this for my garage door opener, so the door will not close if there there is something blocking the path.

1 Like

There’s some action with these modules in esphome although it’s not made it to release yet - I’m hoping it will. I prefer the OTA updates for instance.

If you need longer range, take a look at VL53L1X which doubles the distance (or highers accuracy and robustness to intereference).

Btw: VL53L1X adds also ROI so you don’t have to use two sensors to indicate direction of movement.


That video makes this look way too easy lol.

That video is awesome. I would love to have something like that in the stairwell to my basement. Just need to find an enclosure like this to put it in:
360 motion detector

Did anyone make this using a battery instead of powered cable. I would love to make this more as a small sensor, that doesnt need to be powered using a power outlet!

Wow! That’s just what I needed, thanks for the video, didn’t know that this thing could do this :wink:

Thanks for the Diagrams etc. I am soon going to try this out.
I bought myself some VL53L0X like these but they do not have GPIO1 and XSHUT, instead they have X and E

I got it working (trial and error) with the following schematic:

Hope this helps someone…