[DEPRECATED] ST_Anything - Arduino/ESP8266/ESP32

Dan,

Thanks, got everything going pretty good now. The status does still reset every few minutes, even with it commented out in the parent device, but I can deal with that for now.

Looking through the doorControl libraries, it looks like it calls for checking the contact sensor state a couple of times. I don’t know how to mess with the libraries. I think I’ll just deal with it, like it is, until I can get around to getting a different board and some contact sensors. The contact sensor in ST continues to show correctly in ST, just the door that reverts back to being open, so at least I do know the actual state of the door.

Thanks again for all your help today, getting this all setup.

I look forward to using your wonderful work on some future projects!

So this seemed to work EXCEPT major functionality issue…when I open and close doors/Windows the sensors in ST app don’t respond at all…(nothing shows opened when opened)…please advise! I must be doing something wrong…

Have.you simply connected a jumper wire between Arduino Gnd and the corresponding pin for a contact sensor? You should she the state change.

No but thats the perfect test, thanks. Just opened a door I haven’t tried yet and about 7 of my 13 contact sensors instantaneously switched to open…grounding issue? Nothing changed since I had every sensor working perfectly on your old code…im guessing ground issue…maybe I knocked a wire out of wack

It does sound like a loose ground wire.

Dan,

I would like to do a little project that would involve an esp-01 or similar, with a waterproof temp prob. Have it run on batteries, waterproofed and use it for pool temp monitoring. In order to do this, the esp would have to report like every 10-20 minutes then utilize the deep sleep mode, wake up, report, then back to deep sleep mode.

Would this be possible with ST_Anything? Again, I’m no coder, so looking for something that could be easily modified to work. I know there have been several people interested in a cheap DIY pool temp monitor compatible with ST.

@TexAMR,

It probably could be done, but I have never dug into the ESP8266’s deep sleep mode (nor the Arduino’s). Undfortunately, I have no time for a project like that right now. My guess though is that the ESP8266’s WiFi (like most WiFi) will eat batteries, even sending data only every 20 minutes or so. Maybe you could add a small solar panel to charge a battery during the day?

That was my idea. Throw a small solar cell on it. I’ll just have to read up on the deep sleep and see what it entails. Then I’ll try to merge it into yours and see what happens. Lol.

1 Like

All - I have updated the ReadMe on my Github to include support for v2.5 of ST_Anything with the new Parent / Child Device Handlers. Check out the first post of this thread for details:

1 Like

Thanks! That’s it? I don’t need extra power run to the relay? the digital pins provide enough power for the relay to send enough currant and voltage, just like that!?

If you’re using an Arduino MEGA, it can operate 1 relay pretty reliably using internal power to activate the relay’s dry contacts. The Arduino can not provide power to the siren.

The relay is what allows you to switch high voltage/current workloads safely without harming the Arduino. Think of the relay as simple on/off switch. Through that switch, you connect a separate power supply (per the siren’s requirements) to the siren, and then to ground of the Siren power supply.

Here is an example of the wiring I am talking about. Replace the LAMP with your SIREN. The bottom right icon is your power supply for your siren (separate from the Arduino’s internal power.)

Thanks Dan!!! Finally got all my contact sensors setup and working using your new parent and child device handlers; wow, totally awesome!!! push notifications and txt alerts from ST home monitoring now work like a charm for me!! VERY VERY COOL!!! Thanks very much for this relay example; I could not have asked for a better explanation… what motion sensor would you suggest buying to integrate into ST using the smart hub? Alot of options; I’m really for something hardwired… if you have any preference or suggestions, please let me know. Seriously, thanks for your help; could not have completed this without your code and guidance!!!

Very glad to hear you’ve got it working as desired. As for motion detectors, I am sure there may be a few that are capable of being externally powered versus battery only. For me, I use the battery powered ones mostly. Battery life on the newer ones seems to be very good (~9-16 months) so you’re not always changing batteries. I believe a lot of folks really seem to like the newer Iris motion detectors from Lowes. I have no first-hand experience with these.

I am still AD2Smartthings 2.0.1 with a ThingShield - I was reading that its not yet supported.

I am getting some issues with AD2ST - any idea when the ThingShield will be supported

I am working on the remaining LAN/Ethernet connected examples tonight. I should have the ThingShield example back up and running within a day or two. Sorry for the delay! :wink:

1 Like

Dan -

Don’t ever apologize. You are doing us all a massive service.

Wish you lived in my area. I’d treat you to one heck of a meal.

3 Likes

Good day;
I have implemented two switches for which I have the option to turn on or off manually, this is achieved by modifying one of your libraries which attach, my question is whether what implements is optimal or can be officially improved.

Thanks and stay tuned for an answer.

> IS_LuzControl.cpp

#include "IS_LuzControl.h"

#include "Constants.h"
#include "Everything.h"

namespace st
{
//private
	void IS_LuzControl::writeStateToPin()
	{
		digitalWrite(m_nOutputPin, m_bInvertLogic ? !m_bCurrentState : m_bCurrentState);
	}

//public
	//constructor
	IS_LuzControl::IS_LuzControl(const __FlashStringHelper *name, byte pinInput, bool iState, bool pullup, byte pinOutput, bool startingState, bool invertLogic) :
		InterruptSensor(name, pinInput, iState, pullup),  //use parent class' constructor
		m_bCurrentState(startingState),

		m_bInvertLogic(invertLogic)		
		{
			setOutputPin(pinOutput);
		}
					
	//destructor
	IS_LuzControl::~IS_LuzControl()
	{
	}
	
	void IS_LuzControl::init()
	{
		//get current status of contact sensor by calling parent class's init() routine - no need to duplicate it here!
		InterruptSensor::init();
	}

	//update function 
	void IS_LuzControl::update()
	{
		
		//check to see if input pin has changed state
		InterruptSensor::update();
	}

	void IS_LuzControl::beSmart(const String &str)
	{
		String s=str.substring(str.indexOf(' ')+1);
		
		if (st::Executor::debug) {
			Serial.print(F("EX_Switch::beSmart s = "));
			Serial.println(s);
		}
		
		if(s==F("on"))
		{
			m_bCurrentState=HIGH;
		}
		else if(s==F("off"))
		{
			m_bCurrentState=LOW;
		}
		
		writeStateToPin();
		
		Everything::sendSmartString(getName() + " " + (m_bCurrentState == HIGH?F("on"):F("off")));
		
	}


	//called periodically by Everything class to ensure ST Cloud is kept consistent with the state of the contact sensor
	void IS_LuzControl::refresh()
	{
		Everything::sendSmartString(getName() + " " + (m_bCurrentState == HIGH?F("on"):F("off")));
	}

	void IS_LuzControl::runInterrupt()
	{
		//add the "closed" event to the buffer to be queued for transfer to the ST Shield
		if(m_bCurrentState == LOW)
		{
			m_bCurrentState=HIGH;
			writeStateToPin();
		//	Serial.println(m_bCurrentState);
		}
		else
		{
			m_bCurrentState=LOW;
			writeStateToPin();
		//	Serial.println(m_bCurrentState);
		}

		Everything::sendSmartString(getName() + " " + (m_bCurrentState == HIGH?F("on"):F("off")));	
	}
	
	void IS_LuzControl::runInterruptEnded()
	{
		//add the "open" event to the buffer to be queued for transfer to the ST Shield
		if(m_bCurrentState == LOW)
		{
			m_bCurrentState=HIGH;
			writeStateToPin();
		//	Serial.println(m_bCurrentState);
		}
		else
		{
			m_bCurrentState=LOW;
			writeStateToPin();
		//	Serial.println(m_bCurrentState);
		}

		Everything::sendSmartString(getName() + " " + (m_bCurrentState == HIGH?F("on"):F("off")));
	}

	void IS_LuzControl::setOutputPin(byte pin)
	{
		m_nOutputPin = pin;
		pinMode(m_nOutputPin, OUTPUT);
		writeStateToPin();
	}
}

> IS_LuzControl.h

#ifndef ST_IS_LUZCONTROL_H
#define ST_IS_LUZCONTROL_H

#include "InterruptSensor.h"

namespace st
{
	class IS_LuzControl : public InterruptSensor
	{
		private:
			//inherits everything necessary from parent InterruptSensor Class for the Contact Sensor

			//following are for the digital output
			bool m_bCurrentState;	//HIGH or LOW
			bool m_bInvertLogic;	//determines whether the Arduino Digital Output should use inverted logic
			byte m_nOutputPin;		//Arduino Pin used as a Digital Output for the switch - often connected to a relay or an LED

			void writeStateToPin();	//function to update the Arduino Digital Output Pin

			
		public:
			//constructor - called in your sketch's global variable declaration section
			IS_LuzControl(const __FlashStringHelper *name, byte pinInput, bool iState, bool pullup, byte pinOutput, bool startingState, bool invertLogic);
			
			//destructor
			virtual ~IS_LuzControl();
			
			//initialization function
			virtual void init();

			//update function 
			void update();

			//SmartThings Shield data handler (receives command to turn "on" or "off" the switch (digital output)
			virtual void beSmart(const String &str);

			//called periodically by Everything class to ensure ST Cloud is kept consistent with the state of the contact sensor
			virtual void refresh();

			//handles what to do when interrupt is triggered 
			virtual void runInterrupt();

			//handles what to do when interrupt is ended 
			virtual void runInterruptEnded();

			//gets
			virtual byte getPin() const { return m_nOutputPin; }

			//sets
			virtual void setOutputPin(byte pin);
	};
}


#endif

I will take a closer look at your code shortly, once I finish up some other work on the project.

I do want to congratulate you on being the first community member in over two years to take the initiative to add a new class to ST_Anything! This is exactly what why son and I envisioned years ago!

Thank you!

I promise I’ll take a look soon!

If anyone can help, I would appreciate it, if it is too much to do on here I understand.
I tried to connect the esp01 to the mega and get things working with this. I failed miserably. I looked up what I needed to do and got the esp wired up to the mega with voltage dividers, uploaded the code through arduino and got nothing with the esp and wifi. I have spent days trying to get the esp to do anything. I have tried to update the firmware connecting it to a ftdi. Initially i had no luck with that. Finally i was able to flash the latest firmware (no idea if i did it right) and it took, but i cannot send any AT commands to it. I tried to upload simple wifi sketches to it and the only output i get from it is garbage. If anyone can help i would greatly appreciate it.

Hey thanks again for this…relay successfully triggers siren (alarm) when ST home monitoring is set to ‘Armed’ !!! Just want to do more stuff now!!! Addictive!!! Thank you thank you thank you!

1 Like