Smart Door Control

To help our client automate livestock movement, we developed a fully integrated smart door system combining custom electronics, real-time control, and high-level software. The solution reduced cabling by 50%, simplified installation, and added intelligent features like access logging, camera surveillance, and sensor health monitoring. Built around a robust microcontroller and Raspberry Pi combo, the system ensures reliable operation—even without network connectivity—and is managed centrally via an intuitive Node-RED interface and database-backed backend.

Smart mechanical systems are defined by the tight integration of mechanics, electronics, and high-level software. Our customer faced the challenge of controlling livestock by restricting access to certain areas based on the time of day. Their solution was a remote-controlled door with database integration. They provided a fully functional mechanical prototype, while we developed the electronics and high-level software integration.

CAD design of PCB

Initially, we integrated all electronics onto a single PCB. External components—such as sensors and the motor controller—were connected via dedicated interfaces. We then developed firmware to handle time-critical door operations. Finally, we addressed full system integration, including camera surveillance and network connectivity. Time-sensitive tasks were managed by a microcontroller, while high-level functionality was delegated to a Raspberry Pi.

Safety and manual control were high priorities for our customer. Our design monitors system health by continuously measuring the current consumption of critical components. Additionally, manual override buttons were integrated into the design. While access schedules were managed via a central database, we enabled ad hoc changes through a Node-RED interface.

As our customer operated multiple doors on their property, we simplified management and maintenance by providing a central server for centralized access scheduling.

The initial challenge was to reduce setup complexity, which we addressed through a two-step approach. First, we designed dedicated interfaces for all sensors and the motor controller. These interfaces provided power and enabled reliable sensor readout. The motor controller was connected via its own hardware interface. This design reduced cabling by 50% and significantly simplified installation. To ensure proper EMI separation, all external signals were optically decoupled at their respective interfaces. Connections were implemented using Phoenix Contact terminal blocks, allowing easy plug-and-play integration for all external components.

While sensor and motor controller interfacing proved straightforward, power distribution required optimization. Together with the customer, we agreed on a single 24V power supply to power both the motor and all electronics. Our hardware design incorporated step-down converters to generate the required voltage domains. The power conversion circuitry was thoroughly tested using a dedicated prototype to validate stable operation under load and thermal stress.

The door control system was responsible for managing multiple real-time tasks. Beyond basic door motion control, it also had to detect and respond to animal passage with precise timing—ensuring that only one animal passed at a time, without startling livestock. All real-time logic was delegated to a Silicon Labs BG22EFR32 microcontroller. We selected the BGM220P module, which offers a robust design and integrated BLE functionality to support future wireless features.

Our design also included current monitoring for both sensors and the motor controller. This enabled detection of abnormal power consumption patterns, allowing us to predict potential sensor failures in advance. An early-warning notification system was integrated to prevent downtime and facilitate proactive maintenance. For manual overrides, we added local control buttons to the system.

At the system level, we chose a Raspberry Pi as the integration platform. This provided a cost-effective way to bridge low-level hardware control with high-level software capabilities, such as camera interfacing and network connectivity. The customer requested image capture of each animal passing through the gate. For this, we used a USB camera from ELF, which delivered fast and reliable snapshots.

Access scheduling was managed centrally via a Django-based application backed by a PostgreSQL database. The server was hosted on the customer’s premises and ran a stock Ubuntu distribution. It featured a RAID 1 dual-drive system to protect against data loss in the event of a hardware failure. To ensure continued operation during network outages, each door unit maintained a local database copy. At the customer’s request, we also developed a custom software mechanism to reconstruct the central access-time database from distributed logs stored at the individual doors.

Our door control unit removed two power supplies from the customer’s setup and reduced wiring by 50%. Furthermore, our design provided a tailored footprint, simplifying installation. This was achieved while meeting strict timing constraints and enabling smart features. External door sensors connect via optically decoupled inputs, ensuring system robustness in harsh EMI conditions. We tailored our motor interface to the customer’s preferred controller, enabling intuitive and easy installation. All external sensors are powered by our board, thereby allowing sensor health checks and reducing setup complexity. We integrated buck converters for generating all necessary power domains on-board.

Keeping maintenance in mind, we added on-board push buttons, thus enabling door control without a network connection or any smart features. Two switchable 24V, 200 mA fan outputs facilitate temperature control. Timing-critical operations are handled by a BG22EFR32 from Silicon Labs, while a Raspberry Pi manages smart features. This separation improves operational reliability by isolating physical controls from higher-level software layers. In the case of Raspberry Pi damage or network failure, the microcontroller ensures basic door operability.

Manufactured PCB as delivered to customer.

Integrated smart features include access control via a remote database, access logging, and camera surveillance. All features are customizable and controlled via an MQTT command set. A Node-RED user interface provides simple and intuitive handling.