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

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

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.

Step 1: Pull All the Pieces Together

Picture of 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

Picture of 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

Picture of 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

Picture of 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.

Comments

cwca02 (author)2017-10-30

Hi Jerry, thanks so much for this. I did it and it works. You got me started, so thanks for that. In my case I also have an urtsi and a gc-100 so I modified a bit and am now doing it without the remote. You did however, open my eyes to a whole host of possibilities where I have remotes controlling things that I can't otherwise. Like my fireplace, which will be next.

One thing. I think I know why you are experiencing a bit of instability. It looks like you're using the test, if state=curstate.state to determine when to press a button. State can get out of sych with the actual state if someone raises or lowers the shades outside of this routine. I noticed this because my wife still uses the Somfy remote to close the shades at night. Then in the morning I'm asking Alexa to open them and she says Ok, but nothing happens. Then I ask her to lower them and then raise them (on and off) and finally it works. This is why:

So, say you put the shades down with Alexa. State would be 1. Now say you put them up with a remote. State is still 1 but the shades are up so you'd naturally ask Alexa to turn them on to put them down again. Only state is still 1 and Curstate.state is 1 so the if statement does not get invoked.

That's an issue I have anyway. Hope that helps.

Craig

If

Juan11perez (author)2017-07-09

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

Jerryolsen (author)Juan11perez2017-07-10

No, sorry. I use Smartthings with Alexa.

JuanP228 (author)Jerryolsen2017-07-23

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!

Jerryolsen (author)JuanP2282017-07-23

Glad it worked for you. Thanks for the comments.

JuanP228 (author)Jerryolsen2017-07-30

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.

abhaypawar (author)JuanP2282017-10-07

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.

Juan11perez (author)Jerryolsen2017-07-11

thank you

ChristianW98 (author)2017-09-14

Oh, this is very nice! Congrats :-)

Did you already manage to control multiple channels (multiple blinds)?

Thanks.

TomHoag (author)2017-03-24

Very nice! Thank you for this instructable!

About This Instructable

2,779views

8favorites

License:

Add instructable to: