[Release] HubDuino v1.1.7 - Hubitat to Arduino / ESP8266 / ESP32 / ThingShield Integration (ST_Anything)

community_app
community_driver

#795

So. Just to make sure... Should i copy from ST_Anything_Multiples_ESP8266WiFi, everything what says "button"
#define PIN_BUTTON_1 D3
#define PIN_BUTTON_2 d4
And past to servo sketch?
I'm sorry. I'm new in coding...


#796

Well, it depends on what pins you’re using for the Servo, to prevent a conflict. And, you should check out the ReadMe, as it describes which ESP8266 pins are safest to use. And you’ll need the 4 other lines of “button” device code from the example sketch as well... give it a try. Let us know if you get stuck.


#797

Jusy FYI, caPitaLiZAtION really matters. :slight_smile: So, where you have this:

#define PIN_BUTTON_2 d4

Because d4 and D4 are not the same things. One thing that I didn't pick up on right away and caused a lot of frustration back when I was beginning. The best advice I can give you is to use the other sketch more as a guide rather than trying to copy/paste it in. You'll run into more trouble than just typing it in yourself. Good luck!!


#798

Can you please?


#799

Can I what?


#800

Oh... Nevermind... I thought you said that you have template/guide to create sketch... Lol


#801

Oh....no...i meant use the ESP8266WIFI_Multiples sketch as a guide to add stuff to your servo sketch. Rather than trying to copy/paste. :slight_smile:


#802

I was thinking about building 2 x WeMo's D1 mini temperature & humidity measurement sensors. Now I noticed on the GitHub page there is a few mentioned. Does anyone have any recommendations on the best one to actually use? FYI - I was thinking about using one outside to show on my HE dashboard and then the other inside my communications rack in the garage to see how hot it gets in there.


#803

I really like the BME280 and AM2320 I2C sensors. These seem to be much more reliable than the DHT22 sensor.


#804

ok..i did but buttons still does not working...

#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_Illuminance.h> //Implements a Polling Sensor (PS) to measure light levels via a photo resistor

#include <IS_Button.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin for button presses
#include <EX_Servo.h> //Implements Executor (EX)as an Switch Level capability via a PWM output to a servo motor

#define PIN_SERVO_1 D1 //SmartThings Capabilty "Switch Level"
#define PIN_BUTTON_1 D3 //SmartThings Capabilty Button / Holdable Button (Normally Open!)
#define PIN_BUTTON_2 D4 //SmartThings Capabilty Button / Holdable Button (Normally Open!)

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

// Hubitat Hub Information
IPAddress hubIp(192, 168, 1, 252); // 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()
{

//Interrupt Sensors
static st::IS_Button sensor1(F("button1"), PIN_BUTTON_1, 1000, LOW, true, 500);
static st::IS_Button sensor2(F("button2"), PIN_BUTTON_2, 1000, LOW, true, 500);

//Executors
static st::EX_Servo executor1(F("servo1"), PIN_SERVO_1 , 90, true, 1000, 0, 180, 2000, 544, 2400);

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

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


#805

From a very quick glance at your sketch, it seems alright.

So, here are a few questions that will help guide the troubleshooting:

  1. Does the sketch you provided compile and load to the ESP8266 without any errors?
  2. When you connect a Button/Switch between GND and pin D3 (or D4) and then press the button, do you see some debug output in the Arduino IDE Serial Monitor Window?
  3. In Hubitat, when view the HubDuino Parent device, did you set the Number of Buttons = 2 and then click save?
  4. When you press a button wired as described in #2 above, do you see the button pushed and held events in the HubDuino Parent Device?

That's a good starting point...


#806

all 4 yes
I guess need add to sketch function if button on run servo etc????


#807

Do that from within Rule Machine. That’s the easiest easy to get things started.


#808

Ok... I will try... But if you know way to do it in sketch, let me know


#809

Doing it in rule machine will allow for the most flexibility rather than hard-coding it in your sketch. It will also allow you to use the current value of the servo in your button action. For example, if you wanted to raise them by 20% with one button push, doing so would be a pain to hard-code in the sketch but would be very easy to do in Rule Machine.


#810

tried within rule machine... -> working


#811

I used up all the I/Os on my Adruino 256 so I bought another one :smile: . I used the original sketch as a template for my new 256. I changed the Arduino IP address and the MAC address. Looking at the Serial Monitor it says it is sending to the hub but there are no new devices. What have I missed?


#812

Did you create a new Hubduino parent Ethernet device and input ip and Mac and such?


#813

I did not do that I wondered if I needed to do that.
I'll do that

Thanks


#814

That did the trick,

Thanks for the help