How to Connect Your Somfy Remote to Alexa With an ESP8266 to Control Your Motorized Blinds

13,242

10

30

As a home automation enthusiast, I wanted to find a way to use Alexa to open and close my motorized blinds. I looked on line to purchase a solution, but found that the offerings were expensive and had somewhat bad reviews. Not wanting to put out the money for a marginal solution, I started exploring options for connecting my existing remote to Alexa. I found several good resources, including some instructables, but no single step by step guide. Hopefully, you will find this instructable clear and easy to follow with most of the resources you need.

In this instructable, I show you how to control one channel of your remote and you can make one or multiple blinds go up and down in a group. Later I will provide an update for individually controlling multiple blinds.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Pull All the Pieces Together

Here is the list of hardware and software you will need and where to find it:

  • Somfy remote, if you don't want to use your current one - Found here on Amazon
  • ESP8266. I used this one Found here on Amazon .
  • I assume you have some experience with Arduino and the Arduino IDE. If not you can download the Arduino IDE - Found here. If you are not familiar with the Arduino IDE, instructions and tutorials can be found on the same web site.
  • Install the Fauxmo and ESP WIFI librarys - Adafruit has a nice tutorial on loading the libraries and some great ESP8266 devices found here.

Step 2: Set Up the ESP8266 With the Arduino IDE

Connect the ESP8266 to your computer with the appropriate USB cable. Bring up the Arduino IDE.

Under file/preferences add "http://arduino.esp8266.com/stable/package_esp8266com_index.json" in the Additional Boards Manager URLs: box. As shown in the 1st screen capture.

In the Arduino IDE, under "tools" select the board you are using. If you have a NodeMCU based board like mine, select NodeMCU as shown in the 2nd screen capture. Afterward your tools sub menu should look like the last screen capture.

Load this code to the ESP8266, and remember to change "your SSID" and "your Password" for your router.

/*****************************************************************************************
** ** ESP8266WiFi functions to connect Window Shades to Alexa ** code modified from Adafruit website code based on fauxmo library ** Setup registers the device and in ISR routine call back returns state change for the device. ** ***********************************************************************************************/

#include <Arduino.h> #include <ESP8266WiFi.h> #include "fauxmoESP.h"

#define WIFI_SSID "Your SSID" #define WIFI_PASS "Your Password" #define SERIAL_BAUDRATE 115200 /*************************************************************************** ** NOTE: D1 through D10 are ESP defines that map the ESP GPIO pins to the ** correct pin noted on the ESP8266. Use these defines to map to the correct number ** you see on the package. *************************************************************************************/ #define DOWN D1 #define UP D2

fauxmoESP fauxmo;

// ----------------------------------------------------------------------------- // Wifi // -----------------------------------------------------------------------------

void wifiSetup() {

// Set WIFI module to STA mode WiFi.mode(WIFI_STA);

// Connect Serial.printf("[WIFI] Connecting to %s ", WIFI_SSID); WiFi.begin(WIFI_SSID, WIFI_PASS); // Wait while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(100); } Serial.println();

// Connected! Serial.printf("[WIFI] STATION Mode, SSID: %s, IP address: %s\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str()); } struct State // Struct to keep current state of device { bool state = 0; const char *device_name; uint8_t device_id; } Curstate;

void callback(uint8_t device_id, const char * device_name, bool state) { if (state == Curstate.state) return; Curstate.device_name = device_name; Curstate.state= state; Curstate.device_id = device_id; }

void setup() { // Init serial port and clean garbage Serial.begin(SERIAL_BAUDRATE); Serial.println("Alexa/ESP demo sketch"); Serial.println("After connection, ask Alexa/Echo to 'turn on' or 'off'");

// Wifi wifiSetup();

// Add device fauxmo.addDevice("Shades"); // One or all blinds - work on multiple individual shades later Serial.println();

fauxmo.onMessage(callback);

pinMode(DOWN,OUTPUT); pinMode(UP,OUTPUT); digitalWrite(DOWN,HIGH); // Set UP and DOWN HIGH so the remote doesn't activate on start up digitalWrite(UP,HIGH);

}

void loop() { static bool state; fauxmo.handle(); if (state != Curstate.state) { state = Curstate.state; if (Curstate.state) { Serial.println("ON/DOWN"); digitalWrite(DOWN,LOW); delay(5000); digitalWrite(DOWN, HIGH); } else { Serial.println("OFF/UP"); digitalWrite(UP,LOW); delay(5000); digitalWrite(UP, HIGH); } } }

Step 3: Register Shades With the Alexa App

After your ESP8266 connects to your WIFI, go to the Alexa app and select "Smart Home".

Under "Your Devices" click on "Discover Devices". This should find your new device called "Shades". I used "Shades" instead of "Blinds" because Alexa seemed to occasionally confuse "blinds" with "lights".

Tell Alexa to "turn the shades off" and you should get "OFF/UP" on the Arduino serial monitor. "turn the shades on" should give you "ON/DOWN" on the serial monitor.

The ESP8266 is a little finicky and may take some time to connect. It's mostly reliable, but occasionally misses a command. Not sure if this is the ESP itself, or some of the libraries used.

Step 4: Program Your Somfy Remote

Check out these informational video's from Somfy on programming your duplicate remote:

This will allow you to copy and paste the programming from your current remote to a new duplicate remote.

Step 5: Connect ESP8266 to Somfy Remote

After programming the remote, open the case and pull the circuit board out. Remove the coin battery.

I've seen others connect the remote to the ESP8266 using relays, but if you power the remote from the 3.3v pin on the ESP8266 you can use the digital pins to simulate a button press by pulling the correct side of the button to ground.

Solder each connection as shown in the picture. 3.3v and ground from the ESP8266 to replace power from the coin battery and D1 and D2 to Down and Up respectively.

Be sure to set the correct channel for the blinds you want to control.

Step 6: Package in Project Box

Pick up a small project box like this one from Amazon. You may need to drill a small hole in one side and install USB power connector. Place the box within range of your blinds (mine seems to work at least 50 feet away).

If you try this instructable and have any issues, let me know and I'll update it. In the future I plan to update it with control for multiple individual blinds.

I changed my Alexa to respond the wake word "computer". I wanted to change the name of the shades to "Shields" so I could yell "Computer - Shields on!", but my wife didn't like it. Oh well.

Hope this helps.

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    30 Discussions

    None
    bobby7897877

    Question 4 months ago on Introduction

    Hello again,

    In you writeup you indicate that you would post instructions for selecting other channels on the multichannel remote. Were you ever able to include that?

    None
    bobby7897877

    Question 4 months ago on Step 6

    Hello,
    It looks like you are not using the "MY"button of the somfy remote to move the blinds to a preset position. I guess you could use another output on the ESP8266 to control the MY button. Have you done this already?

    None
    MelanieB112

    Question 9 months ago

    Hi I have got a J4 IO Frequency 868 MHz Blinds and also an Sunea io ..could you build me a box to control them . I will pay you ofcourse to do all the work and materials. contact me via email josef.p at hotmail.co.uk Thank you Location Europe

    None
    Tich1njreid

    Reply 1 year ago

    njreid - I'm having issues connecting the ESP8266 with Alexia (Echo Gen 2), would appreciate if you can share a copy of your configuration please.

    Thanks!

    None
    njreidTich1

    Reply 1 year ago

    Hi Tich1 - I wasn't able to get the Fauxmo library approach to work, so I adapted another bit of sample code I found.

    #include <ESP8266WiFi.h>

    #include <ESP8266WebServer.h>

    #include <WiFiUdp.h>

    #include <functional>

    #include "switch.h"

    #include "UpnpBroadcastResponder.h"

    #include "CallbackFunction.h"

    // prototypes

    boolean connectWifi();

    //on/off callbacks

    bool loungeShadesUp();

    bool loungeShadesDown();

    bool kitchenLightsOn();

    bool kitchenLightsOff();

    // Change this before you flash

    const char* ssid = "YOUR_WIFI_SSID";

    const char* password = "YOUR_WIFI_PASSWORD";

    boolean wifiConnected = false;

    UpnpBroadcastResponder upnpBroadcastResponder;

    #define UP D1

    #define DOWN D2

    Switch *lounge = NULL;

    Switch *kitchen = NULL;

    bool isloungeShadesUp = false;

    void setup()

    {

    Serial.begin(9600);

    // Setup the control pins

    pinMode(DOWN, OUTPUT);

    pinMode(UP, OUTPUT);

    digitalWrite(DOWN, HIGH); // Set UP and DOWN HIGH so the remote doesn't activate on start up

    digitalWrite(UP, HIGH);

    // Initialise wifi connection

    wifiConnected = connectWifi();

    if (wifiConnected) {

    upnpBroadcastResponder.beginUdpMulticast();

    // Define your switches here. Max 10

    // Format: Alexa invocation name, local port no, on callback, off callback

    lounge = new Switch("Lounge Shades", 80, loungeShadesUp, loungeShadesDown);

    Serial.println("Adding switches upnp broadcast responder");

    upnpBroadcastResponder.addDevice(*lounge);

    //upnpBroadcastResponder.addDevice(*kitchen);

    }

    }

    void loop()

    {

    if (wifiConnected) {

    upnpBroadcastResponder.serverLoop();

    //kitchen->serverLoop();

    lounge->serverLoop();

    }

    }

    bool loungeShadesUp() {

    Serial.print("Opening shades... ");

    digitalWrite(UP, LOW);

    delay(5000);

    digitalWrite(UP, HIGH);

    Serial.println("OK");

    isloungeShadesUp = true;

    return isloungeShadesUp;

    }

    bool loungeShadesDown() {

    Serial.print("Closing shades... ");

    digitalWrite(DOWN, LOW);

    delay(5000);

    digitalWrite(DOWN, HIGH);

    Serial.println("OK");

    isloungeShadesUp = false;

    return isloungeShadesUp;

    }

    // connect to wifi – returns true if successful or false if not

    boolean connectWifi() {

    boolean state = true;

    int i = 0;

    WiFi.mode(WIFI_STA);

    WiFi.begin(ssid, password);

    Serial.println("");

    Serial.println("Connecting to WiFi");

    // Wait for connection

    Serial.print("Connecting ...");

    while (WiFi.status() != WL_CONNECTED) {

    delay(500);

    Serial.print(".");

    if (i > 10) {

    state = false;

    break;

    }

    i++;

    }

    if (state) {

    Serial.println("");

    Serial.print("Connected to ");

    Serial.println(ssid);

    Serial.print("IP address: ");

    Serial.println(WiFi.localIP());

    }

    else {

    Serial.println("");

    Serial.println("Connection failed.");

    }

    return state;

    }

    None
    KaiM25njreid

    Reply 1 year ago

    Hi there ...

    but where can i find the

    #include "switch.h" Libary?

    Thanks for help.

    None
    Tich1njreid

    Reply 1 year ago

    Appreciate the reply and configuration file, I managed to get the original file to work with my 'Echo Dot 2', I uninstalled the 'ESP8266' version 2.4.0 from 'Boards Manager', I then re-installed 'ESP8266' using version 2.3.0...after this did a discover and Alexa found the device first time! ;-)

    BManager.PNG
    None
    njreidnjreid

    Reply 1 year ago

    Thanks very much for your instructable.

    None
    Juan11perez

    2 years ago

    hi, thank you for sharing this. Have you looked at incorporating into Home Assistant?

    8 replies
    None
    JuanP228Jerryolsen

    Reply 2 years ago

    Jerry, wanted to let you know I followed your instructions and got it working perfectly. After finishing the whole thing I tried saying "alexa close curtains" just out of curiosity and Alexa opened the curtains; then I said "alexa open curtains" and Alexa closed the curtains....:-)

    Went back to your sketch, replaced all the UPs with Downs and vice-versa, re-flashed and Voila!....

    Now it works intuitively: "Alexa open curtains" and it opens. Alexa close and it closes.

    Once again thank you very much . Produced two Alexa-enabled Somfy ESP/remotes for under USD80!

    None
    JerryolsenJuanP228

    Reply 2 years ago

    Glad it worked for you. Thanks for the comments.

    None
    JuanP228Jerryolsen

    Reply 2 years ago

    Hi Jerry, update. I managed to produce a sketch using your sketch and other resources to control Somfy with Alexa and Home Assistant. Happy to share if of interest.

    None
    KaiM25JuanP228

    Reply 1 year ago

    Perhaps you can help me to connect the Somfy ESP8266 to my Homebridge or to a WebControl? That would be so great !

    None
    RodrigoL93JuanP228

    Reply 1 year ago

    Could you share this? I'd love to be able to connect directly to HASS.

    None
    abhaypawarJuanP228

    Reply 2 years ago

    Can you kindly share how you were able to connect the fauxmo esp to home assistant, I am tryign to do the same.

    Do share the steps and code too.