No announcement yet.

Moving Left vs. Right

  • Filter
  • Time
  • Show
Clear All
new posts

  • Moving Left vs. Right

    There are several ideas on how to detect direction of motion in the thread at In that thread I posted the Sonoff/MQTT implementation using the IR LED beam break approach where three IR LED receivers were mounted in a Sonoff Basic case and provided some of the lessons learned from the exercise. In that thread I indicated disappointment in the maximum distance of the IR beam which was about one foot. This is a follow-up to describe success with a a higher power IR LED emitter. The write up of the implementation is in Section 13.8 of mcsMQTT.pdf (

    The new IR LED emitters are rated at 100 ma vs. the assumed 20 ma in the original implementation. This changed the effective beam distance from one foot to three feet, but it did make pointing of the LEDs very sensitive. Small angle of misalignment would make the circuit non-functional. In a third implementation I used three emitters in parallel as shown the picture. This showed to provide two benefits. One is that distance increased to four feet. Further Increase to 52 inches resulted in false beam-break reports. The second is that the alignment is not as sensitive. I actually found that a perpendicular alignment of emitter threesome vs. received threesome provided easier alignment. I suspect this means that in my case the vertical rather than horizontal alignment was more sensitive. I believe that commercial beam-bream implementations over long distance, such a garage door safety, use lens to help with beam focus and alignment.

    Overall I consider the very simple circuitry of IR LED and resistor pairs to be quite viable for motion direction detection for selected situations. The span of beam separation becomes the limiting factor. Mounting on a doorway which is typically three feet of narrower would be a good use case. A staircase which is typically under four feet wide is another. Pet doors have very small spans so even the original implementation of a single 20 ma IR LED receiver will work well.

  • #2
    While evaluating the IR beams spanning a doorway I was getting results that appeared incorrect for quickly moving objects. I changed the firmware to be interrupt rather than polling and was surprised to see the IR receivers would rapidly toggle between conducting and non-conducting when moved to larger distances from the emitter. Two feet was stable, but 40 inches was not. Ran out of time and will not be back to continue for a month.


    • #3
      To continue this project I packaged up a solution with two receivers and three emitters and attempted an install across a 36" doorway. Components are in first picture. I tried both horizontal and vertical mount of the emitters. I was able to get beam break detection on one, but not on two emitters. It was just too difficult to align all the pieces over this distance. It may be possible to duplicate the emitter to improve pointing tolerance, but did not try it.

      Next chapter was with a commercial beam break sensor that uses a 38 KHz carrier to greatly increase distance and improve noise immunity. The one in the second picture that I tried was rated up to 15 meters and nicely packaged in 2.5" x 1" cases. I determined that this particular device is totally inappropriate to detect left vs. right motion. It was several seconds for it to detect the beam blockage and the beam had to be totally blocked as the emitter IR reflections made it hard to block the beam. It is good to detect if a door is open or closed, but not for detecting an object moving through the beam. I believe other commercial solutions such as those used for garage door safety beam would work, but are not cost-effective nor lend themselves to unobtrusive mounting solution.


      • #4
        I now have a fielded solution with a good result for detecting motion direction and controlling a light based upon the direction of motion. The beams are installed in the doorway between the house and garage and augment control the garage light. My specific need is when carrying wood from garage into the house which is a daily activity during the winter. When I return to the house I need to turn the garage light off, but my hands are full of wood. Either I try to balance the wood on my leg or hope I remember to return to turn the light off. Now I can enter the garage and the light automatically turns on and then when I leave the garage it turns off.

        A pair of laser diodes and pair of photo-resistors are used for two beams that span a three foot doorway. These were direct replacements for the IR LEDs and provide the range necessary for reliable operation. mcsTasmota was updated to 5.9.13j to handle a use case I had not anticipated in the original 5.9.13i design.

        The existing garage light switch now serves as an input to the Sonoff. The Sonoff controls the garage light one of three ways. The original with use of the wall-mounted toggle switch. The second via Alexa. The third based upon motion direction. When motion is from house into garage (and the wall switch is off) the garage light will turn on for 30 minutes. The 30 minutes is a Tasmota input parameter. When motion is from garage into house the garage light will turn off after three seconds. This delay is to allow the house light to be turned on while the garage door is open and providing the initial entry light. In my case the house entry light is provided by X10 motion sensor which trips about the time the door is in motion.

        MQTT event reporting to HS is the state of the light, motion into the garage and motion from the garage. Periodic (10 minute) update of wall switch, each beam break status as well as the normal Tasmota parameters such as RSSI, uptime, etc. In my case I do not need to monitor garage/house passage, but on exterior doors this may be desirable.

        I more fully described the project in Section 3.18.1 of It is based upon the earlier work describe in this thread and initially documented in Section 3.18.