Simple and reliable esp8266 nodeMCU smart garage door opener

I just completed a project to build a smartthings connected garage door opener and it’s working great!

My goal was to build something that was as simple as possible, and I ended up basing a lot of the code off of this [RELEASE] Absolute Simplest ESP8266 Smart Blinds, no mqtt, rest, bridge, or broker, just your board and your hub and just adapting it for a push button instead of an open/close action.

I used an esp8266 nodemcu with a 5v relay connected normally open directly to the terminals on the back of the garage door opener unit. Smartthings triggers the relay which completes the circuit, ‘pushing’ the garage door opener button.

The reason I wanted this was to be able to close my garage door remotely in case I left it open accidentally. I have a tilt sensor on the door already which alerts me if it’s left open for too long, but until now there was no way to operate the door without driving back home again.

If people are interested I can post the code later, I need to clean it up a bit first though.

0119181615

0119181615a

1 Like

I’m interested. I have two garage doors I need to integrate in to smartthings eventually.

Why did you go this route instead of using something like a go-control? Price?

I am also very interested. I have a couple esp8266 nodeMCU’s laying around to use. I currently have a RPI zero controlling my garage, but havent been able to get it working with Smartthings yet. This would solve my issue.

Definitely interested in this code. I’d rather use this solution than have to buy multiple Linear modules for my doors. We’re you still planning on sharing?

In this setup can you still use the button and remotes to open and close the door? Just asking in case WiFi goes down

I’m really interested in the code! Could you please share?? Thank you!!!

Hi @Todd_Meyer

Im interested as well. Please do share the code

If anyone would like to implement this functionality, you can do so very easily using my ST_Anything project. In addition to full support for the Garage Door Control, you can also easily add Temperature, Humidity, Illuminance, Motion, etc… all by simply editing one sketch. Check it out and feel free to post any questions you have in the thread below.

3 Likes

I can vouch for this. @ogiewon’s code has probably been running on my garage door for over a year at this point without any issues.

1 Like

You have to been an expert to use that code. Too complicated for beginners. I have been coding for about 5 years but understanding this without step by step instructions is impossible for newbies.

As the author of ST_Anything, I would prefer to say a user should have a basic understanding of Arduino programming and circuits.

My son and I wrote ST_Anything to drastically reduce the expertise required to utilize these inexpensive microcontrollers with SmartThings and Hubitat. The ReadMe is pretty detailed, with step by step instructions for getting started.

Well, I am an Electrical Engineer 16 years and now I teach High school engineering where I have been learning C++ for the past 3 years. I am not real strong in the C++ but electronics part is no problem. Sorry, I am not a dumb person and I can’t follow those instructions. Too many assumptions that I know things.


ogiewon
Dan
Community Master

    April 27

Bradley_Martin:
You have to been an expert to use that code.

As the author of ST_Anything, I would prefer to say a user should have a basic understanding of Arduino programming and circuits.

My son and I wrote ST_Anything to drastically reduce the expertise required to utilize these inexpensive microcontrollers with SmartThings and Hubitat. The ReadMe is pretty detailed, with step by step instructions for getting started.

If you need assistance, all you have to do is simply ask. I promise you it is not very hard. I have walked folks through the process who have zero programming experience and they have been very pleased with the results.

If you’ve never performed any Arduino programming previously, then I would recommend you familiarize yourself with the basics via any of many websites that offer tutorials. Like anything else, it takes a little while for it to become second nature.

If you’re new to SmartThings, there are some great tutorials on how to install custom Device Handlers available as well.

If its not for you, so be it. I wish you the best in whatever you decide. I am an Electrical Engineer with over 29 years of experience, myself. I work in the industrial automation field, so I find building things like this a fun hobby. I understand that it’s not for everyone, though.

Thank you… Let me explain where I am coming from.

For the past 5 years or so, I have been teaching PLTW digital Electronics where they have like 3 or so labs that use Arduino and we modify the program slightly for the lab. I decided I wanted to learn programming and struggle to find good sources to teach it so I decided to start programming smart switches for my home. I have been using and modifying the belkin wemo emulator versions. I would take a single switch and make it work with the wemo d1 mini switching more than one switch and then adding button function (which I figure out how to write from scratch). After five years, I thought I was getting pretty good at figuring out what is going on in the code and being able to change it for my needs. I spent almost a month trying to understand your code and can’t. The issue is it’s not just for one function and I don’t know what goes with what. I take the opportunity to look at a functioning code to understand what is going on with it and I learn from it and really learn when I try to modify it. You wouldn’t happen to have a version that is for one relay would you without all the other stuff? I am using two different boards and the the only difference in them are the relay pin. Sonoff pin 12 and wemo d1 mini pin 5. Thanks for understanding my frustration. I guess my issues is with the way I have learned to code. Back in 1980’s when I had a commodore 64, I was pretty wicked at writing basic programs and C++ is very similar, it just has many more options. Like going from a McDonalds menu to a menu of infinite size. Thanks again.

I completely understand the desire to learn how things work. I am the same way. My son and I wrote ST_Anything years ago to give back to the community a much simpler, easier to use solution for integrating Arduino-type boards with SmartThings. This actually started back when SmartThings sold an Arduino Shield called the “ThingShield.” This is where I came up with the name “AnyThing” as it allowed users to connect an Arduino to ST and create ‘Any’ type of ‘Thing’ they desired.

There are two main custom sets of Arduino Libraries within our GitHub repository…

The first set are the “SmartThings…” libraries. These perform all of the Arduino to ST Hub communications over Zigbee (the old ThingShield), Ethernet, or WiFi. These libraries are specific on the hardware you’re using (e.g. Wemos D1 would use the SmartThingsESP8266WiFi library.)

The second set of libraries are the “ST_Anything…” libraries. These utilize the aforementioned ‘SmartThings…’ libraries for all communications to the ST Hub. The purpose of ST_Anything is to then create a solution that allows users to easily write a simple sketch, without having to know all of the details about Arduino programming and how to utilize the ‘SmartThings…’ libraries. GPIO pins are automagically configured and monitored for changes. Updates are automatically sent to ST. Commands from ST are automatically routed to the correct ST_Anything ‘devices’ that are defined in the sketch by the user. At the top of every one of the ST_Anything device class C++ set of files (the .h and a .cpp files), you will find a description of all of the parameters that can be passed into the constructor of each object in the setup() portion of the sketch.

The basic portions of an ST_Anything sketch are:

  1. define your local network connection information
  2. declare which ‘ST_Anything’ devices are to be used in your sketch
  3. declare which type of ‘SmartThings…’ communication object will be used
  4. Add the devices from step 2 to the ST_Anything ‘Everything’ class. This class takes care of all scheduling, and data routing between ST and the individual devices on the Arduino

(Note: I also include a copy of all of the other Arduino libraries that ST_Anything uses for its various devices. I do this to ensure users have everything they need to get started without having to hunt down an install a bunch of libraries from all over the internet. There are a few things that need to be downloaded via the Boards Manager, like support for the ESP8266, of course.)

Sure, that’s a pretty simple sketch. Here you go!

//******************************************************************************************
//  File: ST_Anything_Switch_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 Switch devices (used to turn on a digital output (e.g. LED, relay, etc...)
//    
//  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 <EX_Switch.h>       //Implements an Executor (EX) via a digital output to a relay


//******************************************************************************************
//Define which Arduino Pins will be used for each device
//******************************************************************************************

#define PIN_SWITCH_1              D1  //SmartThings Capability "Switch"

//******************************************************************************************
//ESP8266 WiFi Information
//******************************************************************************************
String str_ssid     = "yourSSIDhere";                           //  <---You must edit this line!
String str_password = "yourWiFiPasswordhere";                   //  <---You must edit this line!
IPAddress ip(192, 168, 1, 227);       //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

// Smarthings Hub Information
IPAddress hubIp(192, 168, 1, 149);  // smartthings hub ip       //  <---You must edit this line!
const unsigned int hubPort = 39500; // smartthings hub port

// Hubitat Hub Information
//IPAddress hubIp(192, 168, 1, 143);    // hubitat hub ip         //  <---You must edit this line!
//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)
{
//  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
  
  //Interrupt Sensors 

  //Special sensors/executors (uses portions of both polling and executor classes)
  
  //Executors
  static st::EX_Switch executor1(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
  //*****************************************************************************
     
  //*****************************************************************************
  //Add each executor to the "Everything" Class
  //*****************************************************************************
  st::Everything::addExecutor(&executor1);
   
  //*****************************************************************************
  //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();
}

Wow, that is much different then what I expected. Here is what I am doing. I am using the Wemo D1 mini. Some I am using the D1 pin 5 to switch the relay and D3 = pin 0 to use a push button on the wall just in case the Wifi would die we could still turn off the lights and turn them on. Then I have some D1 mini’s that have two relays for like my living room lamps or my wall that has 3 switches on for ceiling fan, garage light and living room light. Each one of them have a push button switch as well. My wife isn’t on board with the smart home, so the buttons are important. She still walks up and turns lights on and off that way. I use Alexa. Am I barking up the wrong tree with this, or am I just so green with coding I don’t understand how this can work for me? I do want to say thank you for helping me out with this. I want to get better so I can maybe someday pass on this knowledge to my students.


ogiewon
Dan
Community Master

    April 27

alt Bradley_Martin:
I take the opportunity to look at a functioning code to understand what is going on with it and I learn from it and really learn when I try to modify it.

I completely understand the desire to learn how things work. I am the same way. My son and I wrote ST_Anything years ago to give back to the community a much simpler, easier to use solution for integrating Arduino-type boards with SmartThings. This actually started back when SmartThings sold an Arduino Shield called the “ThingShield.” This is where I came up with the name “AnyThing” as it allowed users to connect an Arduino to ST and create ‘Any’ type of ‘Thing’ they desired.

There are two main custom sets of Arduino Libraries within our GitHub repository…

The first set are the “SmartThings…” libraries. These perform all of the Arduino to ST Hub communications over Zigbee (the old ThingShield), Ethernet, or WiFi. These libraries are specific on the hardware you’re using (e.g. Wemos D1 would use the SmartThingsESP8266WiFi library.)

The second set of libraries are the “ST_Anything…” libraries. These utilize the aforementioned ‘SmartThings…’ libraries for all communications to the ST Hub. The purpose of ST_Anything is to then create a solution that allows users to easily write a simple sketch, without having to know all of the details about Arduino programming and how to utilize the ‘SmartThings…’ libraries. GPIO pins are automagically configured and monitored for changes. Updates are automatically sent to ST. Commands from ST are automatically routed to the correct ST_Anything ‘devices’ that are defined in the sketch by the user. At the top of every one of the ST_Anything device class C++ set of files (the .h and a .cpp files), you will find a description of all of the parameters that can be passed into the constructor of each object in the setup() portion of the sketch.

The basic portions of an ST_Anything sketch are:

  1. define your local network connection information
  2. declare which ‘ST_Anything’ devices are to be used in your sketch
  3. declare which type of ‘SmartThings…’ communication object will be used
  4. Add the devices from step 2 to the ST_Anything ‘Everything’ class. This class takes care of all scheduling, and data routing between ST and the individual devices on the Arduino
    (Note: I also include a copy of all of the other Arduino libraries that ST_Anything uses for its various devices. I do this to ensure users have everything they need to get started without having to hunt down an install a bunch of libraries from all over the internet. There are a few things that need to be downloaded via the Boards Manager, like support for the ESP8266, of course.)

alt Bradley_Martin:
You wouldn’t happen to have a version that is for one relay would you without all the other stuff?

Sure, that’s a pretty simple sketch. Here you go!

//******************************************************************************************
//  File: ST_Anything_Switch_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 Switch devices (used to turn on a digital output (e.g. LED, relay, etc...)
//
//  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 <EX_Switch.h>       //Implements an Executor (EX) via a digital output to a relay

//******************************************************************************************
//Define which Arduino Pins will be used for each device
//******************************************************************************************

#define PIN_SWITCH_1              D1  //SmartThings Capability "Switch"

//******************************************************************************************
//ESP8266 WiFi Information
//******************************************************************************************
String str_ssid     = "yourSSIDhere";                           //  <---You must edit this line!
String str_password = "yourWiFiPasswordhere";                   //  <---You must edit this line!
IPAddress ip(192, 168, 1, 227);       //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

// Smarthings Hub Information
IPAddress hubIp(192, 168, 1, 149);  // smartthings hub ip       //  <---You must edit this line!
const unsigned int hubPort = 39500; // smartthings hub port

// Hubitat Hub Information
//IPAddress hubIp(192, 168, 1, 143);    // hubitat hub ip         //  <---You must edit this line!
//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)
{
//  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

  //Interrupt Sensors

  //Special sensors/executors (uses portions of both polling and executor classes)

  //Executors
  static st::EX_Switch executor1(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
  //*****************************************************************************

  //*****************************************************************************
  //Add each executor to the "Everything" Class
  //*****************************************************************************
  st::Everything::addExecutor(&executor1);

  //*****************************************************************************
  //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();
}

I have an example sketch for that as well… Take a look at the following. It can handle three digital outputs and 3 momentary push-buttons. The logic for the buttons is all locally contained within the sketch, which might be interesting to see as an example of how some ‘local control’ can be added within the ST_Anything architecture.

Be sure to adjust the PI assignments for your hardware.

@ogiewon I am somewhat new to Arduino but have written sketches for my own purposes. I am trying to figure out how all of this works. I am trying to convert my garage door sensor that uses an ultrasonic SR04 to determine if the garage door is up or down and if a car is in the garage or not based on the distance it is reading. Is it possible to use your examples to write my own sketch to do this? I mean putting my own logic in the loop of the program to set sensors on and off based on the distances the sensor is reading? What I did so far, loaded the garage door sketch and added logic based on serial input to change the sensor values without an actual sensor hooked up just for testing purposes.
I can’t seem to get them to change without actually grounding those pins. I tried digitalWrite(PIN_DOORCONTROL_CONTACT_2,HIGH); but it does not seem to change that sensor value when I hit refresh. I also can only get the app to show refresh, 0 buttons, the name of the device that says it departed and a dash for tiles. Refresh does work, the serial monitor shows it working. I am using the 12E board. Thanks!

The Garage Door Control requires the use of a digital input to indicate whether the door is open or closed. By default, this is configured for a simple magnetic reed switch to indicate the status of the door. The digital input for this sensor has its Internal Pullup resistor enabled. This is a user configurable setting in the sketch when the door control device is declared.

I would recommend just changing for the ultrasound sensors to the much simpler magnetic reed switches. I use old hard drive magnets, which are very powerful, attached to the garage doors to trigger the reed switches mounted to the framing.

If you really want to use ultrasonic sensors, you may want to build your own logic in the loop() portion and have that turn on a digital output pin that is wired to the digital input pin for the contact sensors. To do this you will need to disable the internal pullup feature for those pins.

Thanks for the quick reply! I’ll have to play with it a little but I think I understand what I need to do now.