The current device will be an infrared proximity sensor. The sensor is assembled on an inexpensive Attiny13 microcontroller, easy to manufacture and does not need any adjustment.

Sensor video:

How does such a sensor differ from, say, factory-made motion sensors (which, by the way, have become very affordable and inexpensive)?

The main difference is the scope. Ready-made sensors are still more focused on large rooms and motion control. In our case, the sensor is compact and more designed for proximity control functions and is designed to be built into finished projects.

The scope of use can be extensive:

- the reaction of objects to the approach of a hand (for example, interactive toys, automatic devices);
- opening lockers, doors and the like when a hand approaches;
- ignition of light when passing the "check point";
- orientation in the robot space (control of walls and obstacles);
- control systems for hand movements;
- alarm;
— …

1 Principle of work.

The sensor works very simply. The device sends out pulses with a certain period using an IR LED. Infrared rays, reflected from the object, are received by the TSOP infrared receiver. The object is - there is a signal, there is no object - there is no signal. So that there are no false positives from household consoles, noise, pulses when the light is turned on, the device transmits a certain sequence of pulses and when decoding TSOP, everything that does not coincide with this sequence is discarded. On household appliances (controlled by IR remote controls) the device has no effect, since the signal is relatively weak and modulated by a sequence that is not used anywhere.

2 Scheme, board.

Structurally, the sensor is already assembled. The scarf has worked well in various projects, so it was decided to do this project on it as well.
A minor design change is the installation of a variable resistor to adjust the sensitivity of the sensor. There are no more changes. The components used in the design are not critical to the ratings - close to them can be used.

3 Microcontroller firmware.

To flash the microcontroller (in the board), you need to connect the programmer to the appropriate pins:

Let me remind you: For Algorithm Builder and UniProf, checkboxes are set as in the picture.
For PonyProg, AVR Studio, SinaProg, checkboxes are put inversely.
Fuse Bytes: Low \u003d $ 7A, High \u003d $ FF
How to program microcontrollers read in

4 Design features.

One of the disadvantages of the circuit is the dependence of the sensor sensitivity on the general illumination. This is due to the automatic correction of the sensitivity by the TSOP itself (so that extraneous illumination does not bring the receiver into the non-working area).

There are several ways to reduce this effect:

- In order for the receiver to receive less extraneous light, you need to place it in an opaque tube (I used a black heat shrink, having previously shrunk it to obtain thicker walls) and close the tube on one side with an opaque stopper (I filled it with black hot glue) and put it dark on the other -red light filter. This design is maximally protected from indirect illumination, while the sensitivity does not suffer, since the red filter is highly permeable for infrared rays. It is advisable to place the IR LED in the tube as well - this will reduce lateral reflections infrared rays - capable of giving false positives.

- Another way to solve this problem is to apply light correction, for example, the simplest is to use a photoresistor in the sensitivity control circuit (in series with a variable sensitivity resistor). With brighter lighting, the current through the photoresistor increases, which leads to an increase in sensitivity and vice versa.

Another recommendation, this time for installing the sensor. Since the principle of the sensor is based on the reception of reflected radiation, when an object is close to a reflective plane (for example, a wall in a corridor), reflections from the plane will give an additional background that will reduce the overall sensitivity. In this case, try to place the sensor at an angle to the plane - this will direct the reflected beams to the side (for the most part).

5 Sensor operation.

After assembling the sensor, we turn it on. To begin with, we set the sensitivity to the middle, turn on the sensor, direct it in the right direction and set up a reliable response to the object we need with sensitivity.

If during the operation of the sensor control from the household remote control will be used, you need to go through the procedure for studying the button (command) of the remote control. The device uses only one button - toggle the trigger value. To study the button, it is necessary to de-energize the device, “press down” the TSOP output leg (on the diagram “Out” leg) to the “ground”, turn on the device, release the “Out” leg and press the selected button on the remote control. The sensor will now start working normally.

When several sensors are turned on at a close distance from each other (for example, to control the direction of movement of an object), the sensors will interfere with each other's work, since their signals are not synchronized. To eliminate this problem, use the output of prohibiting infrared radiation "LED-Deny". On all devices except one, this pin must be “pinned” to “ground”. In this case, all sensors will work from the bottom infrared signal source. If one emitting LED is not enough, then you can connect IR LEDs in parallel to the output of the emitting device (not forgetting about the ballast resistors).

In the case of parallel operation of several sensors, all of them must be taught the same button on the remote control, or all must not be taught.

6 Conclusions.

The circuit has both advantages and disadvantages.

For starters, the disadvantages:
- Dependence of the device operation (sensitivity) on the brightness of the lighting. This is being solved, to some extent, but there is a problem;
- Low resolution (small objects will “work” badly);
- Small range of response (the presence of reflective walls and ceilings reduce the range, since they do not allow increasing the sensitivity - false alarms from reflections appear).

Well, for dessert - advantages:
- Simplicity of design (and if you have assembled a scarf before, you don't need to do anything at all!);
- Lack of scarce and expensive items;
- Does not need adjustment.

As you can see from the video, the sensor reacts fairly confidently to the hand within half a meter. Works confidently from the remote control and does not interfere with the nearby TV. The consumed current is within 10mA. The sensor can be powered from sources with a voltage of 3 to 6 volts (some TSOPs cannot operate below 5 volts - this must be taken into account).

  • pbvf

    I will describe the situation in more detail: there is a room with two entrances. When entering from either side, the lamp should turn on (the motion sensor is standing and brakes firmly) When leaving the room, it immediately turns off.
    If an object in this room and someone else crossed any of the entrances, the light is still on, and it will go out only if there are no people in this room ... no matter how simple

  • GetChiper Post author

    This sensor is not able to determine the direction of its intersection (that is, it does not know whether they entered or exited).
    It is necessary either to install sensors controlling the direction of intersection, or to control the presence of people in the passage (for example, with a PIR sensor)

  • pbvf

    it's all wrong. I will try to describe the algorithm of all the work, since you can write programs, unlike me :-). and so there is a room with two or three entrances (and or exits). each entrance / exit is controlled by an IR block like yours, and the entire room is controlled by a PIR sensor - light, after someone is in it, it will be turned on, and will turn off only after the PIR sensor command that all objects have left this room on a signal from any of the IR-blocks. All this is handled by the microcontroller (not necessarily tinka13, but better AVR Thank you!

  • GetChiper Post author

    They explained it somehow confusingly. Poorly understood. If there is a PIR sensor that monitors people in the room, why monitor the entrances separately? Or are the entrances to the premises long corridors?

  • pbvf

    all PIR-sensors work for some time after the object leaves the control zone, or turn off when a person is still inside the room. Again, the sensation is not very good, and one sensor cannot fully scan the room, and there is a large delay when entering the control zone. there are circuits on the counters, but this is with one input / output. okay, I have one idea here ... today I will collect your sensors (I made the boards yesterday), and I will stir up. ATP for participation. And if something needs to be changed in the firmware, I hope you will not refuse

  • Anastas

    Hello! Can I please the source code of the program? What language was the firmware written in?

  • GetChiper Post author

    The source is at the end of the article.
    Written at http://algrom.net/russian.html

  • Anastas
  • vitalik.dog1958

    Thank! Probably not all modifications have looked through.

  • vitalik.dog1958

    Good afternoon GetChiper! I looked through your links there is only a conversation about the third contact.
    What would pins 3 and 7 with memorization and only from the remote control no and did I not find it? And please do 10 seconds in the same firmware. off delay on 5 legs.
    Sincerely. Thank.

  • GetChiper Post author
  • In order to attract customers or buyers, you can make an automated advertising stand or showcase, in which the backlight will turn on when a person approaches it. An attempt to use standard motion sensors for this has been unsuccessful, because they react to movement, not presence.

    Infrared proximity sensor

    Yes, when a person approaches, the motion sensor will turn on the advertisement, but if the person stops and stands looking at an advertising stand or a shop window, the advertisement will turn off, because there will be no movement. We need a sensor that does not respond to movement, but to the fact that a person is standing in front of him. For example, an infrared reflection sensor, the diagram of which is shown here. The sensor consists of an "optical pair" from the TV remote control system, an infrared LED HL1 and a resonant photodetector HF1 tuned to a frequency of 36 kHz.

    The LED and photodetector are directed in one direction to the place in front of the advertising stand or showcase. They should be located so that the light from the NI does not directly hit the HF1, but only when reflected from the obstacle located in front of the sensor. That is, there must be an opaque partition between them.

    The multivibrator on the elements D1.3 and D1.4 generates pulses with a frequency of 36 kHz (exactly this frequency is set by selecting the resistance R7). These pulses are fed to the base of the key on the VT3 transistor. Its collector circuit includes a NI infrared LED. Light-emitting diode
    emits flashes of IR light, repeating at a frequency of 36 kHz, and the intensity of these flashes depends on the current through the LED, the value of which is set by selecting the resistance of the resistor R5.

    If a person stands in front of the sensor, the flashes of light emitted by the NI LED are reflected from it and hit the HF1 photodetector. In this case, the output switch of the photodetector opens and its output (pin 3) will be a logical zero. Transistor VT1 opens and charges the capacitor C2. The voltage across it is a logical unit. At the output D1.2 is also a logical unit.

    Transistor VT2 opens and relay K1 with its contacts (not shown in the diagram) turns on the lighting of the stand or showcase. When a person steps aside, the light does not turn off immediately, but after 23 seconds (time for the discharge of C2 through R3). This is necessary so that the light does not blink when a person moves near an advertising stand or shop window. The sensor's sensitivity (range to a person) depends on the resistance R5.

    Robots, like death, all humans really need sense organs to navigate in space. The Sharp GP2Y0A21YK infrared rangefinder is very suitable for this role if you need to avoid colliding with obstacles or know where this obstacle is located approximately.

    By the way, you may already have one of the robots in your home that uses similar sensors. These are practically all sane Chinese robotic vacuum cleaners and, I suppose, many Roomba models. And probably many others.

    And if these sensors have found a place in more or less serious technology, then we will find a use for them, right?

    In order not to bend my heart, I will say right away: I ordered these sensors not just to play with. On the contrary, from the very beginning I knew that they would be useful to me to make an interactive lamp that changes the intensity of the glow depending on the position of the palm above it.

    Of course, reality made its own adjustments in the end. In other words, it now has five modes: night light, dimmable light, thermometer, manual northern lights and automatic northern lights.

    And besides - a couple of service functions: turning on and off the background and overhead lighting in the room.

    This is how it works:

    Well, now is the time to tell in more detail about the sensor, thanks to which everything happened.

    As I said at the very beginning, Sharp GP2Y0A21YK is an infrared rangefinder. This means that it is equipped with an IR emitter and an IR receiver: the first serves as a source of the beam, the reflection of which is caught by the second. In this case, the infrared rays of the sensor are invisible to the human eye (although you can distinguish red flicker if you look into the sensor) and at this intensity are harmless.

    They also have no effect on pets.

    According to the characteristics are as follows:

    • Supply voltage: 5V
    • Maximum current draw: 40mA (typical 30mA)
    • Working range: 10 cm - 80 cm
    As for the competitors, compared to ultrasonic sensors, for example, the super popular HC-SR04, this sensor has advantages and disadvantages. The advantages include all that is said above, i.e. neutrality and harmlessness.

    And the disadvantages are a smaller range (HC-SR04 has about 4 m) and dependence on external interference, including some types of lighting. For example, I've seen mentions that sunlight can affect sensor readings.

    The sensor is supplied in a spartan kit, i.e. the sensor itself and a cable with a connector for connecting to the sensor. On the other side, there are just tinned wires, which is not very convenient for use with the Arduino Uno, but it is quite suitable for controllers without soldered connectors. Since I was planning to use the sensor with the Arduino Pro Mini, this was quite suitable option - I just soldered the wires into the breadboard.

    The wires differ in color: yellow - signal, black - ground, red - plus power (+ 5V).

    The sensor output is analog (although for some reason it says digital in the datasheet). That is, the voltage on it is proportional to the distance to the obstacle. At the same time, as in the case of ultrasound, for the sensor there is a difference between different types obstacles.

    In this regard, Sharp provides data in the datasheet when using Kodak reference cards with a reflectivity of 90% as reflectors. Judging by it, the sensor outputs 1.3V at 20 cm.

    Let's compare with my experimental data:

    As a reminder, the Arduino analog input operates in the 0V - 5V range and has 1024 steps, hence the calculation: (5/1024) * (sensor readings). So if you take into account the fact that everyone is with their own (trembling) hands, then the readings fit perfectly into the characteristics of the sensor. And at the same time it is clear that the black surface makes its own adjustments.

    So it shines

    At the same time, as the attentive reader has noticed, there is some specificity. The bottom line is that when the obstacle is closer to the lower limit of the radius of action (10 cm), the sensor begins to consider that the obstacle, on the contrary, is removed (when the hand is covered, the readings are fixed at 345).

    It looks like this:

    Hence the conclusion: although for many purposes the datasheet is quite adequate, sometimes it makes sense to conduct experiments so that later it would not be excruciatingly painful. And this is especially true if the sensor is slightly recessed (or covered with an IR-transparent material), which means it can receive reflections from the walls or other elements of the case.

    For example, I was faced with the fact that Evlampia, being installed in a regular place after successfully conducted "table" tests, began to go crazy. At first I thought that the power supply was to blame and even put a pair of capacitors (10 μF and 0.1 μF) in parallel with the sensor power supply, pulled the Arduino analog input to zero through a 10 kΩ resistor, and even bought a power filter socket.

    But when this did not help, he returned to the table again, where he twisted the sensor in different directions and saw that, in fact, even if the distance to the nearest obstacle is more than 80 cm, the sensor readings change noticeably. So if your charges are inadequate - check the actual readings in real conditions.

    For example, here is an elementary sketch that, firstly, displays the sensor readings at intervals of half a second, and, secondly, lights up the Arduino LED if the readings fall in the range from 100 to 200:

    // Yellow - A0, Black - ground, Red - + 5V unsigned int l; void setup () (Serial.begin (9600); pinMode (A0, INPUT); pinMode (13, OUTPUT); l \u003d 0;) void loop () (l \u003d analogRead (A0); Serial.println (l); delay (1000); if (l\u003e 100 && l< 200) { digitalWrite(13, HIGH); } else { digitalWrite(13, LOW); } }

    To summarize, the sensor, while a bit moody, is very easy to use and relatively cheap.

    It can be used in robots, as well as for intersection control doorways, in some kind of interactive devices controlled by gestures and in something else that fantasy tells you.

    I plan to buy +33 Add to favorites Review liked +38 +67

    Unfortunately, there will be no application yet, since it came to me later than planned (the reason is not in the speed of delivery, but in some other reasons) and I had to apply a much more expensive solution.

    There are different switches and switches.
    There are ordinary ones that are at home. To enable or switch them, you must click on them.
    There is a touch sensor, you do not need to press them, you just need to touch them.
    And there are non-contact ones, but not in terms of lack of contacts (although one does not interfere with the other), but in the absence of the need to even touch the switch, you just need to bring your hand to it.
    Here we will talk about the last type of such devices.

    I'll start, as always, with a description and a photo of what I received, and in the process I will tell you what it is, why and what kind of approximate analogues of this device are.
    She came in a neat box, the switch itself (or rather the switch) was in a transparent bag, but I took it off before the photo.

    Inside the bag was.
    The actual switch.
    Hardware kit, two plastic plugs and two screws.
    Instructions on english language, although it is not particularly needed for this device, since it does not have any adjustment organs, and the outputs are signed on the back of the device itself.
    A piece of paper I don't understand.

    Instructions, what if someone comes in handy :)

    The button itself is made of very high quality, the metal is strong, albeit thin, very similar to stainless steel, the plastic parts fit well.
    Yes, and it looks pretty nice, only the Exit inscription annoys, then I'll write why.

    There are 5 wires at the back.
    Red and black, respectively, plus and minus power supply, everything corresponds to the generally accepted marking (there are exceptions).
    Yellow - common contact of the relay
    Green - normally open contact
    White - normally closed contact.
    The wires are not very long, about 15cm.

    So we gradually got to the insides.
    The board in the device is double-sided, the assignment of the wires is also signed on the back, which is very pleasant, since the piece of paper pasted on the back may well come off, be damaged, etc.
    The back cover is not sealed, but it fits quite well, but the hole for the wires is made with a margin, so the protection class is indicated only for the front panel.

    Logically, there should be a photo of the insides next. It will be, but first I will make a small lyrical digression.
    For starters, what are the proximity switches.
    1. Capacitive, require touching, or bringing the hand to a very close distance. Probably the simplest and cheapest solution. I had one involving such a sensor.
    2. Radio frequency, operating on the Doppler principle. The most expensive sensors.
    3. Sensors based on the reflection of infrared radiation. Simple and inexpensive, but a compromise option.

    And now the advantages and disadvantages.
    Capacitive, relatively inexpensive, but it is desirable to touch the surface, may not work correctly in the case of electromagnetic interference.
    RF, operate at a very high frequency, about 24 GHz. Complex and, accordingly, expensive, but less afraid of interference, not afraid of surface contamination, they can work through opaque plastic.
    Infrared, simple construction, the range is comparable to radio frequency, but may decrease if the surface is heavily contaminated and does not work through materials that are opaque in the IR range.

    And now I will try to explain why I use such switches.
    In addition to writing reviews, soldering boards, I am installing automatic sliding doors... and these doors do not always include a motion sensor.
    And since I install such doors at enterprises, then there are sanitary standards according to which it is desirable (and sometimes necessary, for example, in operating rooms and toilets) to use activators for opening doors with contactless control (there are even special devices where you need to insert a leg, which bby the contact worked).

    Until recently, I used sensors from the Belgian company Bea. for instance

    The cost of one such sensor is (if I'm not confusing anything) about $ 130.
    And often you need two sensors for one door.
    It should be noted that these sensors are not vandal-proof, the monitored one is more robust, but it is also not considered vandal-proof.

    So I smoothly got to the point of showing how the IR sensor is arranged inside.
    First, I will show the very place where the board is placed, the holes for transmitting and receiving IR radiation are clearly visible, they are made so that the IR receiver sees only the reflected radiation.
    The board itself will not work.
    By the way, a sealing gum around the perimeter of the metal would not hurt, but in an expensive radio frequency one it is also not there.

    And now the circuit board of the device itself.
    It can be seen -
    IR LED.
    IR photodetector, such are usually used in various radio equipment with remote control, operating frequency 38 KHz (measured).
    Relay, its parameters correspond to the parameters specified in the instructions.
    Connector for connecting wires.
    The power input is protected by a self-resetting fuse and a diode that protects against the wrong polarity of the power supply. then there is a 5 Volt power stabilizer, electrolytic capacitors absent, which only increases reliability.
    Four bi-color LEDs. Lights up red in normal mode and blue when triggered.
    Control IC, small, 6 feet, in SOT23 package.

    For control, a microcircuit is used on which 02En is written, I found it on the Internet, but I'm not sure if this is it, since the page is in Chinese and looks like a page of some incomprehensible trading platform or forum.
    It not only constantly generates pulses to control the LED, but generates certain sequences of pulse trains, a photodetector is connected to it, respectively.
    As a result, obstacle recognition is quite correct, it does not react to the IR remote control, as well as to strong illumination by an incandescent lamp (but this is the merit of the photodetector).

    Naturally, I measured the consumption currents in standby and working mode.
    In standby mode it consumes 27mA. Power supply 12 volts.

    In active mode, a little more, 38mA, since the relay is on.

    In standby mode, the backlight is red, a little uneven, but it may be intended.

    In active mode, the backlight is blue, but since a matte diffuser is used, it does not bother much.

    The operating range is about 8cm by hand and about 15cm from a sheet of white paper.
    It works very clearly even for a relatively quick hand movement, after triggering it is in active mode for about two seconds, after which it goes into standby mode.
    It does not work on relatively thin objects.

    The design is quite thin, most of it is recessed, as it is designed for inset into the wall / panel.

    To be on the safe side, I measured the main dimensions, suddenly someone will come in handy.

    As I wrote above, the power supply is 12 Volts, which hints that the device is intended for use in security systems, and the Exit inscription says the same about it.
    Industrial automation systems have a standard 24 Volt power supply, and they can operate from direct current and from alternating.
    I think that with a simple revision, the button can also be used with industrial automation systems.
    The button could be very convenient in various fields of application, but the inscription is annoying, in my opinion one could suggest either different variants inscriptions, or provide stickers with various inscriptions in the set.
    Scope of application -
    Access control devices.
    Control of door opening in rooms where it is necessary to give a command to open without touching, grocery enterprises, operating rooms, clean rooms, toilets, etc.
    Just places where such control can be convenient, for example, in the kitchen (with appropriate decoration) to turn on the lighting.

    In general, when I wrote this review, I had a feeling of light deja vu, I described similar impressions of the device in the review. In particular, I really liked the quality of workmanship and the rather thoughtful and reliable-looking circuitry.

    On the Internet, I have come across at least two options for homemade implementation of such a device, one on the LM567CN chip, as well as on. I collected the last option and it is successfully used by me, if interested, I can somehow make a review.

    Summary.
    Pros.
    Price.
    Nice appearance.
    High-quality workmanship and a fairly well thought-out design.

    Minuses.
    I would like a sealing gum around the perimeter for sealing.
    Since the device can be used not only as an exit button, I would like to have options for changing the inscription.

    My opinion. Quite a decent and easy replacement for RF proximity switches, and also does not generate RF radiation.

    This product was provided free of charge, for review and testing, by eachbuyer store.

    I think that an overview of this device can be helpful. I am waiting for questions and comments.
    If I forgot to mention something, write, I will add.

    P.S. By adding a penny microcircuit (and possibly one resistor and capacitor), you can convert the device into a bistable one, i.e. raised your hand, turned it on, brought it up again, turned it off. The cost of the rework is about 20 cents, the HEF4013BP microcircuit.
    Now the device works as an analogue of a non-fixed button (like an exit button in intercoms, although this sensor is made for such an application).
    Perhaps there will still be a review with a similar revision :).

    I plan to buy +91 Add to favorites Review liked +112 +198

    Close