This project uses a NodeMCU ESP8266 and Apple HomeKit to control an electric blind.
The objective of this project is to control an electric blind through HomeKit, but also keeping the manual use of the blind with its old switch. All this with the lowest possible budget.
The components used were:
- Nodemcu Wifi Esp8266 Board.
- 2 Channel Relay Module (Songle).
- AC (220v) to 5v Power Supply.
- Famale-Famale cables and 1mm cables for the electric connections.
The next diagram shows the electric connections:
The logic pins used on the NodeMCU ESP8266 were:
- D1 (GPIO5) working as OUTPUT and used to activate/desactivate the relay so that the blind goes down.
- D2 (GPIO4) working as OUTPUT and used to activate/desactivate the relay so that the blind goes up.
- D6 (GPIO12) working as INPUT_PULLUP and used to know when the physical switch is pulled down.
- D7 (GPIO13) working as INPUT_PULLUP and used to know when the physical switch is pulled up.
- Download and install the CH340 driver required for the computer to recognize the board in Windows 10/11.
- Download and install the Arduino IDE.
- Add the ESP8266 to the IDE Boards Manager, in Preferences/Additional-Boards-Manager-URLs. Pasting this link there: http://arduino.esp8266.com/stable/package_esp8266com_index.json.
- Download the ESP8266 from the IDE Boards Manager, in Tools/Board/Boards-Manager searching for ESP8266 and instaling the last version.
- Download the Library Arduino-HomeKit-ESP8266, and install it from the IDE in Sketch/IncludeLibrary selecting the .zip of the downloaded repository. For an explanation of why the fork is used go to the section: Clarification.
- Inside the file wifi_info.h change the variable ssid for the name of your WiFi and the variable password for your WiFi password.
- Modify the
Serial.begin(9600)
inside the file automatic_blinds.ino with the BPS that your device uses, in the case of the NodeMCU ESP8266 this is written on the back of the board. - It may be necessary to invert the signals sent to the relays for their correct operation, in my case the relay is activated by sending a LOW signal, with other relays it can be the other way around. If necessary, the functions that interact with the motor should be modified, such as
blind_motor_off()
inside automatic_blinds.ino.
- CPU Frequency: 160MHz (Must)
- Board/Module: Generic ESP8266 Module
- Erase Flash: Only Sketch (ideally select All Flash Contents when uploading the code for the first time)
- SSL Support: Basic SSL ciphers (lower ROM use)
blind_usage.mp4
A fork of the original library Arduino-HomeKit-ESP8266 is used, since with the changes proposed in #212 and coupled with this other change #2, it is working as intended.
If in the future they update the original repository, which for now seems deprecated, this no longer matters. As of today 7/26/2023 without these changes it does not work.