[RELEASE] ST_Anything - Arduino/ESP8266/ESP32

This a good Idea as I have several different modified DH’s for my purposes using the contact sensor. For instance Tank “Full” (Green) or “Low” Red. Would it be possible to also add a color choice for each open and close state. Like allow user to not only select the name but also select color for each case; Red, Green, Blue, or Orange etc…?

The short answer is yes its possible. The long answer is you would need to have a entry for each states color which would get completely unmanageable if they were select-able options. It’s doable but for each color choice you’d allow the user to select you’d be increasing the DTH code by 5% - 8%.

With that said you can modify my DTH yourself. if you look at the code you will see a section under the tile definition called “Regular” and “Inverted”. This is where I’m reversing the colors. The colors are based on the SmartThings Tiles Documentation so #e86d13 is orange and #00a0dc is blue. Just change all of those to the colors you want. #44b621 is green and #bc2323 is red for example.

If you think you’ll use it I can add the “Full” and “Low” options in pretty easily also. I tried to make it a single DTH for any contact closure situation that I personally would have but I’m sure their are others.

Has any work been done with esp.deepsleep? I’m following this project, but it seems like it’d require the esp8266/arduino/etc device to be on the entire time, or am I misunderstanding it?

In my case, it’s a simple wifi/wireless humidity sensor. It’s running off a 18650 battery so being able to sleep is very important… Right now I’m using a combination of homeassistant/mqtt-smartbridge bridge… Would love to simplify using this, but not sure if it’s realistic given that this project won’t let the device sleep? Basically it wakes up every 5 minutes to report the temp/humidity through mqtt to homeassistant then goes back to sleep. I’m still working on the smartthings-mqtt bridge part of it. Would love to switch to this project if it can handle the device napping…

(Or am I totally missing something here?)

-mark

Mark,

You are in luck! I had another ST_Anything user attempt the exact same thing, and it works!

Basically, ST_Anything is already designed to perform the WiFi connection and an initial status update to SmartThings as part of the sketch’s setup() routine. This means if you deep sleep at the end of the setup() routine, and tell it to wake back up in 5 minutes, you’ll be all set.

When an ESP8266 wakes up from deep sleep, it just restarts the board from scratch, thereby running the setup() routine again. And thus the process is sustained.

In this case, you do not need to have any code in the loop() routine as it will never get called.

This also means that your device can only send data. It will never be able to receive data, which is probably fine for your use case.

Dan

awesome, thanks. I’ll have to try it tonight.

Which sketch would you thing is the closest out of your examples for a simple humidity sensor? (I’m using bme280 which I didn’t see… I guess the dht22 is the closest?)

-mark

Correct, the DHT series of sensors is already supported. If you’re an Arduino programmer, adding a new class to ST_Anything that supports the bme280 shouldn’t be too difficult. I don’t have one of those sensors, so I have haven’t written one for it.

Start with the ST_Anything_Multiples_ESP8266WiFi.ino sketch, and simply comment out the extra devices. Just leave one declaration for the DHT22 device (if you need an example, look at one of Arduino MEGA example sketches, as those showcase almost every sensor in the library, including the DHT22’s.)

Or, you could start with the ST_Anything_Multiples_ESP01WiFi.ino if you’re planning on using one of those tiny boards.

Has anything experimented with making the serial connection available via WiFi? Is this something that would even be possible? I upgraded my setup from 2 to 5 temp sensors and today all 5 of them stopped reporting. I can still ping the board though but that seems to be all the information I can get from a remote location.

Assuming you’re using an ESP8266, downgrade the ESP8266 Arduino board package to v2.3. There is a known issue with v2.4.x causing a memory leak that hoses up the board.

Dan, turns out it was a problem with the InfluxDB logger app code in Hubitat. I shared my findings in the Hubitat forum.
Question remains though, would it be possible to gain access to the serial monitor via Wifi? I did some research and saw some DIY “shields” that would do the job, but this is done using an additional ESP.

I don’t know of any simple way to get Serial Monitor data, except via a direct USB connection. I would love to be able to access this data remotely as well.

Hi All,

Hoping to gather some advice on implementing an ST_Anything-based dimmer setup for a group of lights.

Specifically, I’d like to use a Wemos D1 R2 with an analog potentiometer as a physical input. That rotary potentiometer should allow me to control the on/off and level state of a group of lights. I originally envisioned this working as follows:

  1. Turn knob
  2. ST_Anything updates the status of a Virtual Dimmer
  3. Virtual Dimmer state controls multiple dimmable bulbs

I already have some virtual switches set up to control groups of lights. The sticking point for me is the ability to use ST_Anything to create a virtual dimmer device type controlled by the analog input from a potentiometer.

Anybody else tried to tackle a similar problem?

In other news, I’m happy to report the success of my last ST_Anything-based project (garage door opener) thanks to the advice from this community!

Thanks!
Kevin

1 Like

You could try the PS_Generic sensor and tie the potentiometer into your analog input. You could also just do two button functions. One button raises the level by 10% each press and one lowers it by 10% each press. That might be simpler.

I’m getting Exception 28 from ST_Anything v2.9. I’m sure it’s my code, but I’d love to know how to troubleshoot this.
I fired up vs2013 on my Windows10 machine to see if it could provide some insights with the plug-in, but that was useless. I’m an electrical engineer, but not quite familiar with the details of programming the ESP8266-12E module. I setup a web browser to monitor and control my device’s I/O, but my goal is to have a reliable interface with my SamLine 121 is run_scheduled_functions();sung SmartThings hub.

I think I understand how the Arduino IDE manages the cache, but am so challenged by the debugging capability of the IDE and I really hate doing so much of it manually.

Lately, the exceptions have been winding up at,
Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads
Decoding 10 results
0x4020282e: STsiren::refreshDevices() at /tmp/arduino_build_206339/sketch/ST_SirenBase.cpp line 185
0x40202838: STsiren::refreshDevices() at /tmp/arduino_build_206339/sketch/ST_SirenBase.cpp line 185
0x4020302a: STsiren::run() at /tmp/arduino_build_206339/sketch/ST_SirenBase.cpp line 456
0x40107460: sntp_get_current_timestamp at ?? line ?
0x40107508: sntp_get_current_timestamp at ?? line ?
0x40107508: sntp_get_current_timestamp at ?? line ?
0x40107508: sntp_get_current_timestamp at ?? line ?
0x40203254: loop at /home/pinaar/Arduino/ST_Siren_ESP8266WiFi/ST_Siren_ESP8266WiFi.ino line 110
0x40209aa0: loop_wrapper at /home/pinaar/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/core_esp8266_main.cpp line 121
0x40100a2c: cont_norm at /home/pinaar/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/cont.S line 109

where Line 121 is run_scheduled_functions();

What would you do to get this resolved? It seems to me that a hardware debugger for an ESP8266 or ESP32 can’t be that expensive! I.e., is that a viable alternative?

Thanks,
Art

Can you load your sketch?

I’m sure, but I’m not familiar with the tech.

The software that you loaded onto the bard from the Arduino IDE?

Please post a copy of your sketch, or a link to it so we can look at it.

Please use the preformatted text option to make it readable.

Here’s the main code, “ST_Siren_ESP8266WiFi.ino” 110 lines,

#include “ST_SirenBase.h”
#include <ESP8266WiFiSTA.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266WiFiAP.h>
#include <WiFiClient.h>
#include <ESP8266WiFiGeneric.h>
#include <ESP8266WiFiScan.h>
#include <WiFiUdp.h>
#include <WiFiClientSecure.h>
#include <ESP8266WiFiType.h>

//******************************************************************************************
// File: ST_Siren_ESP8266WiFi.ino
// Author: Art J Pina
//
// Summary: See ST_Anything_AlarmPanel_ESP8266WiFi.ino for additional details on this Arduino Sketch
// and the ST_Anything library.
// ST_Siren_ESP8266WiFi implements an Alarm (Siren & Strobe) device (using a two digital
// outputs to drive load NMOS transistor switches to turn on the strobe light and/or siren)
// Initial testing is with two LED’s tied to D1 & D2 outputs from the ESP module.
//
// Derived from original application, ST_Anything_AlarmPanel_ESP8266WiFi.ino
// by Dan G Ogorchock & Daniel J Ogorchock
//
//******************************************************************************************
// SmartThings Library for ESP8266WiFi
//******************************************************************************************
#include <SmartThingsESP8266WiFi.h>

// State variables
int battSts = -1, sdoorSts=-1, pin1Sts=-1, pin2Sts=-1; // Indicate unknown until read

// Persistent/Global Variables
float vp=0.00f; // Previous Voltage Measurement
bool vpread=false; // VPrevious cc unread
float v=0.000f; // Current Voltage Measurement
WiFiServer serverif(80); // Browser monitor - server interface

//******************************************************************************************
//ESP8266 WiFi Information
//******************************************************************************************
String str_ssid = “MySpectrumWiFi7a-2G”; // Custom
String str_password = “purplebread459”; // Custom
IPAddress ip(192, 168, 1, 169); //Device IP Address // Custom
IPAddress gateway(192, 168, 1, 1); //Router gateway // Custom
IPAddress subnet(255, 255, 254, 0); //LAN subnet mask // Custom
IPAddress dnsserver(192, 168, 1, 1); //DNS server // Custom
const unsigned int serverPort = 8090; // port to run the http server on

// Smartthings / Samsung Hub TCP/IP Address
IPAddress hubIp(192, 168, 1, 95); // smartthings/Samsung hub ip // Custom
const unsigned int hubPort = 39500; // smartthings 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 sketch.
//******************************************************************************************
// void callback(const String &msg) – see original for implementation notes

//******************************************************************************************
//Arduino Setup() routine
//******************************************************************************************
void setup()
{
pinMode(PIN_1, OUTPUT);
pinMode(PIN_2, OUTPUT);
pinMode(SPIN_1, INPUT);

//******************************************************************************************
//Executors
static EX_Switch executor1(F(“switch1”), PIN_1, HIGH, true);
static EX_Switch executor2(F(“switch2”), PIN_2, LOW, false);

//*****************************************************************************
// Configure debug print output from each main class
//*****************************************************************************
Device::debug=EX_Switch::debug=STsiren::debug=false;
//*****************************************************************************
//Initialize
//*****************************************************************************
//Create the SmartThings ESP8266WiFi Communications Object. STATIC IP Assignment - Recommended
STsiren::SmartThing = new st::SmartThingsESP8266WiFi(str_ssid, str_password, ip, gateway, subnet, dnsserver, serverPort, hubIp, hubPort, receiveSmartString);
STsiren::init(); // Set baudrate to 230200
if (WiFi.isConnected() == true){
// Start the server
serverif.begin(); // Browser monitor
Serial.println(“Browser monitor server started”);

// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");

}

STsiren::addExecutor(&executor1); //Add each executor to the STsiren Class
STsiren::addExecutor(&executor2); //Add each executor to the STsiren Class
STsiren::initDevices(); //Initialize each device added to the STsiren Class
// Light’em up! digitalWrite(D1, HIGH);digitalWrite(D2, HIGH);
}

//******************************************************************************************
//Arduino Loop() routine
//******************************************************************************************
void loop()
{
STsiren::run(); // Call my version - ajp v. st::Everything::run(); // Take care of “Everything”
}

I’m on Ubuntu 17.10 with the Arduino IDE 1.8.5.

I posted via a reply to ogiewon a few minutes ago.
I actually took the St_Anything code and stuck it into my ST_SirenBase.cpp & “.h” files because I wanted to tweak a bunch of parameters, e.g, but the baud from 115k to 230k, etc. It just seemed like this was the best way to do it to avoid “class conflicts”.

  • Psi