When that button is pressed. Charlotte needs to go 180. I do believe that is a switch function indicated in my coat above.
You need to do some more basic understanding of how Arduino code works and how ST works. You are trying to jump to level 8,398 when youâre on level 5. Take things a little slower.
In order to get ST_Anything to control a servo, you need to build a sketch that uses the Servo library and the functions within that library. It isnât as easy as you claim.
When I get back home I will post some code that I found that works to accomplish the task but does not use St anything. And donât know where to change in that code to adjust the servo.
Are you even reading my replies? Itâs not that simple as just âchanging some codeâ to insert what you found. You remember when you downloaded the ST_Anything Library for the Arduino IDE? Well, in there are all these .h and .cpp files. For example, IS_Contact.h. This is the file that defines how a contact sensor works. It is then called by the rest of the functions of ST_Anything. The âContactâ part is the capability. You would have to take the code your found and convert it into a ST_Anything capability. You would then have to create a new child device type and then modify the parent DTH for the new child.
So, itâs not as easy as âdropping in some code.â Do you understand how complicated it is now? I tried to do exactly what you are asking to do a couple months ago and it was WAAAAY too complicated to even bother with. I posted a sketch that allows the capability of ST anything and blinds with the other DTH. Why not use that?
/**
* NodeMCU Blinds Switch Device Handler
*
* Copyright 2018 Viet Nguyen
*/
import java.security.MessageDigest
preferences {
input("serverIP", "text", title: "NodeMCU Server IP Address")
}
metadata {
definition (name: "NodeMCU Blinds", namespace: "smartthings-users", author: "Viet Nguyen") {
capability "Switch"
capability "Refresh"
capability "Polling"
command "subscribe"
command "setOffline"
}
simulator {}
tiles(scale: 2) {
multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
attributeState "on", label:'${name}', action:"switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821", nextState:"off"
attributeState "off", label:'${name}', action:"switch.on", icon:"st.switches.switch.off", backgroundColor:"#ffffff", nextState:"On"
attributeState "offline", label:'${name}', icon:"st.switches.switch.off", backgroundColor:"#cccccc"
}
}
standardTile("refresh", "device.switch", inactiveLabel: false, height: 2, width: 2, decoration: "flat") {
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
}
main "switch"
details(["switch","refresh"])
}
}
def setLevel(value) {
log.trace "setLevel($value)"
sendEvent(name: "level", value: value)
}
// handle commands
def on() {
sendEvent(name: "switch", value: 'on')
apiGet("open")
}
def off() {
sendEvent(name: "switch", value: 'off')
apiGet("close")
}
private apiGet(action) {
log.debug "Posting Body: NODEMCU"
def result = new physicalgraph.device.HubAction(
method: 'GET',
path: '/'+action,
headers: [
HOST: settings.serverIP + ':80',
'Content-Type': 'application/json'
],
body: []
)
return sendHubCommand(result)
}
def refresh() {
log.debug "Executing NodeMCU Blinds refresh'"
poll()
}
def poll() {
log.debug "Executing NodeMCU Blinds POLL'"
def cmd = new physicalgraph.device.HubAction([
method: 'GET',
path: '/status',
headers: [
HOST: settings.serverIP + ':80',
Accept: "*/*"
]
], '', [callback: calledBackHandler])
def result = sendHubCommand(cmd)
log.debug "cmd: $cmd"
log.debug "result: $result"
}
void calledBackHandler(physicalgraph.device.HubResponse hubResponse) {
def body = hubResponse.json;
log.debug "body $body"
if(body.isOpen == 1){
sendEvent(name: "switch", value: 'on')
}else if(body.isOpen == 0){
sendEvent(name: "switch", value: 'off')
}else{
log.debug "OFFFFFFFLINE"
setOffline()
}
}
def updated() {
log.debug "Executing NodeMCU Blinds UPDATED'"
unschedule()
runEvery1Minute(poll)
}
def setOffline() {
sendEvent(name: "switch", value: "offline", descriptionText: "The device is offline")
}
/*
Window Blinds by Viet Nguyen
Features:
- Auto Update firmware with /update or curl -F âimage=@HelloServerWorking.ino.nodemcu.binâ esp8266-v.local/update
- To open/close use endpoints /open /close
- By default it uses the speed and duration set in the EEPROM
- Overridable values: speed, duration, dutyCycle
- Configuration
- Get: GET /config
- Set: GET /config with the following values in the query string:
- Speed: Speed at which the motor turns when opening / closing
- Allowed values: 1 for slow 2 or fast
- Duration: Duration at which the motor turns when opening / closing
- Allowed values: 1000 - 9999 (milliseconds)
- Version: /version
https://github.com/vietquocnguyen/NodeMCU-ESP8266-Servo-Smart-Blinds
*/
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h>
#include <Servo.h>
#include <EEPROM.h>
#include <math.h>
#include <ArduinoJson.h>
#define VERSION 19
#define DEFAULT_WIFI_SSID "bob5731"
#define DEFAULT_WIFI_PASSWORD "crocker50red"
#define DEFAULT_HOSTNAME "esp8266-smart-blinds"
#define DEFAULT_SPEED "2" // 1 or 2
#define DEFAULT_DURATION "3500" // 4 characters 1000-9999
#define DEFAULT_LAST_ACTION "0"
char host[25];
char ssid[25];
char password[25];
int servoPin = 05;
int tryCount = 0;
Servo Servo1;
ESP8266WebServer server(80);
ESP8266HTTPUpdateServer httpUpdater;
void setup(void) {
// Avoid Randomly Vibrating when turning on
Servo1.attach(servoPin);
Servo1.write(0);
delay(200);
Servo1.detach();
Serial.begin(115200);
EEPROM.begin(512);
if (getData(84, 86, "0") == "1") {
// Yay I know you
} else {
// I don't know you
clearEEPROM();
setData(84, 86, "1"); // Getting to know you
}
String theSSID = getData(0, 25, DEFAULT_WIFI_SSID);
String thePassword = getData(26, 50, DEFAULT_WIFI_PASSWORD);
String theHostname = getData(61, 80, DEFAULT_HOSTNAME);
Serial.println("Trying " + theSSID + " / " + thePassword + " / " + theHostname);
theSSID.toCharArray(ssid, 25);
thePassword.toCharArray(password, 25);
theHostname.toCharArray(host, 25);
WiFi.begin(ssid, password);
Serial.println("Started");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
tryCount = tryCount + 1;
Serial.print("Try #" + String(tryCount) + " ");
if (tryCount > 30) {
Serial.println("Giving up, reverting back to default Wifi settings");
setData(0, 25, DEFAULT_WIFI_SSID);
setData(26, 50, DEFAULT_WIFI_PASSWORD);
setData(61, 80, DEFAULT_HOSTNAME);
delay(1000);
WiFi.disconnect();
ESP.reset();
}
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
if (MDNS.begin(host)) {
Serial.println("MDNS responder started");
}
server.on("/version", []() {
DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.createObject();
Serial.println("version");
json["version"] = VERSION;
String output;
json.prettyPrintTo(output);
server.send(200, "application/json", output);
});
server.on("/status", []() {
DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.createObject();
Serial.println("status");
json["isOpen"] = getData(81, 83, DEFAULT_LAST_ACTION) == "1";;
String output;
json.prettyPrintTo(output);
server.send(200, "application/json", output);
});
server.on("/clear", []() {
DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.createObject();
Serial.println("clear");
json["message"] = "Clearing EEPROM data and resetting";
String output;
json.prettyPrintTo(output);
server.send(200, "application/json", output);
clearEEPROM();
WiFi.disconnect();
ESP.reset();
});
server.on("/reset", []() {
DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.createObject();
json["message"] = "resetting";
Serial.println("Resetting");
String output;
json.prettyPrintTo(output);
server.send(200, "application/json", output);
WiFi.disconnect();
ESP.reset();
});
server.on("/open", []() {
openOrClose(1);
});
server.on("/close", []() {
openOrClose(0);
});
server.on("/config", []() {
DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.createObject();
int theSpeed = getData(51, 55, DEFAULT_SPEED).toInt();
if (server.hasArg("speed")) {
theSpeed = server.arg("speed").toInt();
setData(51, 55, String(theSpeed));
}
json["speed"] = theSpeed;
int theDuration = getData(56, 60, DEFAULT_DURATION).toInt();
if (server.hasArg("duration")) {
theDuration = server.arg("duration").toInt();
setData(56, 60, String(theDuration));
}
json["duration"] = theDuration;
String output;
json.prettyPrintTo(output);
server.send(200, "application/json", output);
});
server.on("/wifi", []() {
DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.createObject();
bool resetMe = false;
String aSsid = getData(0, 25, DEFAULT_WIFI_SSID);
if (server.hasArg("ssid")) {
aSsid = setData(0, 25, server.arg("ssid"));
resetMe = true;
}
json["ssid"] = aSsid;
String aPassword = getData(26, 50, DEFAULT_WIFI_PASSWORD);
if (server.hasArg("password")) {
aPassword = setData(26, 50, server.arg("password"));
resetMe = true;
}
json["password"] = aPassword;
String aHostname = getData(61, 80, DEFAULT_HOSTNAME);
if (server.hasArg("hostname")) {
aHostname = setData(61, 80, server.arg("hostname"));
resetMe = true;
}
json["hostname"] = aHostname;
json["ip"] = WiFi.localIP().toString();
String clientMac = "";
unsigned char mac[6];
WiFi.macAddress(mac);
clientMac += macToStr(mac);
clientMac.toUpperCase();
json["mac"] = clientMac;
if (resetMe) {
json["message"] = "Changes detected, now resetting.";
}
String output;
json.prettyPrintTo(output);
server.send(200, "application/json", output);
if (resetMe) {
ESP.reset();
}
});
server.onNotFound(handleNotFound);
httpUpdater.setup(&server);
server.begin();
MDNS.addService("http", "tcp", 80);
Serial.println("HTTP server started");
}
String macToStr(const uint8_t* mac) {
String result;
for (int i = 0; i < 6; ++i) {
result += String(mac[i], 16);
if (i < 5)
result += ':';
}
return result;
}
void openOrClose(int direction) {
DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.createObject();
bool toSpin = true;
String lastAction = getData(81, 83, DEFAULT_LAST_ACTION);
if (lastAction == String(direction)) {
toSpin = false;
json["message"] = "did not spin";
}
int theSpeed = getData(51, 55, DEFAULT_SPEED).toInt();
if (server.hasArg("speed")) {
theSpeed = server.arg("speed").toInt();
}
int theDuration = getData(56, 60, DEFAULT_DURATION).toInt();
if (server.hasArg("duration")) {
theDuration = server.arg("duration").toInt();
}
int dutyCycle = calculateDutyCycleFromSpeedAndDirection(theSpeed, direction);
if (server.hasArg("dutyCycle")) {
dutyCycle = server.arg("dutyCycle").toInt();
}
json["action"] = direction ? "open" : "close";
json["speed"] = theSpeed;
json["duration"] = theDuration;
json["calulatedDutyCycle"] = dutyCycle;
String output;
json.prettyPrintTo(output);
server.send(200, "application/json", output);
if (toSpin) {
Servo1.attach(servoPin);
Servo1.write(dutyCycle);
delay(theDuration);
Servo1.detach();
setData(81, 83, String(direction));
}
}
void handleNotFound() {
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET) ? "GET" : "POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i = 0; i < server.args(); i++) {
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
}
int calculateDutyCycleFromSpeedAndDirection(int speed, int direction) {
if (speed == 1 && direction == 1) {
return 80;
} else if (speed == 2 && direction == 1) {
return 0;
} else if (speed == 1 && direction == 0) {
return 95;
} else if (speed == 2 && direction == 0) {
return 180;
} else {
return 180;
}
}
// Get EEPROM Data
String getData(int startingIndex, int endingIndex, String defaultValue) {
String data;
for (int i = startingIndex; i < endingIndex; ++i) {
String result = String(char(EEPROM.read(i)));
if (result != "") {
data += result;
}
}
if (!data.length()) {
return defaultValue;
} else {
return data;
}
}
// Set EEPROM Data
String setData(int startingIndex, int endingIndex, String settingValue) {
for (int i = startingIndex; i < endingIndex; ++i) {
EEPROM.write(i, settingValue[i - startingIndex]);
Serial.print("Wrote: ");
Serial.println(settingValue[i - startingIndex]);
}
EEPROM.commit();
delay(250);
return settingValue;
}
void loop(void) {
server.handleClient();
}
void clearEEPROM() {
for (int i = 0 ; i < 512 ; i++) {
EEPROM.write(i, 0);
}
EEPROM.commit();
delay(500);
}
Did you read a single word that I wrote?
Yes I did read it.
Iâm trying to Zone a condo that I rent from my folks. They refuse to do anything in the way of fixing the heating there. Iâm trying to do this on a poor manâs budget. Downstairs stays cold in summer time in the winter the upstairs stays blazingly hot. So I thought by zoning the system would fix it. Thatâs what I saw on This Old House. But donât have the money to Shell out for smart vents.
The generic library and device was created to see how ST_Anything interfaces with a device, there are lots of comments in it. It also was designed with no pin definitions and an assumption on using the ic2 bus for sensors. The Adafruit TCS34725 device is based on it which is also a IC2 sensor. Look at the TCS34725 libraryâŠthat I would think should be the easiest to use.
Hi Dan,
Maybe I am doing something wrong here, but in my case both photoresistors i used acted like a switch. Normally a value of 128 was shown and when there was less light it suddenly gave a value of 4000 or something. The 1750 just gives a changing value dependent on how muchlight there is.
Verzonden vanaf mijn Samsung Galaxy-smartphone. Dus vergeef me een enkel tikfoutje.
That is not the behavior I normally see. I wonder if you have the photoresistor wired to the microcontroller properly? The link below shows the correct wiring of the photoresistor as part of a voltage divider circuit. Try using it as an example to make sure you have things wired up correctly and properly reporting a smooth range of values.
Once you have the circuit working, you can use the ST_Anything sketch instead. Within your setup() routine, you will define your PS_Illuminance device. You can adjust the last four arguments to suit your needs (i.e. scale the 'illuminance values based on the raw analog input values). See the details of all of the arguments below. (Note: every ST_Anything deviceâs documentation is at the top of the corresponding .h and .cpp files.)
//******************************************************************************************
// File: PS_Illuminance.h
// Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son)
//
// Summary: PS_Illuminance is a class which implements the SmartThings "Illuminance Measurement" device capability.
// It inherits from the st::PollingSensor class. The current version uses an analog input to measure the
// value of a simple photo resistor.
//
// The last four arguments of the constructor are used as arguments to an Arduino map() function which
// is used to scale the analog input readings (0 to 1024) to Lux before sending to SmartThings. The
// defaults for this sensor are based on the device used during testing.
//
// Create an instance of this class in your sketch's global variable section
// For Example: st::PS_Illuminance sensor1("illuminance1", 120, 0, PIN_ILLUMINANCE, 0, 1023, 0, 1000);
//
// st::PS_Illuminance() constructor requires the following arguments
// - String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name
// - long interval - REQUIRED - the polling interval in seconds
// - long offset - REQUIRED - the polling interval offset in seconds - used to prevent all polling sensors from executing at the same time
// - byte pin - REQUIRED - the Arduino Pin to be used as a digital output
// - int s_l - OPTIONAL - first argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output
// - int s_h - OPTIONAL - second argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output
// - int m_l - OPTIONAL - third argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output
// - int m_h - OPTIONAL - fourth argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output
The only problem with the code I posted is I donât know where to position the servo in the code.
All of those examples do not work that you linked above.
I also posted the device Handler code can you add to the device Handler code I start and stop degrees. For example start Servo at 10 degrees and stop Servo at 180. Other than that the code is working for me as far as I can tell. It took me several days to find that code all of the other that you mentioned did not even work for me. Iâm also using a called SmartThings app calledScheduleTstatZones
(Works with Any ST Connected thermostat, temp/motion/contact sensors & smart vents)
First of all, HUGE thanks to Dan and all the other contributors for the ST Anything project, I am super-impressed with the capabilities and ease of use of the platform!
I have been running into an issue where my boards stop responding after 2-3 days (sometimes less). By stop responding I mean they do not report status or accept commands from ST. Usually they will respond to ping, but not always. In some cases I have been able to âresurrectâ them by forcing a reconnect from my WLAN (I use Unifi), in others I have to power cycle the ESP.
I figure there is some sort of memory leak that is causing the board to crash after a period of time, but I figure if that was the case I would have seen a lot of others on here asking about it.
Iâd really like to get this sorted out, my plan right now is to figure out how to implement a watchdog timer into my sketch, from browsing through the library it doesnât appear there is anything built-in at the moment?
Board(s): Occurs on NodeMCU v0.9 and Wemos D1 Mini
Iâm using a fairly bog-standard sketch:
//******************************************************************************************
// File: ST_Anything_Relays_ESP8266.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_Relays_ESP8266 implements the following ST Capabilities as a demo of what is possible with a single NodeMCU ESP8266
// - 3 x Relay Switch devices
//
//
// 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
// 2017-11-27 Kai Lenk Modified to 3 relaySwitch
// 2017-11-29 Dan Ogorchock Revisions to make sure works for Kai Lenk
// 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_Illuminance.h> //Implements a Polling Sensor (PS) to measure light levels via a photo resistor
#include <PS_TemperatureHumidity.h> //Implements a Polling Sensor (PS) to measure Temperature and Humidity via DHT library
#include <IS_Contact.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin
#include <IS_Button.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin for button presses
#include <EX_Switch.h> //Implements an Executor (EX) via a digital output to a relay
#include <S_TimedRelay.h> //Implements a Sensor to control a digital output pin with timing capabilities//*************************************************************************************************
//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 2 //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_TIMEDRELAY_1 D5 //SmartThings Capability âRelay Switchâ
#define PIN_TIMEDRELAY_2 D6 //SmartThings Capability âRelay Switchâ//******************************************************************************************
//ESP8266 WiFi Information
//******************************************************************************************
String str_ssid = âxxxâ; // <âYou must edit this line!
String str_password = âxxxâ; // <âYou must edit this line!
IPAddress ip(192, 168, 30, 104); //Device IP Address // <âYou must edit this line!
IPAddress gateway(192, 168, 30, 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, 30, 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, 30, 6); // 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//******************************************************************************************
//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//Special sensors/executors (uses portions of both polling and executor classes)
static st::S_TimedRelay sensor1(F(ârelaySwitch1â), PIN_TIMEDRELAY_1, LOW, true, 40000, 0, 1); // Run once for 40 seconds on trigger
static st::S_TimedRelay sensor2(F(ârelaySwitch2â), PIN_TIMEDRELAY_2, LOW, true, 40000, 0, 1);//*****************************************************************************
// 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
//*****************************************************************************//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
//*****************************************************************************//*****************************************************************************
//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();
}
Thanks for the quick response Dan, Iâll try reverting!
Iâm using an ESP32s, and have a temp/humidity sensor, and a relay. After compiling and uploading to the ESP32, it connects to wifi, gets through everything, but the stops after displaying the temperature.
In the smartthings app, I have the parent setup, and only one child is created for the temp. It refuses to update the temp when hitting refresh and never updates on itâs own.m
The ip, port, and mac address are correct in the app. There are no errors in the ST API log, and nothing else is read out in the serial display unless the esp32 is reset.
Any idea what I could be missing? ii
I donât think youâre missing anything. A few others have mentioned recent ESP32 issues, probably due to recent changes in the ESP32 Arduino Board Package. Iâll take a look and see where it is getting hung up.
Thanks for the feedback.
Another noob here with ESP32 issues. Tried loading both of the example codes and keep running into the same thing. The first thing that pops up in the serial monitor after loading:
Everything: init started
Everything: Free RAM = -1
Disabling ESP32 WiFi Access Point
It does proceed to connect to the internet. Followed by this:
SmartThingsESP32WiFI: Intialized
Everything: init ended
Everything: Free RAM = -1
Everything: adding executor named rgbSwitch1
Everything: Free RAM = -1
Everything: adding executor named rgbSwitch2
Everything: Free RAM = -1
Everything: adding executor named rgbwSwitch1
Everything: Free RAM = -1
Everything: initDevices started
Everything: Free RAM = -1
Everything: Sending: rgbSwitch1 off
Then Iâm able to add it as a device to ST, but only the first child will show up, rgbSwitch1 in this example. Did I configure the ESP32 section of the IDE wrong? Iâve tried anything I can think of but still no results. Switched to a different ESP32 even.
Fix for the ESP32 has been pushed to the ST_Anything Github repository. Make sure you update your copy of SmartThingsESP32Wifi.cpp.
Thanks for your feedback in alerting us to this issue.
That was quick! Thanks so much! Iâll give it a go.
That seems to have fixed everything!
The only thing now is, I seem to be getting an error in the ST logs:
Error in parse() routine, error = java.lang.NullPointerException: Cannot get property âdateCreatedâ on null object