How to connect an emlux curtain motor with a smart hardware module
We want to use the emlux curtain motor, but we have our own independent operating app. How can we get our program to run on your curtain motor?
The emlux curtain motor has a standard asynchronous serial communication interface (UART) for smart home devices. The RX, TX, GND, and 3.3V pins allow communication with your smart hardware module.
Below, I'll explain in detail how to use this interface, including the communication principles, steps, sample code, and precautions.
TX -> RX: Connect the TX pin of your smart hardware module to the RX pin of the curtain motor. (The smart hardware sends data to the motor.)
RX -> TX: Connect the RX pin of your smart hardware module to the TX pin of the curtain motor. (The smart hardware receives data from the motor.)
GND -> GND: Required to provide a common voltage reference for communication.
3.3V: This is typically an output pin, meaning the curtain motor can provide 3.3V power to your external smart module. (Important: Before use, you must confirm whether the current output capability of this pin meets the requirements of your smart module.)
II. Interconnection Steps
1. Obtaining the Communication Protocol
This is the most critical step. You need to contact EMLUX to request the "Serial Port Communication Protocol" or "Secondary Development Protocol" document. You can also download this document from our official website. This document is in Chinese and can be translated using Google Translate.
This document will clearly specify:
Baud Rate: For example, 9600, 115200, etc. Both communicating parties must set the same baud rate.
Data Bits: For example, 8 bits.
Stop Bits: For example, 1 bit.
Parity: For example, none.
Packet Format: How the command is structured. Common formats include:
[Header][Command Code][Data Length][Data Content][Checksum][Trailer]
Header/Trailer: Identify the beginning and end of a data packet, commonly using 0xAA, 0x55, 0xFE, etc.
Command Code: Distinguishes different functions, such as 0x01 for "Open" and 0x02 for "Stop."
Data Content: Optional parameters, such as operating speed and target position percentage.
Checksum: Used to verify that data transmission was error-free. A simple method is to add all the previous bytes and take the lower 8 bits.
Let's assume we have a simplest virtual protocol:
Baud rate: 9600
Data format: 8-N-1 (8-bit data, no parity, 1 stop bit)
Command format: 0xFE + [command code] + 0xFF
Command code:
0x01 -> Open curtains
0x02 -> Close curtains
0x00 -> Stop
0x03 -> Query status (the motor may return 0x01 [Open] or 0x02 [Off])
2. Hardware Connection
Curtain Motor Interface
Smart Hardware Module (such as ESP32/ESP8266/Arduino)
Wire Color Recommendations
RX TX (e.g., GPIO17) Green
TX RX (e.g., GPIO16) Blue
GND GND Black
3.3V (Use with caution, not recommended) Red
Note: The above wire colors are for debugging purposes only. For mass production, the smart hardware module will need to be attached to the adapter board and soldered to the curtain motor motherboard.
3. Software Programming (Using Arduino/ESP32 as an Example)
Write the control code based on the assumed protocol.
// Assuming ESP32's Serial2 is used for connection
// Curtain motor TX -> GPIO16 (ESP32's RX2)
// Curtain motor RX -> GPIO17 (ESP32's TX2)
#define MOTOR_SERIAL Serial2
void setup() {
// Start the serial port for debugging (connect to a computer)
Serial.begin(115200);
// Start the serial port for communication with the curtain motor, parameters: baud rate, configuration mode (usually SERIAL_8N1 represents 8 data bits, no parity, 1 stop bit)
MOTOR_SERIAL.begin(9600, SERIAL_8N1, 16, 17); // (RX pin, TX pin)
Serial.println("Init Done");
}
void loop() {
// Example: Loop through the cycle Open -> Stop -> Close every 5 seconds
openCurtain();
delay(5000);
stopCurtain();
delay(2000);
closeCurtain();
delay(5000);
}
// Function for sending commands
void sendCommand(byte cmd) {
byte commandPacket[] = {0xFE, cmd, 0xFF}; // Compose data packets according to the protocol
MOTOR_SERIAL.write(commandPacket, sizeof(commandPacket));
Serial.printf("Command 0x%02X Sent.\n", cmd);
}
void openCurtain() {
Serial.println("Sending OPEN command...");
sendCommand(0x01);
}
void closeCurtain() {
Serial.println("Sending CLOSE command...");
sendCommand(0x02);
}
void stopCurtain() {
Serial.println("Sending STOP command...");
sendCommand(0x00);
}
// If you need the receiving status, you can continuously read it in the loop.
void checkSerial() {
if (MOTOR_SERIAL.available()) {
byte incomingByte = MOTOR_SERIAL.read();
Serial.print("Received: 0x");
Serial.println(incomingByte, HEX);
// You can add code to parse the returned data here.
}
}
III. Smart Hardware Module Selection and Advanced Applications
WiFi Module (such as ESP32/ESP8266):
Advantages: Can connect directly to home WiFi and integrate with platforms such as Home Assistant, HomeKit, Tmall Genie, and Google Home via MQTT or HTTP protocols, enabling mobile app and voice control.
Implementation: Write code on the ESP32 to create a web server or MQTT client to receive network commands and forward them to the curtain motor via the serial port.
Bluetooth Module (such as ESP32, HC-05):
Advantages: Allows direct Bluetooth control via a mobile phone, and consumes relatively low power.
Implementation: Utilizes the ESP32's Bluetooth serial port, allowing a mobile app to send commands to the ESP32, which then controls the motor via the serial port.
Zigbee/Thread Module:
Advantages: Low power consumption, high stability, and the ability to build large-scale mesh networks. Suitable for integration into ecosystems such as Apple HomeKit over Thread, Xiaomi Multi-Mode hub、matter hub, and Home Assistant Zigbee.
Implementation: Typically requires selecting a Zigbee-supported module (such as the CC2652P) and writing the corresponding firmware. This can be challenging to develop, but once integrated into the ecosystem, it is very stable.
IV. Precautions and Safety
1. Voltage Matching: Ensure your smart module operates at 3.3V TTL voltage. Most modern microcontrollers (ESP32, ESP8266, Raspberry Pi Pico) operate at 3.3V and can be connected directly. Direct connection to 5V TTL voltage levels (such as certain pins on the Arduino Uno) is strictly prohibited, as this will damage the curtain motor.
2. Protocol Verification: Be sure to obtain the official protocol documentation. Guessing the protocol may result in failure or even damage the device.
3. Anti-static Protection: During wiring and debugging, pay attention to static protection and avoid touching exposed pins.
4. Debug Before Assembly: It is recommended to connect all components first and test communication before installing them in their final location, such as the curtain box.
In summary, you have tremendous flexibility. Through this serial port, you can connect the curtain motor to nearly any smart home platform you like, creating highly customized automation scenarios (e.g., "open the living room curtains at sunrise" or "close all curtains when you leave home"). I wish you success with your project!
The above products have no MQQ order quantity requirements and are suitable for buyers who have technology, their own hardware modules and need fast customization.
