WebSocket based version of motor-on-roller-blind. I.e. there is no need of an MQTT server but MQTT is supported as well - you can control it with WebSockets and/or with MQTT messages.
3d parts for printing are available on Thingiverse.com: "motor on a roller blind"
- A tiny webserver is setup on the esp8266 that will serve one page to the client
- Upon powering on the first time WIFI credentials, a hostname and - optional - MQTT server details is to be configured. You can specify if you want clockwise (CW) rotation to close the blind and you can also specify MQTT authentication if required. Connect your computer to a new WIFI hotspot named BlindsConnectAP. Password = nidayand
- Connect to your normal WIFI with your client and go to the IP address of the device - or if you have an mDNS supported device (e.g. iOS, OSX or have Bonjour installed) you can go to http://{hostname}.local. If you don't know the IP-address of the device check your router for the leases (or check the serial console in the Arduino IDE or check the
/raw/esp8266/register
MQTT message if you are using an MQTT server) - As the webpage is loaded it will connect through a websocket directly to the device to progress updates and to control the device. If any other client connects the updates will be in sync.
- Go to the Settings page to calibrate the motor with the start and end positions of the roller blind. Follow the instructions on the page
- When it connects to WIFI and MQTT it will send a "register" message to topic
/raw/esp8266/register
with a payload containing chip-id and IP-address - A message to
/raw/esp8266/[chip-id]/in
will steer the blind according to the "payload actions" below - Updates from the device will be sent to topic
/raw/esp8266/[chip-id]/out
Replace "[chipid]" with your chipid that you can find by subscribing to the topic "/raw/esp8266/#"
cover:
- platform: mqtt
name: "DIY Roller Shade"
command_topic: "/raw/esp8266/[chipid]/in"
set_position_topic: "/raw/esp8266/[chipid]/in"
position_topic: "/raw/esp8266/[chipid]/out"
value_template: "{{ value_json.position }}"
json_attributes_topic: "/raw/esp8266/[chipid]/out"
json_attributes_template: "{{ value_json.position | tojson }}"
retain: false
payload_open: "100"
payload_close: "0"
position_open: 100
position_closed: 0
Simply do not enter any string in the MQTT server form field upon WIFI configuration of the device (step 3 above)
(start)
- (calibrate) Sets the current position as top position(max)
- (calibrate) Sets the current position as max position. Setstart
before you definemax
asmax
is a relative position tostart
(0)
- (manual mode) Will stop the curtain(-1)
- (manual mode) Will open the curtain. Requires(0)
to stop the motor(1)
- (manual mode) Will close the curtain. Requires(0)
to stop the motor0-100
- (auto mode) A number between 0-100 to set % of opened blind. Requires calibration before use. E.g.50
will open it to 50%
For those who do not want to carry smartphone all the time, device supports manual operation using buttons - up and down. Additional reset button is added to clean configuration, device will be just like freshly flashed. Calibration using webpage is still needed though.
Buttons are active low using internal pullup resistors.
If you plan to use buttons very far from device please use external pullup resistors and INPUT
mode instead of INPUT_PULLUP
.
- Press and hold reset button
- Press and hold up and down buttons
- Hold for 5 seconds
- Release buttons and wait for device to reboot
NOTE: After flashing - remove power source, otherwise device will hang after reset. This is one-time-only issue so next resets will be done properly.
- Stepper_28BYJ_48: https://github.com/thomasfredericks/Stepper_28BYJ_48/
- PubSubClient: https://github.com/knolleary/pubsubclient/
- ArduinoJson v5: https://github.com/bblanchon/ArduinoJson
- WIFIManager: https://github.com/tzapu/WiFiManager
- WbSocketsServer: https://github.com/Links2004/arduinoWebSockets