I recently moved into a two-story apartment, with an intercom system at the entrance of the building, located in the lobby area. Since I usually live upstairs, I want to find a way to remotely open the door without having to rush downstairs to the intercom every time someone presses the doorbell. It would be very convenient. Even better, if I could know when someone presses the doorbell when I’m not at home, that would be great! This way, I can handle doorbell events in a timely manner and won’t miss any important visits.
My apartment’s intercom system has a basic setup, including a buzzer, a button to unlock the hall door, and a speaker, but the microphone in my intercom doesn’t work. The system is powered by 14V AC, but it has an electrical noise problem. Moreover, the system lacks voltage spike suppression, and I often see a small arc when I press the button to control the unlocking of the hall door. This also causes the error counter on my broadband modem to increase by 1. To solve these problems, I need to pay attention to the following points:
- Solve the problem of the microphone not working.
- Reduce the impact of electrical noise.
- Add voltage spike suppression to prevent arcing.
- Prevent the error counter on the broadband modem from increasing.
The System
The first thing to do was to find some schematics of the system and try to figure out which wires do what. After searching for the manufacturer “Elvox” and “art 870” which were printed on the PCB inside I found plenty of information.
So, it looks like I need to sense the ring in (connection 6) for an AC signal and make a connection across the door open switch to open the door lock (connection 7 to 4/5).
Prototype
I have successfully built a prototype using a NodeESP board, an optocoupler connected to the bell input, and a relay connected to the lock solenoid. The prototype works normally, with the ESP able to detect the bell sound through the optocoupler and activate the lock solenoid through the relay. Next, we will design a real product, aiming to neatly install it inside the intercom casing. To achieve this, we need to:
- Optimize the NodeESP board design to make it smaller and more compact for easy installation.
- Select suitable optocouplers and relays to ensure reliable operation.
- Design a PCB board that fits the intercom casing, ensuring all components are correctly installed.
- Implement an aesthetically pleasing and practical casing design, ensuring the product’s appearance and quality meet requirements.
Through these efforts, we will create a powerful and visually appealing product that meets actual application needs.
I decided to use the ESP-M2 WiFi module, which includes the ESP8285 (ESP8266 with built-in flash). The power supply comes from a 5V USB charger adapter, which is then regulated by a 3V switch-mode voltage regulator. I initially planned to “steal” some AC power from the intercom system to power the lock solenoid, but I had to abandon this idea because I couldn’t completely control the ESP’s power consumption, which caused the lock to produce a quiet humming noise. Every time I tried to do something, I had to run back and forth in the building, which was also a painful experience.
To avoid electrical connections between the intercom system and the controller, I needed to implement optical isolation. The optocoupler and relay design used in the prototype was too simple, so I decided to design my own isolation system. To do this, I used a bunch of LEDs to achieve optical isolation. These LEDs not only acted as photodiodes, producing a small current when exposed to light, but were also much cheaper than dedicated photodiodes. Although they may not be as good as dedicated photodiodes, they were sufficient for my needs.
Buzz Detection
The buzzer sound detection is achieved through an optical coupler consisting of two infrared LEDs (LED6 and LED7, Kingbright KPA-3010F3C). The optical coupler consists of a transmitter LED (LED6) connected to the intercom’s ring line, which faces a photodiode LED (LED7) operating in photovoltaic mode, similar to a solar cell, producing a current in the opposite direction of the arrow when light is shone on it. The photodiode LED is connected to the ESP8285’s ADC input through a low-pass filter.
When the intercom emits a buzzer sound, the transmitter LED shines light onto the photodiode LED, producing a small voltage that the ESP can detect. The reason for using a low-pass filter is that the intercom is powered by a 50Hz AC power source, and the photodiode LED also outputs a 50Hz waveform. To reliably detect the buzzer sound, the ESP needs to sample the ADC every 5 milliseconds. However, since the ADC is also used for various internal WiFi purposes, the ESP seems to work poorly when sampling the ADC so frequently. To solve this problem, the low-pass filter is used to smooth out the waveform, allowing the ESP to sample every 50 milliseconds.
Since all the intercom door switches in the building are connected in parallel, I can detect when others unlock the hall door through the intercom. To achieve this, I connected the LED to the bell input and door switch with a resistor of the correct value. This causes the LED to emit light at 4 different brightness levels, which in turn produces the same number of different voltage levels at the ESP’s ADC input. This allows me to determine the state of the hall door by detecting these voltage levels.
ESP ADC 读数
Unlocking the Door
The circuit for controlling the door lock consists of 4 infrared LEDs (of the same type as the buzzer detector), a dual MOSFET, and some other components, which are used to create an optically isolated solid-state AC relay. The working principle of this circuit is as follows: one LED emits light to the other three photodiode LEDs, generating a total voltage of approximately 2V between them, which is just enough to turn on the MOSFET. To protect the MOSFET, two back-to-back 24V zener diodes are used to clamp the high-voltage spikes mentioned earlier.
The current from the photodiode LED is very small, so the turn-on time of the MOSFET is quite slow, approximately 1ms. However, since the time required to open the solenoid is relatively short, this speed is still fast enough to avoid damaging the FET. With the help of the fast turn-off circuit Q2, D3, and R9, the turn-off time is much faster, approximately 100us. R9 is a relatively large 10MΩ resistor, and a smaller value would help to speed up the turn-off time, but if it’s too small, it would eventually draw too much current from the photodiode LED, preventing the FET from turning on.
Furthermore, I think that using a visible LED instead of an infrared LED might produce a higher current and voltage, which could improve the turn-on speed of the MOSFET.
Supply voltage: 20V DC
Yellow: Voltage across 32.5R test load (615mA @ 20V)
Blue: Output of ESP pin to emitter LED.
Internet of Things
My server runs a Node.js application that hosts a Telegram bot and a WebSocket server. The ESP device connects to the server via WebSocket and transmits JSON messages to the server when events occur. Then, the server formats the messages and sends them to a Telegram group chat, notifying group members of these events.
The JSON message sent for when a buzz is detected (it also includes a lot of extra information about its WiFi connection and things):
{
"notify": "ring",
"requestId": "",
"millis": 1029721207,
"session": "aabbccdd-eeff-0011-2233-46678941fd69",
"disconnectreason": 0,
"fw": {
"version": "1.0.0 211117",
"build": "Jan 10 2022 23:30:38"
},
"counts": {
"wifi": 1,
"ws": 1,
"ring": 6,
"unlock": 15,
"neighbour": 40,
"stuck": 0
},
"net": {
"ip": "10.0.0.97",
"subnet": "255.255.255.0",
"gateway": "10.0.0.1",
"dns1": "10.0.0.1",
"dns2": "(IP unset)",
"hostname": "ESP-AABB55"
},
"wifi": {
"ssid": "MyWiFi123",
"bssid": "01:23:45:67:89:AB",
"channel": 3,
"mac": "AA:BB:CC:DD:EE:FF",
"rssi": -65
},
"env": {
"t": 22.91447,
"h": 32.31556
}
}
The door can be unlocked by the inline keyboard option or the by the /unlock command. The Node.js Telegram bot then picks this command up from the Telegram servers and relays a JSON message back to the controller, unlocking the door for 3 seconds:
{
"action": "unlock",
"duration": 3000
}
Other Things
There is also an auto-unlock feature, which automatically unlocks the door if the buzzer is pressed within 5 minutes. This feature is very convenient when I’m carrying a lot of shopping and don’t want to bother finding my keys. Additionally, the ESP hosts a local web server, allowing me to control the door lock without the need for Node.js and Telegram, making it even more convenient. The web server also allows for easy firmware updates, enabling remote maintenance and upgrades of the door lock.
So, why not let the Telegram bot run directly on ESP? Unfortunately, this would require each device to have its own bot account, and each device would constantly poll the Telegram server for new messages, resulting in unnecessary complexity and resource waste. When Telegram initiates a new message connection, WebHooks can be used, but they only support 4 target ports, so there can be at most 4 bots behind a home router/NAT.
Perhaps I can add some voice recognition functionality using Raspberry Pi to create a more intelligent home automation system.
Schematics, firmware and everything can be found on my GitHub.