Announcing the "ST_Anything" Arduino/ThingShield Project

@ogiewon,

I’m concerned that ST is not going to get Smart Things Shields back in stock. Is there any chance at all that what you have developed here could be reworked to use Xbee modules to talk to ST?

-Todd

1 Like

Todd,

I don’t see why not. The ST_Anything library was actually designed to be somewhat portable and to not necessarily require a ST ThingShield. Only a few files would need to change in order to communicate with something else.

Do you have an example of someone already using an Xbee module to talk to SmartThings?

Another alternative I’ve been considering is using a Raspberry Pi to run ST_Anything. I have yet to figure out how to properly integrate it with ST to allow unsolicited updates from the Pi to the Hub to the ST Cloud… If someone had that working, a $35 Raspberry Pi 2 would be a very powerful platform ( although not battery friendly.)

1 Like

The most often cited Xbee example is the propeller project.

If you are considering Pi, you might also consider looking at the Yun, which is basically an Uno with a Linux side built-in. The Pi and the Yun would both need to talk to ST over the network, rather than Zigbee.

I played around trying to get a yun to talk to ST, but I was unable to find a decent example of a similar project to work from and then I decided to use a thing shield and had started to get it to work when you posted this and made what I was working on my unnecessary!

I have two thing shields and am using them for sensors in different parts of my house. I’d love to get a couple more, but they are out of stock. I find myself wanting to recommend arduino solutions to people here, but without the shields it isn’t feasible.

Xbee support would ensure that your excellent library continues to get out to great use!

Todd

1 Like

@Todd_Whitehead I’m in the same boat waiting for a shield. I’ve got some assurances that they’re coming soon but we shall see.

If there’s a way to connect another device to ST Hub and ecosystem without ST Shield will be very nice. And it will be better if we can spend less then 35 USD

Now I’m still wait for ST Shield to be available.
Is there any smaller or cheaper arduino that compatible with ST Shield ?

Looks like the shield is back in stock

1 Like

Yes, they are and bought a couple of them. Will be nice to join the arduino builders and have fun.

1 Like

Yup finally ordered mine, so the fun shall soon ensue… or rage…

1 Like

@ogiewon: First let me say that this project is great. I will reduce start-up time and reduce complexity to use the ThingShield. (Also as a software engineer with 20+ years experience, I will observe the code is very well done.)
While waiting for the ThingShield’s to get back in stock I looked at @DavidCreed reference to http://www.instructables.com/id/Uber-Home-Automation, and ended buying a few inexpensive senors - Smoke, Fire, Distance, and a much less expensive Temperature sensor.
Have you considered adding additional sensors to your project? (I could help by providing the Arduino code and then testing or even completely coding the new sensor so that they look exactly like your code.)

@Garnet - users adding their own sensors is exactly what we hoped ST_Anything would inspire and enable others to do. Please feel free to create your own header and cpp files to implement other sensors. We’d be happy to incorporate them into the library for everyone to enjoy.

First of all, this project looks awesome!

I have been having issues though with compiling the code. From your source and multiple other projects I have found online. I seem to keep getting build errors.

C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp: In member function 'void SmartThings::_shieldGetNetworkInfo()':
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:272: error: invalid conversion from 'const __FlashStringHelper*' to 'char'
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:272: error:   initializing argument 1 of 'long int SmartThings::st_print(char)'
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp: In member function 'void SmartThings::send(String)':
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:375: error: invalid conversion from 'const __FlashStringHelper*' to 'char'
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:375: error:   initializing argument 1 of 'long int SmartThings::st_print(char)'
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:396: error: invalid conversion from 'const __FlashStringHelper*' to 'char'
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:396: error:   initializing argument 1 of 'long int SmartThings::st_print(char)'
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp: In member function 'void SmartThings::shieldSetLED(uint8_t, uint8_t, uint8_t)':
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:411: error: invalid conversion from 'const __FlashStringHelper*' to 'char'
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:411: error:   initializing argument 1 of 'long int SmartThings::st_print(char)'
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:417: error: invalid conversion from 'const __FlashStringHelper*' to 'char'
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:417: error:   initializing argument 1 of 'long int SmartThings::st_print(char)'
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp: In member function 'void SmartThings::shieldFindNetwork()':
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:468: error: invalid conversion from 'const __FlashStringHelper*' to 'char'
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:468: error:   initializing argument 1 of 'long int SmartThings::st_print(char)'
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp: In member function 'void SmartThings::shieldLeaveNetwork()':
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:480: error: invalid conversion from 'const __FlashStringHelper*' to 'char'
C:\Program Files (x86)\Arduino\libraries\SmartThings\SmartThings.cpp:480: error:   initializing argument 1 of 'long int SmartThings::st_print(char)'

Do you have any suggestions as to where to start to fix these?

@akraintz2014 - At quick glance, it appears that the compiler is not happy about the F() macros we placed around the code to save RAM. Is your Arduino compiler completely up to date? I think I recall reading that the compiler’s support for the F() macros has changed considerably over time.

This is great work, and I’m going to use it in my next Arduino project, which is to integrate my wired door sensors with SmartThings. Since your code already covers that, it should take no time, I expect.

I have a couple of questions, though:

  1. It looks like the logic in your InterruptSensor class assumes that the sensor switches are normally open, i.e. no current when the door is closed, is that correct, or did I misunderstand? The “polarity” of interrupt state would have to be reversed for a normally closed switch, which ours are.

  2. In order to see each door as a separate tile under ‘Things,’ I should make use of your virtual device types and set up additional virtual devices, is that correct? I want to be able to program different alerts and actions for different doors.

Thanks,

Niklas

Niklas,

The answer to your first question is an easy one. The third argument of the st::IS_Contact class is whether to use HIGH or LOW to indicate whether the contact sensor is open or closed. See the comments in the header section of any of the ST_Anything library’s .cpp or .h files to see the options for each class’ constructor (which is called in the main Arduino Sketch.) For example, here are the current options for a st::IS_Contact sensor class:

// 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

So just vary the third argument between HIGH and LOW to change whether you’re using a normally open or closed contact sensor.

In response to your second question - Yes, you’ll need to use the Virtual Contact Sensor Device Type, along with the DOORS Multiplexer SmartApp. The SmartApp simply attaches each Virtual Contact Sensor to the Arduino’s custom attributes for each door’s sensor. Start with just the Arduino Code + the Arduino Device Type. Once you get that working properly, then add the Virtual Contact Sensors Devices and the Multiplexer SmartApp. You’ll need to do a little bit of customizing of the Arduino Device Type and the SmartApp based on the number of door/window sensors you have. You may also want to remove the Garage Door code.

Have fun!!!

Dan

Yup, it’s working just fine. The thing that took the longest time was to figure out what was what in the Groovy code; I also had trouble with my motion sensor, which kept repeating messages (dozens of time for a single event), so I had to model it as a contact sensor at the Arduino and then remap it on the virtual device.

I’m going to try to do another version of the sketch without your library just for the learning experience, now that I have what I need already working.

Thanks for sharing,

Niklas

1 Like

This is my first time connecting to the arduino with the arduino st sheild and when I go to compile I get the following error. I believe I downloaded all the correct libraries.

Can someone help me, please.

Arduino: 1.6.1 (Windows 7), Board: “Arduino Uno”

Arduino_8_Zone_Irrigation_Controller.ino:215:25: fatal error: SmartThings.h: No such file or directory

compilation terminated.

Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

That error indicates that the SmartThings Arduino library is missing.

Are you attempting to use my ST_Anything project as a starting point? Or are you starting with the examples provided by SmartThings?

Yes, just trying different ones but starting off with ST_Anything

Did you restart the Arduino IDE after copying in all of the new libraries from my Github repository?

Also, try compiling ST_Anything.ino with the rest of the libraries instead of “Arduino_8_Zone_Irrigation_Controller.ino”

ST_Anything.ino will definitely compile and run. What model Arduino are you using? Have you followed all of the steps in the ReadMe at the GitHub repo?

Okay, I was able to compile and upload to the Arduino. Is the led on the at shield suppose to light up or anything?