[OBSOLETE] Absolute Simplest ESP8266 Smart Blinds, no mqtt, rest, bridge, or broker, just your board and your hub

As I said on the other thread that you posted on, you need to use v2.2 of the ESP8266 library to get it to work properly. You use whatever pin you specify in your sketch.

Forgive me if I missed something, but I’m having trouble figuring out the last step: configuring the device parameters in ST. I have everything else working and can navigate and trigger the device via browser.

Is there a guide I missed that explains what to enter for DeviceBodyText, DevicePath, and DevicePostGet?

Name Type Value
DeviceBodyText string GateTrigger=
DeviceIP string 192.168.1.170
DevicePath string 192.168.1.127
DevicePort string 80
DevicePostGet enum GET
HTTPAuth bool false
HTTPPassword string
HTTPUser string
UseJSON bool true

Do you have the DTH installed using the ST IDE? You then have to create a new device using that DTH.

Yes I do.

Blinds Device Blinds
Name Blinds
Label Blinds
Type Generic HTTP Device - ESP8266 - Blinds
Version Self-Published
Device Network Id 192.198.1.25
Status ACTIVE
Hub Home Hub
Last Activity At 2018-05-26 3:14 AM CDT
Date Created 2018-05-26 3:14 AM CDT
Last Updated 2018-05-26 3:24 AM CDT
Data No data found for device
Current States No states found
Preferences (edit)
Name Type Value
DeviceBodyText string GateTrigger=
DeviceIP string 192.168.1.170
DevicePath string
DevicePort string 80
DevicePostGet enum GET
HTTPAuth bool false
HTTPPassword string
HTTPUser string
UseJSON bool false
Execution Location Cloud

#1. If you’ve published the DTH, it would be “published” not self published.
#2 The network ID should just be numbers.
#3 you’re not assigned the DTH. It should be just esp8266 blinds, don’t know where the generic HTTP device game from.
#4 go into the ST app, open the blinds device and hit the cog wheel to go into settings.

You really need to read up on the basics a little more befor trying something so complicated. You don’t know the basics yet.

definition (name: "Generic HTTP Device - ESP8266 - Blinds", author: "hobbzey", namespace:"hobbzey") {

Type Generic HTTP Device - ESP8266 - Blinds

Is that the one I need to use?

Now have my bored talking to SmartThings and controlling a servo.
But now every time it check for an update from SmartThings it turns the servo.
Can anyone look at the code and help me figure this out?

//******************************************************************************************
//  File: ST_Anything_Multiples_ESP8266WiFi.ino
//  Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son)
//
//  Summary:  This Arduino Sketch, along with the ST_Anything library and the revised SmartThings 
//            library, demonstrates the ability of one NodeMCU ESP8266 to 
//            implement a multi input/output custom device for integration into SmartThings.
//            The ST_Anything library takes care of all of the work to schedule device updates
//            as well as all communications with the NodeMCU ESP8266's WiFi.
//
//            ST_Anything_Multiples implements the following ST Capabilities as a demo of what is possible with a single NodeMCU ESP8266
//              - 1 x Alarm device (using a simple digital output)
//              - 1 x Contact Sensor devices (used to monitor magnetic door sensors)
//              - 1 x Switch devices (used to turn on a digital output (e.g. LED, relay, etc...)
//              - 1 x Motion devices (used to detect motion)
//              - 1 x Smoke Detector devices (using simple digital input)
//              - 1 x Temperature Measurement devices (Temperature from Dallas Semi 1-Wire DS18B20 device)
//              - 1 x Relay Switch devices (used to turn on a digital output for a set number of cycles And On/Off times (e.g.relay, etc...))
//              - 2 x Button devices (sends "pushed" if held for less than 1 second, else sends "held"
//              - 1 x Water Sensor devices (using the 1 analog input pin to measure voltage from a water detector board)
//    
//  Change History:
//
//    Date        Who            What
//    ----        ---            ----
//    2015-01-03  Dan & Daniel   Original Creation
//    2017-02-12  Dan Ogorchock  Revised to use the new SMartThings v2.0 library
//    2017-04-17  Dan Ogorchock  New example showing use of Multiple device of same ST Capability
//                               used with new Parent/Child Device Handlers (i.e. Composite DH)
//    2017-05-25  Dan Ogorchock  Revised example sketch, taking into account limitations of NodeMCU GPIO pins
//    2018-02-09  Dan Ogorchock  Added support for Hubitat Elevation Hub
//
//******************************************************************************************
//******************************************************************************************
// SmartThings Library for ESP8266WiFi
//******************************************************************************************
#include <SmartThingsESP8266WiFi.h>

//******************************************************************************************
// ST_Anything Library 
//******************************************************************************************
#include <Constants.h>       //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library
#include <Device.h>          //Generic Device Class, inherited by Sensor and Executor classes
#include <Sensor.h>          //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...)
#include <Executor.h>        //Generic Executor Class, typically receives data from ST Cloud (e.g. Switch)
#include <InterruptSensor.h> //Generic Interrupt "Sensor" Class, waits for change of state on digital input 
#include <PollingSensor.h>   //Generic Polling "Sensor" Class, polls Arduino pins periodically
#include <Everything.h>      //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications

#include <PS_TemperatureHumidity.h>  //Implements a Polling Sensor (PS) to measure Temperature and Humidity via DHT library
#include <EX_Switch.h>       //Implements an Executor (EX) via a digital output to a relay
#include <Servo.h>

//*************************************************************************************************
//NodeMCU v1.0 ESP8266-12e Pin Definitions (makes it much easier as these match the board markings)
//*************************************************************************************************
//#define LED_BUILTIN 16
//#define BUILTIN_LED 16
//
//#define D0 16  //no internal pullup resistor
//#define D1  5
//#define D2  4
//#define D3  0  //must not be pulled low during power on/reset, toggles value during boot
//#define D4  5  //must not be pulled low during power on/reset, toggles value during boot
//#define D5 14
//#define D6 12
//#define D7 13
//#define D8 15  //must not be pulled high during power on/reset

//******************************************************************************************
//Define which Arduino Pins will be used for each device
//******************************************************************************************
#define PIN_SWITCH_1              05  //SmartThings Capability "Switch"
Servo myservo;

//******************************************************************************************
//ESP8266 WiFi Information
//******************************************************************************************
String str_ssid     = " ";                           //  <---You must edit this line!
String str_password = " ";                   //  <---You must edit this line!
IPAddress ip(192, 168, 1, 170);       //Device IP Address       //  <---You must edit this line!
IPAddress gateway(192, 168, 1, 1);    //Router gateway          //  <---You must edit this line!
IPAddress subnet(255, 255, 255, 0);   //LAN subnet mask         //  <---You must edit this line!
IPAddress dnsserver(192, 168, 1, 1);  //DNS server              //  <---You must edit this line!
const unsigned int serverPort = 8090; // port to run the http server on

// Smartthings / Hubitat Hub TCP/IP Address
IPAddress hubIp(192, 168, 1, 127);    // smartthings/hubitat hub ip //  <---You must edit this line!

// SmartThings / Hubitat Hub TCP/IP Address: UNCOMMENT line that corresponds to your hub, COMMENT the other
const unsigned int hubPort = 39500;   // smartthings hub port
//const unsigned int hubPort = 39501;   // hubitat hub port

//******************************************************************************************
//st::Everything::callOnMsgSend() optional callback routine.  This is a sniffer to monitor 
//    data being sent to ST.  This allows a user to act on data changes locally within the 
//    Arduino sktech.
//******************************************************************************************
void callback(const String &msg)
{
  //myservo.attach(PIN_SWITCH_1);  //D4
  //myservo.write(180);
  //delay(2000);
  //myservo.write(0);
  //delay(2000);
PIN_SWITCH_1 = digitalRead(PIN_SWITCH_1);

if(PIN_SWITCH_1 == LOW && setting <= 180 && direction == 0){
  setting++;
  delay(0);
  if(setting == 180){
    direction = 1;
    }
  }
  
if(buttonState == LOW && setting >= 0 && direction == 1){
  setting--;
  delay(0);
  if(setting == 0){
    direction = 0;
    }
  }

if(position < setting){
   servoA.attach(servoPin);
   servoA.write(position++);
   delay(5);
     Serial.print("Setting: ");  
     Serial.println(setting);
     Serial.print("Position: ");
     Serial.println(position);
   }
   
if(position > setting){
   servoA.attach(servoPin);
   servoA.write(position--);
   delay(5);
     Serial.print("Setting: ");  
     Serial.println(setting);
     Serial.print("Position: ");
     Serial.println(position);
   }

if(position == setting){
  servoA.detach();
  }
}
  
//  Serial.print(F("ST_Anything Callback: Sniffed data = "));
//  Serial.println(msg);
  
  //TODO:  Add local logic here to take action when a device's value/state is changed
  
  //Masquerade as the ThingShield to send data to the Arduino, as if from the ST Cloud (uncomment and edit following line)
  //st::receiveSmartString("Put your command here!");  //use same strings that the Device Handler would send
}

//******************************************************************************************
//Arduino Setup() routine
//******************************************************************************************
void setup()
{
  //******************************************************************************************
  //Declare each Device that is attached to the Arduino
  //  Notes: - For each device, there is typically a corresponding "tile" defined in your 
  //           SmartThings Device Hanlder Groovy code, except when using new COMPOSITE Device Handler
  //         - For details on each device's constructor arguments below, please refer to the 
  //           corresponding header (.h) and program (.cpp) files.
  //         - The name assigned to each device (1st argument below) must match the Groovy
  //           Device Handler names.  (Note: "temphumid" below is the exception to this rule
  //           as the DHT sensors produce both "temperature" and "humidity".  Data from that
  //           particular sensor is sent to the ST Hub in two separate updates, one for 
  //           "temperature" and one for "humidity")
  //         - The new Composite Device Handler is comprised of a Parent DH and various Child
  //           DH's.  The names used below MUST not be changed for the Automatic Creation of
  //           child devices to work properly.  Simply increment the number by +1 for each duplicate
  //           device (e.g. contact1, contact2, contact3, etc...)  You can rename the Child Devices
  //           to match your specific use case in the ST Phone Application.
  //******************************************************************************************
  //Polling Sensors
  //static st::PS_DS18B20_Temperature sensor2(F("temperature1"), 15, 0, PIN_TEMPERATURE_1, false, 10, 1); 
    
  //Executors
  //static st::EX_Alarm executor1(F("alarm1"), PIN_ALARM_1, LOW, true);
  static st::EX_Switch executor2(F("switch1"), PIN_SWITCH_1, LOW, true);  //Inverted logic for "Active Low" Relay Board
  
  //*****************************************************************************
  //  Configure debug print output from each main class 
  //  -Note: Set these to "false" if using Hardware Serial on pins 0 & 1
  //         to prevent communication conflicts with the ST Shield communications
  //*****************************************************************************
  st::Everything::debug=true;
  st::Executor::debug=true;
  st::Device::debug=true;
  st::PollingSensor::debug=true;
  st::InterruptSensor::debug=true;

  //*****************************************************************************
  //Initialize the "Everything" Class
  //*****************************************************************************

  //Initialize the optional local callback routine (safe to comment out if not desired)
  st::Everything::callOnMsgSend = callback;
  
  //Create the SmartThings ESP8266WiFi Communications Object
    //STATIC IP Assignment - Recommended
    st::Everything::SmartThing = new st::SmartThingsESP8266WiFi(str_ssid, str_password, ip, gateway, subnet, dnsserver, serverPort, hubIp, hubPort, st::receiveSmartString);
 
    //DHCP IP Assigment - Must set your router's DHCP server to provice a static IP address for this device's MAC address
    //st::Everything::SmartThing = new st::SmartThingsESP8266WiFi(str_ssid, str_password, serverPort, hubIp, hubPort, st::receiveSmartString);

  //Run the Everything class' init() routine which establishes WiFi communications with SmartThings Hub
  st::Everything::init();
  
  //*****************************************************************************
  //Add each sensor to the "Everything" Class
  //*****************************************************************************
  //st::Everything::addSensor(&sensor1);  
  //st::Everything::addSensor(&sensor8);  
      
  //*****************************************************************************
  //Add each executor to the "Everything" Class
  //*****************************************************************************
  st::Everything::addExecutor(&executor2);
    
  //*****************************************************************************
  //Initialize each of the devices which were added to the Everything Class
  //*****************************************************************************
  st::Everything::initDevices();
  
}

//******************************************************************************************
//Arduino Loop() routine
//******************************************************************************************
void loop()
{
  //*****************************************************************************
  //Execute the Everything run method which takes care of "Everything"
  //*****************************************************************************
  
  st::Everything::run();
}

The code posted in the original post works. use that.

Hi @C_Hobbs. Is this project still valid and workable ?? I am really interested in automating my blinds and I found this a very good option.

I’m still using it today. Had them for months and still going strong.

great news !! I have really quickly gone through the posts but I did not find how the servo motor is attached to the blinds shafts/tube. Is there any documentation or picture related?

Sorry, the one I’m using is this:

But there is a link in the first post here of the coupler he used.

Great, thanks !! Will the servo motor be able to carry and work with roller shadows like the ones in my picture? because in the youtube video I saw it was working with different type that what I had in mind

image

No, these are for blinds, not shades. For shades you need a continuous motor not a servo.

Ok then I will continue searching a post/development for shades. Thanks

Yes this project still works, and in my opinion is still the easiest way to do smartblinds.
But as for myself, I have moved my installations to the solar powered version @blebson built based on this, which can be found here. I’ve been using his version in my house for almost a year now, with just the solar panels for power, and they’ve been absolutely rock solid!

thanks. Is there a way your development could be used/adapted to be used with a continuous motor ?? Ryan mentioned in a post before that is what I would need instead of a servo motor for my shades (which is what I actually have and not blinds)

It technically could, technically lol, but I wouldn’t trust it…
Basically instead of sending the servo the number of degrees of rotation as it does now, you’d switch it to time of rotation, like for example spin clockwise (down) for 15 seconds, or counter clockwise for 10…

Not to mention you’d need a hefty servo to pull up all of the weight of the blinds on the “open” actuation. As it is now the servo just tilts the horizontal blades.

But the real problem is that using simple timers isn’t precise and the controller has no way of knowing the “true” position of the blinds…

ok I will navigate the web to explore some other options then… thanks

I am trying to gather the supplies to make your project. I like the simplicity of your project. Do you think I can use the MG996 that jetpuf used along with a shaft coupler? The MG996 motor seems to be much cheaper (I want to modify multiple blinds so the costs will add up). I don’t have access to a 3D printer and don’t know how to modify the 3d designs to fit my blinds (even if I did) so I would like to use the MG996 like jetpuf did but use the shaft coupler approach like you did. Thoughts?