ST_Anything: 433Mhz RF Devices + Arduino + ThingShield


I have noticed a few folks asking questions about integrating 433Mhz RF devices with SmartThings. I have a set of 3 ETEKCITY Remote Outlet Switches - ZAP 3F is the model. The SKU is 10-BHC9938U-3 and I purchased them on sale a while back from Newegg. @keithcroshaw had asked me a while back about integrating the Arduino “RCSwitch” library with my ST_Anything library. I am happy to share with everyone the results of this union between an Arduino, a ST Thingshield, and some inexpensive 433MHz RF components.

For the basic understanding of the Arduino ST_Anything library my son and I wrote a few months back, please visit this post. This should get you started:

I have updated my Github repository to include the EX_RCSwitch.cpp and .h files at The EX_RCSwitch (Executor, Radio Controlled Switch class) implements the necessary features/libraries needed to comminucate with the 433MHz RC Transmitter (I used one just like this, however I bought mine via eBay from China.)

I have also added a new RCSwitch Multiplexer which handles three virtual switches to one Arduino. So, there is now a complete matched set of code (i.e. RCSwitch Arduino sketch/library, RCSwitch Device Type for the Arduino ThingShield, RCSwitch Multiplexer Smart App, and Virtual Switch Device Type.)

This should be everything you need to get things up and running.

  1. Load the ST_Anything_RCSwitch.ino sketch on your Arduino (which I assume you have figured out how to wire to the ThingShield and the 433MHz Transmitter already. See my original thread for ST_Anything I linked above for detailed instructions.)
  2. Then install the ST_Anything_RCSwitch.device.groovy Device Type in the ST IDE to replace whatever Device Type you have already for the Arduino ThingShield.
  3. Using the ST IDE, create three Virtual Switches using my VirtualSwitch.device.groovy Device Type
  4. Finally, tie everything together using my ST_Anything_RCSwitch_Multiplexer.smartapp.groovy SmartApp. The SmartApp will accept the Arduino and the three Virtual Switches as input devices. This allows you to control each “Switch” independently from other traditional SmartApps/Hello Home phrases.

I realize that this example is specific to my ETEKCITY ZAP 3F RF outlets, however it should server as a great starting point for anyone who wants to integrate 433MHz RF devices to SmartThings. Once you determine the correct RF Codes needed by the RCSwitch library, just enter them into the Arduino Sketch in the following section of code:

  static st::EX_RCSwitch executor1(F("rcswitch1"), PIN_RCSWITCH, 5526835, 24, 5526844, 24, 174, 1, 15, LOW);
  static st::EX_RCSwitch executor2(F("rcswitch2"), PIN_RCSWITCH, 5526979, 24, 5526988, 24, 174, 1, 15, LOW);
  static st::EX_RCSwitch executor3(F("rcswitch3"), PIN_RCSWITCH, 5527299, 24, 5527308, 24, 174, 1, 15, LOW);

Refer to the comment section at the top of EX_RCSwitch.h for details of what each of the arguments above is used for. You WILL need to change come of these values for your specific 433MHz RF device.

//			  st::EX_RCSwitch() constructor requires the following arguments
//				- String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name
//				- byte transmitterPin - REQUIRED - the Arduino Pin to be used as a digital output for the RCSwitch object's transmitter pin
//				- unsigned long onCode - REQUIRED - the "on" code for RCSwitch send() command
//				- unsigned int onLength - REQUIRED - the "on" code's length for RCSwitch send() command
//				- unsigned long offCode - REQUIRED - the "off" code for RCSwitch send() command
//				- unsigned int offLength - REQUIRED - the "off" code's length for RCSwitch send() command
//				- unsigned int pulseLength - REQUIRED - the length of the RF pulse for RCSwitch send() command
//				- byte protocol - OPTIONAL - defaults to "1" - the protocol for RCSwitch send() command
//				- byte repeatTransmits - OPTIONAL - defaults to "15" - the number of repeated transmits for RCSwitch send() command
//				- bool startingState - OPTIONAL - the value desired for the initial state of the switch.  LOW = "off", HIGH = "on"

Also, an antenna on the transmitter will most likely be required to get some decent range.

To determine your device’s 433MHz codes, please use the example Arduino code contained within the RC-Switch library( - I have included it in my Github Repo as well.) You’ll need to hook up the 433MHz receiver to an Arduino so it can listen and learn the correct codes to turn on or off your device. Once you know these codes, try using them in one of the sample transmitter sketches to make sure you can make the Arduino control your device BEFORE you try to use my ST_Anything_RCSwitch example code. No need to complicate the troubleshooting until you know that you can get the device to be properly controlled by the Arduino in the first place.

Hope others find this useful!



@Dan will this work with Fan/light remotes from Honeywell or Hunter ? Love to automate my home fans

While compiling ST_Anything_RCSwitch.ino with Arduino Mega, I got this error message,
it seems the call missing value of pulseLength

What’s value of pulseLength I should input to this call?

Arduino: 1.6.3 (Windows 8.1), Board: “Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)”

ST_Anything_RCSwitch.ino: In function ‘void setup()’:

ST_Anything_RCSwitch.ino:93:90: error: no matching function for call to 'st::EX_RCSwitch::EX_RCSwitch(const __FlashStringHelper, int, long int, int, long int, int)’*

ST_Anything_RCSwitch.ino:93:90: note: candidates are:

In file included from ST_Anything_RCSwitch.ino:51:0:

C:\Users\TamTranMinh\Documents\arduino-1.6.3\libraries\ST_Anything_RCSwitch/EX_RCSwitch.h:54:4: note: st::EX_RCSwitch::EX_RCSwitch(const __FlashStringHelper, byte, long unsigned int, unsigned int, long unsigned int, unsigned int, unsigned int, byte, byte, bool)*

*EX_RCSwitch(const __FlashStringHelper *name, byte transmitterPin, unsigned long onCode, unsigned int onLength, unsigned long offCode, unsigned int offLength, unsigned int pulseLength, byte protocol = 1, byte repeatTransmits = 15, bool startingState = LOW);*

Please omit my previous post.
I’ve found default value for pulseLength (174) in your instruction.
Arduino now can receive command from ST, however when I turn on/off switches from ST mobile app, nothing happen.
(Notes: I have changed RF code with code of my remote, which I get them from RC-Switch example, and also can turn on/off using send example)
Below is details of serial monitor
Please advise

Everything: Free RAM = 6304
Everything: initDevices started
Everything: Free RAM = 6324
Everything: Sending: rcswitch1 off
Everything: Sending: rcswitch2 off
Everything: Sending: rcswitch3 off
Everything: initDevices ended
Everything: Free RAM = 6324
Everything: Received: rcswitch1 on
EX_RCSwitch::beSmart s = on
Everything: Sending: rcswitch1 on
Everything: Received: rcswitch1 off
EX_RCSwitch::beSmart s = off
Everything: Sending: rcswitch1 off
Everything: Received: rcswitch1 on
EX_RCSwitch::beSmart s = on

Your code seems to work ok.
I tested with 2nd arduino as RF receiver & RC-Switch receive-demo code.
Both actions - press on original remote or virtual switch from your code on ST mobile I’ve got the same result in 2nd arduino (the receiver).
It means with your code, arduino did send correct RF signal.
However, from original remote, light turn on; from arduino, nothing happen.

Is it the distance from arduino to the light causes this issue? It’s just < 2.4m (8 feet)


Did you finally get it to work? Distance can be an issue, especially if you have hooked up a small piece of wire to serve as an antenna to the transmitter module. Also, in addition to the basic on and off codes, you will need to determine the ideal PulseLength and RepeatTransmits parameters for reliable operation.


1 Like

I’d like to send the Smartthings cloud a device “on” command within the Arduino loop routine in ST_Anything when I receive a certain code from my RCSwitch receive function. I can confirm that I receive the code, however, I cannot send the command to the cloud. I tried both functions below but it won’t work:

sendSmartString(“rcswitch4 on”);
SmartThing.send(“rcswitch4 on”);

Your help is very much appreciated.


Have you tried using the following syntax within the Arduino loop() routine? Just be sure to only do it at a very slow pace, as the SMartThings Shield is not capable of keeping up with transmitting data to the ST cloud at a high data rate.

st::Everything::sendSmartString(“rcswitch4 on”);

I can’t test it right now, but I think the above syntax should work.

Dan (@ogiewon)

The below worked well:
String sc = “rcswitch4 on”; st::Everything::sendSmartString(sc);
Thank you so much.

1 Like

Hi Ogiewon! Thanks for this tutorial. Im having troubles in the first part, im still unable to sniff the RF Code with the RC Switch, it seems Im not the only one, do you have a workaround for this? Ive tried to do the sound card trick but is not very reliable.

Any ideas?


I am not much of an expert on the RC-Switch library and its example sketches. What I can tell you, is that by using the example “receive” sketches, I was able to “listen and learn” the RF codes. Obviously, you must have an RF Receiver connected to the Arduino (I temporarily used a separate Arduino altogether to do this) and the RF Receiver must match the frequency of the remote control device you are trying to replicate.

Please see for more information.


1 Like

Silly question.

Would this be able to control tvs?

You’d need to probably convert the Arduino to use Infrared, instead of Radio Frequency.

It could be made to work. In fact, I 'd be surprised if someone hasn’t already done it.


That would be awesome! :smiley: the family has a nasty habit of leaving TV’s on around the house and its getting annoying.

Maybe I’ll dive into that in a few months!

This is exactly what I was looking for. I have a lot of devices left from when I was using ninja blocks. Unfortunately, this setup is too complicated for my skill level. Hopefully they will put out a RF device that will just connect one day


Since I already have a Raspberry Pi and not an Arduino, I will be working on building basically the same using the RPi instead and having Smartthings communicate with the Pi over http (on the local network). I’ll make sure to document and post back with results.
I will basically follow these instructions:, modify the php code for my purposes and create device types as needed (right now I only have one of these to control: Also for a quick and dirty http get momentary switch see thread below. I built the device type so I can call a locally hosted php page which then arms my lifeshield alarm, this would essentially work the same way.

If anyone has any suggestions, please let me know. Thanks.

Can anyone link an ‘idiots guide’ on what to buy to get this working?

Additional why hans’t Smartthings imported this code if it’s stable?

SmartThings does not “import” any user Arduino code as far as I know. As far as an idiot’s guide… Buy an Arduino UNO or MEGA (I prefer the MEGA due to its increased RAM and 3 extra hardware UARTs), buy the ThingShield from SmartThings, and buy the 433Mhz RF transmitter/receive combo linked in the first post.

Get familiar with my ST_Anything project, again linked in the first post. Read through the rest of this thread to see how others have got things to work. Range is somewhat limited, so you may need to add a small piece of wire as an antenna to the transmitter board.

I believe I documented things about as best I could in the first post. If you have suggestions to make it better, please let me know.



Thank for assisting and for breaking ground but you and I have a different definition of enjoy.

I will enjoy not having to have arduinos and scruffy power supplies withcode to maintain.

I’ve been to the point whew maintaining my HomeSeer automation scripts was more ongoing effort than doing stuff manually. That was the point I took it all apart and sold it eBay.

Hi Dan,

I found this topic recently and it’s exactly what I wanted to set up since I have a 5-outlet Etekcity RF set. I bought an Arduino Mega, Smartthings shield, 433 Mhz receiver and transmitter and started playing around.

I was able to successfully find the on/off frequencies for each of my 5 switches using the receiver and test that the codes actually turn them on and off using the transmitter and just the Arduino (without the Smartthigns shield).

However, I’ve run into a roadblock linking the shield and the Arduino. I decided to first test it out with your 3-switch code and then extend it to 5 switches once I got this working.

I have it hooked up, along with the transmitter, added the shield to my Smartthings, switched the device handler to ST_Anything_RCSwitch.device.groovy, added another device handler for VirtualSwitch.device.groovy. I added 3 virtual switches using this device handler, and added the smartapp as well -ST_Anything_RCSwitch_Multiplexer.smartapp.groovy.

When I publish the code to the Arduino, this is all I see in the serial monitor:
Everything: init started
Everything: Free RAM = 6440
Everything: UNKNOWN

When I open the device on the phone app, it just shows up with the switches grayed out and don’t do anything when you try to turn them on. In the recent activity, it shows ‘catchall’ followed by the code. I’ve attached a screenshots for this, I can share more if it helps. All the while, there are no new entries in the serial monitor.

Any help would be appreciated!

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.