Announcing the "ST_Anything" Arduino/ThingShield Project

Sounds great and exactly what I needed.

You have convinced me to use an Arduino instead of a R-Pi so thanks. My alarm panel is still operational and I want to keep using the main functionality since I need a monitored service to get my insurance discount. So I think the second example is what I need. I will dig in and write again if I run into problems. One complication is my alarm documentation says that an open circuit or a short circuit will set off the alarm so I can’t remove the lines coming from the sensors. My tap has to run in parallel with high ohmage resistors to avoid altering the primary voltage path. I think I have that right.

I only have doors and windows plus a bunch of other z-wave devices that I bought for lights and motion sensing. My alarm system uses window break sound sensors for windows that don’t open, not motion, so I will just ignore those. I will use the door sensors and the window sensors for the windows that open.

Thanks again - this is going to be very helpful.

1 Like

It was mentioned earlier in this thread that it might be possible to get the ST_Anything library to work without the requirement for a SmartShield.
Is this still the case?
If so, would it be possible to get a pointer as to which files would need to be changed?

I have an XBee shield and have been experimenting with getting it communicating with the SmartHub and have had some success, however being able to use the ST_Anything library would make things a lot easier!


Within the ST_Anything library, you will find a file named Constants.h. This file is designed to be modified by the end user as needed to adjust various settings with the overall library. In particular, based on your request, you can simply uncomment the following line of code, which will prevent the library from needing the ThingShield.

//#define DISABLE_SMARTTHINGS	//If uncommented, will disable all ST Shield Library calls (e.g. you want to use this library without SmartThings...)

This will let you run the ST_Anything library, but you’re going to have to get into some of the more hidden features of ST_Anything to replace the ThingShield calls with your XBee shield calls. I believe most of the ThingShield calls are contained with the Everything class (Everything.h and Everything.cpp). So if you can modify these two files, and possibly Constants.h, you should be able to reuse the rest of the library.


Awesome, thanks for the pointers!
Hopefully I’ll be able to get something up and running without too many headaches.
Thanks once again.

Wauw, absolute amazing work you did here guys, I’m really impressed
I’m a civil engineer masterstudent from Belgium and I always found the google nest, smartthings,… systems way too expensive for what they only can do. One sensor for $40, seriously who buys that? That’s good to automate 1 light at your frontdoor that lights on when it’s dark, but if you want to do more then that it becomes insanely expensive.
I already played a bit with my arduino before stumbling on this post, I’m building my own automation, starting from my room, but i want to integrate it for my whole house
I will simply explain my idea:

1 box with: Temp + humidity + illuminance + motion sensor
Every room should eventually have 1 box, and 1 on the outside of the house (arduino material doesn’t suit for outside sensors i guess…)
This “input-boxes” can be connected to a central system that calculates all the input (at first wired: easier, later wireless)
Other inputs (not in box) are contact sensors on doors/windows,…

These inputs can trigger a lot of outputs and in this way we can create automated scenes for example:

  1. Servo motor that can open/close 1 window per room
    When does it need to open?
    When the temperature is too high or the humidity is too high, and there is no one in the room.
    If someone enters the room and the temperature/humidity is already better, it can close again so there’s no wind
    The outside humidity sensor makes sure that the window doesn’t open when it rains
    PS: automated opened window only a small gap and on 1st floor, so burglaring isn’t an issue
    To open this window manually there needs to be a second button to override this scene and open/close manually

  2. I’d like to set the hour of leaving my bed on the central system, for example: 07:45 am in the morning
    The systems knows i’m not a morning person so at 07:30 the curtain slowly starts to open
    This is done by a servo motor that pulls a double wire connected to the curtain top, to close it the servo turns the other way around and the curtains close
    The music starts slowly on 7:30 too and by 7:45 the music is loud and the curtains are open
    7:45 a buzzer start, that will only stop when my feet hit the pressure sensor on the floor next to my bed

Is it possible to do with ST_anything or am I dreaming?
I’ve read a lot about your input sensors that can communicate with smartthings, hey that’s amazing so my input side could really work in this system
But is it possible to steer my output servo’s,… too with ST? In this way ST needs to recognize my window servo/alarm clock/curtain servo/… as an output, like for example a philips hue bulb

I’m really exited about getting my project from the ground
I will exchange my arduino uno for the arduino mega and buy me the shield
Can someone tell me if I can try it with ST, or better just go dreaming along and buy me all the expensive inputs and outputs?

Thanks a lot


Yes, you can most likely accomplish everything you’ve mentioned using SmartThings and the ThingShield with an Arduino Mega 2560. You’ll need to extend the ST_Anything library by adding your own classes to support things like servo motors. Let me know if you need any help understanding the design on the library and supporting sensor/device classes.

If you want to try an even less expensive solution, check out one of my other projects below that shows you how to hack a Cree LED lightbulb for use with an Arduino. Note - this is a one-way communications solution - ST to the Arduino. This would be good for devices that just need to be told what to do, like a motor.

Have fun with your project!

1 Like

I built a bypass damper for my HVAC system using an Arduino Mega, ThingShield, and a Motor Shield (Adafruit). The shield can drive steppers or servos. It works great.

Got mine working today…

only tricky part was building the circuit to drive a transistor as an on/off switch when voltage of my alarm door sensors flips between 6 and 12 volts. Tapping in 100K and 10K resistors and using a simple npn transistor did the trick since the 10 to 1 voltage drop made the 6 volts go to 0.6 which won’t trigger the transistor and 12 goes to 1.2 which does trigger the transistor. My electric circuit theory was a bit rusty so figuring this out took me way longer than it should have. Here’s a pic of my circuit. Still need to box it up nicely but the ST device using ST anything works flawlessly. Super nice work @ogiewon Dan.



Nice work. Thanks for sharing. I am sure others may find your integration method useful.


I’m taking the leap into Arduino land. I’m moving into a a home with a preexisting security system consisting of contact sensors and motion sensors. Here is what i hope to accomplish.

Phase 1
I hope to piggyback on the existing contact sensors in doors/windows adding them as (virtual) 'Things" into my SmartThings environment while also leaving them intact with the current system.

After reading a ton of forums I believe that I can accomplish this with a Arduino Mega and a SmartThings Shield with this Sketch and following all of this fun ReadMe supplemented by this post on Virtual devices

The part I’m not totally sure on is splicing the wires from the existing security system into the Arduino. I haven’t gotten my filthy hands on the existing system but a cursory glance looks that each contact sensor has two wires and is the normal magnetic kind. I’m hoping the voltage drop is enough so I wont have to do any fancy breadbox work. From what I have read it sounds like I should splice a wire off the existing system’s contacts onto one of the boards pins and repeat for all the sensors.

Now the questions.

Do I need to splice the second wire from the existing sensors? I get the feeling from this post that I need to hook something to the ground on the Arduino board but I’m unsure if I need to do this for multiple sensors, just one, or at all.

I’m assuming that I only need the ST_Anything_Doors_Windows Sketch with the corresponding libraries to accomplish this task. Is that correct?

I’m going to screw up the coding part of the project as my coding knowledge is only slightly better than the average person. Not really a question just a forewarning of the impending broken code i may post.

Phase 2

If I somehow accomplish Phase one and the stability/Maintenance/Kludge of phase one doesn’t drive me insane I’ll process to complicate everything by adding the preexisting motion detectors to the mix.

I think the biggest concern is how much voltage does the existing system generate. The mega wants to work at around 5 volts. If you get above that, it might work, but it might fry the mega (either right away or over time).

I’m not sure what the upper limit is (Anyone?), but you may need to deal with that first.

If the voltage isn’t an issue, then I would think you would just need to tie ground on the mega into ground on the alarm and then tie all the non-grounds into pins on the mega.

You’ll also want to read this post about the settings you want to use if the alarm is generatIng the current.

This is why I used a transistor as a switch. That way the Arduino always gets 5volts and the alarm voltage is used only to drive the transistor via the base pin to switch the Arduino provided 5 Volts on and off by means of the cutoff voltage behavior of all transistors at 0.7 volts.

I will draw out my circuit when I have some time.

1 Like

Right. He was hoping not to use a breadboard. I think it would be great to see your circuit.



It looks like you have a pretty solid plan. Yes, using ST_Anything_Doors_Windows should provide you with an excellent starting point. Be sure to get everything up and running in your lab before trying to integrate with the existing alarm system.

Some basic ST_Anything guidelines:

  • 99.99% of your Arduino code modifications should be within the ST_Anything_Doors_Windows.ino sketch. You should not need to modify any of the library files (there are many!) One exception to this rule is the “Constants.h” file which has user tweakable settings.

  • Please read the comments at the top of the IS_Contact.h file, found within the ST_Anything library. This will explain what all of the arguments are that you can modify within your Arduino sketch’s setup() routine when the various doors and windows objects are defined. Of particular note are the options to Invert Logic and whether or not to use the Internal Pullup resistor. Here is a sample of the comments:

    // st::IS_Contact() constructor requires the following arguments
    // - String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name
    // - byte pin - REQUIRED - the Arduino Pin to be used as a digital input
    // - bool iState - REQUIRED - LOW or HIGH - determines which value indicates the interrupt is true
    // - bool internalPullup - OPTIONAL - true == INTERNAL_PULLUP
    // - long numReqCounts - OPTIONAL - number of counts before changing state of input (prevent false alarms)

  • Do NOT use the internal pullup resistor feature if you want to run both the old alarm system and the new one in parallel. The internal pullup resistor feature is designed to supply +5 volts on the digital input pin, thus allow a very simple wiring circuit (i.e. Arduino pin --> Reed Switch --> Arduino Gnd.) When running two systems in parallel, the Arduino will be trying to force its +5V on the old alarm system’s inputs. This is a bad idea.

Hopefully Ken Washington’s (@kewashi) wiring diagram will help to explain some of the wiring circuitry. If you’re not familiar with the wiring, it may be best to try to find a buddy who is good with TTL level circuits to help out. You’re going to need to figure out what voltage the old alarm system is using. If it happens to be 5 volts DC (TTL) then you’re in luck! If not, you’ve going to have to build voltage level shifting circuitry, which is what Ken has done.

If the old alarm does use 5vdc wiring, you then need to figure out which side of the existing reed switch wiring you need to tap into before connecting it to the Arduino Digital Input pin. You’re also going to have to figure out how to get both the old alarm system and the new Arduino to have the same reference voltage. Usually, this is done by tying the Arduino ground to the old alarm system’s ground. Do NOT also tie the Arduino +5 to the old Alarm panel’s +5. That would be a very bad idea!

This can be tricky, which is why having someone around which circuits experience in your house to help figure this out, is really the best way to determine your wiring strategy.


1 Like

Got a quick look at the security board tonight. It looks like its 12v throughout so me and ken are going to be good buddies.

1 Like

The Atmel Mega2560 data sheet shows the I/O pin current limit is 40mA. I believe this is true for all the Atmel microcontrollers. The I/O pins have internal protection diodes rated for 40mA. It only takes .6 x Vcc (5v) = 3v @ 10uA to see a logic HIGH.

I have used 10K resistors with 12V systems for years without any issues. 12v/10K= 1.2mA. It will actually be less, more like (12v-5.5)/10K=.65mA or 650uA.

Just one resistor in series to limit the current is needed. No voltage divider or transistor needed.

Here is the link to the Atmel app note…


I’ve had great fun as a newbie experimenting with your work, and I have some questions about ‘RCSwitch’. Is this sketch/smartapp/device type for the purpose of controlling multiple outputs, such as relays, with an Arduino SmartThings Shield? The .ino file wouldn’t compile for me until I inserted a value in the constructor for ‘unsigned int pulseLength’. Not knowing what that represents I arbitrarily put a value of 25. So should I define outputs for my relay pins, or am I off-base in my understanding of what this code is for?


Hate to answer myself but in reading more I think I have got the picture now…

1 Like


Glad you’re having fun. The RCSwitch example is to be used specifically with a 433MHz transmitter to control Radio Control (RC) devices. If you are just trying to control relays from the Arduino, via SmartThings, please refer to my ST_Anything_Relays example code. Please read the ReadMe on the GitHub repository for basic setup instructions. You’ll also need to use the corresponding Groovy code for the Arduino “Device Handler”, the Multiplexer “Smart App”, and my virtual switch “Device Handler”. Together, they make a matched set of code.

Please read through this discussion where I helped a user by creating the ST_Anything_Relays example:

Also. here is the discussion I posted about the ST_Anything_RCSwitch project you mentioned, in case you’re curious.