[RELEASE] ST_Anything - Arduino/ESP8266/ESP32

Without having any development experience myself, I picked up a handful of Adafruit Huzzah boards with the express intent of integrating them with my car and with some blinds I have.

For the car aspect, I’m not 100% sure how to make things happen the way I want, so I’ll posit my questions here.

I need a couple of inputs to monitor a few things, but those are less important than the outputs.

Is it possible for the ESP8266 to pulse an output for 100ms just like a momentary contact?
My goal is to integrate with my alarm system on my car directly (rather than by wiring in a remote control to the ESP), and I have a couple of status wires/trigger wires in the alarm module that the ESP can trigger.

Specific momentary pins: Lock, Unlock, Trunk release, all three separate wires, and the ESP will trigger either a SSR or Mechanical Relay board to control these. Additional options would be window roll up/down, triggered by two pins, one for up, one for down.
Two or three latched pins for various functions.
Two input pins, one for a sense wire for the remote start. This pin becomes active when the remote start is running. The remote start module has a wire that goes high when the car is running.

The alarm/remote start will handle all of the necessary safety features…

My wife and I have some “fun cars” that we drive during the summer. A lot of the time, we’ll ride together, and then I’ll keep the keys in my pocket and head to work in the daily driver or whatnot. She may need something from the car, and it’s locked and armed. So having the ability to see the status in SmartThings, tie the car into the home security system, etc would be phenomenal.

My logic tells me the Arduino side of things would be super simple. I just don’t have any dev experience.
Can anyone help?

@Synthesis,

This is an interesting project. I think it would be the first time I have heard of an Arduino / Car / SmartThings integration.

My ST_Anything Arduino library supports what I call “Timed Relay” digital outputs. This is implemented in my S_TimedRelay C++ class. Below is a portion of the comments section of the corresponding .h and .cpp files which explains the list of constructor arguments. 100ms would be easy to implement.

Additionally, ST_Anything supports a standard Switch (normal on/off digital outputs, not timed) as well as Contact Sensor (for simple open/closed digital inputs.)

One area of concern that I just thought of though… Since the car will come and go frequently, I am not sure how well ST_Anything will handle the disconnect/reconnect logic. It was never an issue with the old ThingShield. Since you’d be using WiFi, I am worried that the system may not auto-reconnect. Something to add to my list to test…

//******************************************************************************************
//  File: S_TimedRelay.h
//  Authors: Dan G Ogorchock
//
//  Summary:  S_TimedRelay is a class which implements the SmartThings "Relay" device capability.  It features
//			  an automatic-turn-off time delay for a relay to emulate a button press.
//
//			  It inherits from the st::Sensor class and clones much from the st::Executor Class
//
//			  Create an instance of this class in your sketch's global variable section
//			  For Example:  st::S_TimedRelay sensor1("relay", PIN_RELAY, LOW, true, 500, 500, 3);
//
//			  st::S_TimedRelay() constructor requires the following arguments
//				- String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name
//				- byte pinOutput - REQUIRED - the Arduino Pin to be used as a digital output
//				- bool startingState - REQUIRED - the value desired for the initial state of the switch.  LOW = "off", HIGH = "on"
//				- bool invertLogic - REQUIRED - determines whether the Arduino Digital Ouput should use inverted logic
//				- long onTime - REQUIRED - the number of milliseconds to keep the output on, DEFGAULTS to 1000 milliseconds
//				- long offTime - OPTIONAL - the number of milliseconds to keep the output off, DEFAULTS to 0
//				- intnumCycles - OPTIONAL - the number of times to repeat the on/off cycle, DEFAULTS to 1
1 Like

One area of concern that I just thought of though… Since the car will come and go frequently, I am not sure how well ST_Anything will handle the disconnect/reconnect logic. It was never an issue with the old ThingShield. Since you’d be using WiFi, I am worried that the system may not auto-reconnect. Something to add to my list to test…

That brings to light another question: How would the ST_Anything device do in an environment in which it moves between SSIDs? Example: If the car arrives at work, can it connect to a second network and become available for access if there were a ST hub there as well? This way I could time remote start functionality on days colder than X through the ST interface at both locations.

Finally, the unit could be wired to turn off whenever the car itself is running, and then turn on when the key is shut off.
This would enable it to go through the reconnect process at each site, connecting to whichever WiFi happened to be within range that it was programmed for. This may resolve the connectivity issue you mentioned, but would remove the ability to read the status of the car and whether it were running or not when the remote start process caused it to turn off.

Hmmmm… I think your on to something there. Powering on the ESP8266 each time it arrives at a destination would cause it to connect to the WiFi. Currently, the software does not support more than 1 set of WiFi credentials. One simple option would be for you use the same WiFi SSID and password at both locations. Also, not sure how great the WiFi range of the tiny ESP8266 antenna is going to be inside a big metal car. Distance/range may be an issue.

You could add a WiFi cellular hotspot to your car. Then the ESP8266 would always have a cellular internet connection. Not necessarily free, although FreedomPop might be a very low cost option.

Fair enough. At both work and home, the car is less than 100 feet from an available access point. I’m pretty good with cars/tools, so the fun cars have the perfect spot for me to mount this directly under the top of the dash, and would get GREAT signal. The daily driver has an overhead console that extends to the glass in front. I could mount there as well.

@Mickw please check out:

1 Like

Thanks Eric I’ll be able to get the show on the road brilliant

Eric you have just made someone very happy cannot thankyou enough this is a great start to my automation project ,installed as you discribe working a charm 2 relays and an overall switch brilliant :grin:

1 Like

Hi. Having some dificulties flashing the sonoff dual. Can you add some pictures and how to. Found diferent explanations on the web how go get it in flashing mode.
Thanks

Is there any way to get feedback on an output ?

I have the esp 01 working well with one input and an output, the input will change state and also change the output but if you look under smartthings the state remains the same.

I’m using the esp01 for a light “relay” and the input for manual control of the light locally, I think the handler is only setup to poll these >>> PS_Illuminace, PS_Water, PS_TemperatureHumidity.

It would be nice to know the state of the relay or switch if it was controlled locally and to know if the output was actually on.

Yes, all device state changes are automatically updated to the ST Cloud, assuming you don’t change things manually in the Arduino code without having ST_Anything do it for you.

Please post your code and I’ll take a look. Make sure you highlight it and click the “pre-formatted text” button in the menu bar. This prevents the code from getting screeed up.

hrmm the code still went full screen

well i tried in the forum but it still went 4 pages, i’ll just send you the
.ino here.

Thanks

Adam

@hwac I have sent you a Private Message…

Wow - firstly, Dan, what a spectacular job you’ve done here.

I have an old Alarm system. 5 Doors, 3 PIR, 2 Panic buttons and 2 sirens - one indoor, and an old bell outdoor.

Here is a picture of the alarm control board.

I have a sneaky feeling that your ST_Anything might well be the right platform for me to convert this old system into a SmartThings Home Monitor Alarm. I could technically do cool things like “when armed, on door open, take CCTV recording” etc.

My first (1) question is, am I at the right place? Can ST_Anything work for this use-case?

If yes. I assume I’ll need lots of inputs, possibly two pins for each alarm device, so my second question (2) is the Mega with a WiFi board is my only option here? [as it has 50 or so pins?]

I’m building a shopping list of things I’d need to buy - bearing in mind I’ve never done this before and own nothing relating to Arduino - (3) If it’s no trouble, can you confirm or add/remove items from my list please?

Then I’ll need some software, Arduino IDE, your libraries, and then the ST_Anything_WiFiEsp.ino sketch. I’ll follow your readme for installation instructions. Hopefully it’s noob proof :grin:

I suppose, once all that is bought and installed, (4) I just pull off the wires from the Alarm PCB and pop them into the Mega [they are labelled]? Surely there is more to it?

I’m also worried about power, reading this thread shows things like 3.3v and 12v etc. Here is a picture of the battery and the mains power incoming -

(4a) Would you be able to expand more on how to bring the two together, old Alarm PCB and Mega?

Let me know if I’ve taken this too far down into noob basics, or if this has already been discussed over and over before [though I couldn’t find anything - wrong search terms?]

Cheers.

1 Like

You might want to take a look at this.

I used it to replace my DSC alarm system. I’ve got 3 doors, 3 window zones, and a siren hooked up to it. I hope to eventually tie in my smoke detectors. You can use additional ESP8266s if you need more I/O pins. (I think 6 to 7 is the most you can connect to a single board.)

1 Like

@Vyker

Yes, you can very easily use the ST_Anything library to integrate an old alarm panel with SmartThings. Are you planning on continuing to use the old alarm panel, or just replace it it completely and use SmartThings instead? Your wiring plans will depend greatly on which approach you are planning to use. It is much simpler if you simply disconnect the sensors from the old panel and just connect them to the Arduino MEGA or NodeMCU ESP8266 board.

I am actually working on a new and improved version of ST_Anything which greatly simplifies the installation and setup of the system. I will be posting more information here in this thread very soon.

By far, the easiest hardware to integrate is a NodeMCU ESP8266 board ( http://amzn.eu/4iF1bCy). This is an all-in-one solution that includes a microprocessor, WiFi, and general purpose I/O pins. Using an Arduino MEGA is a bit more complicated, unless you can use hard-wired Ethernet via a W5100 shield (http://amzn.eu/ifDnNI3.) You can also use an Arduino MEGA with an ESP-01 WiFi board (like the parts you have linked in your message), but it takes a lot more wiring (not the best first choice for a noob, but it can be done.)

As for power, you’re going to have to decide which pieces of the old system are staying and what is leaving. Personally, I would probably start simple with a “mains-powered” USB power supply. This can be used to power either an Arduino MEGA or a NodeMCU ESP8266 board. Best to get everything up and running on the work-bench and then figure out exactly how to integrate with the old sensor wiring.

You do not need two pins per sensor. You really only need one pin per sensor, with the other wire from each sensor all attached to a common ground pin. The door/windows sensors are pretty trivial. The PIR sensors from the old panel will probably need to be powered independently, as the new microcontroller will most likely not be able to power them. You’ll also need to figure out the power requirements for the sirens, which will most likely need relays to activate them. None of this is too difficult, but it does take some basic electrical skills with a voltmeter to figure out it all out.

Hope this helps get you started. I am happy to help out where possible. Again, stay tuned for my upcoming release which makes most of the setup semi-automagic/plug-n-play.

Dan

3 Likes

Hi ogiewon,

It would be great to see basic on/off/dim levels/RGB setting, as well as some simple “scenes” for neopixels. I’ve seen some apps that have a color selecting wheel where you can scroll through any possible color. Not sure how do-able it is, but I think having a memory functionality to the color setting would be helpful between power on/off of the ESP8266 board, or at least on/off of the LEDs themselves. Perhaps a fade between selections as well, rather than stark, immediate color or dim level changes? Just some thoughts!

It would also be great to have a setting that will slowly fade each LED randomly through several color options. For example, you could select a few different shades of blue and the strip would randomly fade each LED through the different blues for a bit of a random wave effect? Not linear down the strip, but random fades… I’ve seen some examples and it looks pretty relaxing.

The Adafruit neopixel library and FastLED library also have some interesting effects. I think all of these could be as simple as writing the effect code and storing it on the ESP8266, and then use Smartthings to trigger a call to the ESP8266 and run the effect with the chosen colors.

I would be happy to find some of these code sections if it would help! I would really love to see neopixel support on ESP8266 get implemented to Smartthings, even on/off/dim/RGB color for now. The possibilities are endless for home lighting accents.

Thanks for all of your work on this!

Apologies if this is a dumb question, but when creating a virtual device, what is entered into “device network id”?

Any unique string is fine.

I have a new version coming out very soon that eliminates the need for virtual devices and the multiplexer application!

1 Like