ST_Anything: 433Mhz RF Devices + Arduino + ThingShield

Hi Dan,

Sorry to drag up an old thread.

I’d really like to add an RF 433mhz transmitter to my NodeMCU running ST_A v2.71.

I noticed the RCSwitch is now in the deprecated folder and appears to have been written for the ThingShield, which is as you know, discontinued.

What sort of effort would it take to add it as a new constructor(?) into the ST_Anything_Multiples_ESP8266WiFi.ino ?

My use case/need is to use $4 433mhz window/door sensors vs $40 zwave/zigbee alternatives. [I can’t hardwire and so looking for cheaper wireless alternatives]

Thanks in advance.

The EX_RCSwitch class is still active in my github repository as linked below (I probably deprecated the groovy DH code for it though.) However, this class is a 433MHz TRANSMITTER used to activate 433MHz switch devices. It does not support 433MHz Receiver functionality, which is what I think you’d like to implement.

You’d have to figure out how to get an Arduino to receive and interpret the 433MHz door and window sensor data. Then implement a new ST_Anything "Contact Sensor) class. It could easily use the same Child Contact Sensor Device Handler as the normal digital input contact sensor device in ST_Anything, IS_Contact.

Timing is usually pretty critical in sending and receiving RF data. Therefore, it might be best to use something like an extra ESP8266 board attached to a 433MHz receiver module to receive and interpret for 433MHz Door and Windows sensor data. The “433MHz Porcessor” could then simply be wired to to another ESP8266 via digital IO pins to keep ST_Anything running the same as it does today. I would only do this if you couldn’t get a new 433MHz Receiver Class to not work properly with the current architecture of ST_Anything.

Edit: Disclaimer - I have no idea if the RCSwitch code will run on a NodeMCU ESP8266. I have only tested it on an Arduino board.

2 Likes

Got it thanks.

Correct :frowning:

I have added the following to the ESP8266Wifi sketch

#include <EX_RCSwitch.h>
#define PIN_RCSWITCH               0
static st::EX_RCSwitch executor1(F("rcswitch1"), PIN_RCSWITCH, 5526613, 24, 5526871, 24, 174, 1, 15, LOW);
st::Everything::addExecutor(&executor1);

I got the RF numbers from the RCSwitch receive demo.

I’m testing the transmit code on the NodeMCU first - if it works, then I can start on the receive.

One thing that is worrying me a little is this code found in the EX_RCSwitch.h file

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

It’s the only thing that references the ThingShield in all the headers and program files that I can see. No idea if I can ignore it or not…

Anyhow, what I’ve tried here uploaded fine to the NodeMCU - but of course, with a DTH groovy, nothing appears anywhere, and I don’t know how I can test it.

Easy fix for getting the child to be created… Simply make sure you follow the naming convention I outlined at the bottom of the ST_Anything ReadMe file. In other words, make sure you call it “switch1” or “switch2” since the Child Device handler for a normal switch would be exactly the same for a RCSwitch.

static st::EX_RCSwitch executor1(F("switch1"), PIN_RCSWITCH, 5526613, 24, 5526871, 24, 174, 1, 15, LOW);

st::Everything::addExecutor(&executor1);

No need to worry about the “ThingShield” reference. None of the ST_Anything classes no whether you’re using a ThingShield or LAN Connected device. That’s the beauty of the “SmartThings” library which I use to abstract all communications between the Arduino/ESP8266 and the ST Hub. The individual devices that you hook up to the Arduino/ESP8266, and their associated C++ code, never talk directly to the communications layer. That work is handled within the ST_Anything’s Everything class, which in turn, uses one of the SmartThings’ classes for network communications. In your sketch’s setup() routine, the proper SmartThings object is created and passed to the Everything object.

So, if you want to change from an ESP8266 to an Arduino + Thingshield for example, you only really need to change a few lines of code in your sketch.

Our goal is to support as many communications methods and platforms as possible, while keeping the end-user’s experience mostly isolated to a simple Arduino sketch file.

1 Like

Worked :slight_smile:

RF Transmit on NodeMCU successfully triggered an old RF Socket that I had lying around the house.

Now I need to work out the Receive for the window door sensors.

Thanks

1 Like

@Vyker

Curious if you ever got the sensor handling working?

Yes I did - but my RF socket would change frequency with every second press so I couldn’t click “on” in ST more than once or twice before the frequency changed and I had to re-flash the ESP with a new set of codes.

You need to find one that sets it’s frequency but that also sticks to it.

I never got past switch devices. I’d like to work on state devices when I get time - I’m looking at getting a cheap RF smoke detector and having that in ST.

Just an update. I have just added a project where I have used the brilliant ST_Anything library together with a RCSwitch library I have updated (to support many more devices) on a NodeMCU V3. With a simple wire antanna on the RF433, the range is pretty good and I can have just one of the RF Bridges installed to turn on and off many power switches around the house.
See: https://github.com/perivar/ST_Anything_NodeMCU for the PlatformIO projects (used in Visual Studio Code) and https://github.com/perivar/rc-switch for the updated library.
Enjoy.

3 Likes

So glad to hear you’ve found this work useful.

1 Like

@perivar I am attempting to replicate exactly what you have built out specifically for controlling etekcity sockets via 433mhz. That said, I have pulled your project into platform.io but it is throwing errors about secrets.h missing which makes sense. Would it be possible for you to drop the sensitive values and post that file with the variables so I can compile?

Here:
#define WIFI_SSID “*"
#define WIFI_PASSWORD "

#define DEVICE_IP_ADDRESS { 192, 168, 0, 200 }
#define ROUTER_GATEWAY { 192, 168, 0, 1 }
#define LAN_SUBNET { 255, 255, 255, 0 }
#define DNS_SERVER { 192, 168, 0, 1 }
#define SERVER_PORT 8090
#define HUB_IP_ADDRESS { 192, 168, 0, 50 }
#define HUB_PORT 39500

@Vyker I am trying to get this up and running as well but haven’t had much success. I’ve got all the hardware and started leveraging @perivar’s code. Any tips/guides you have to getting it to transmit 433mhz via nodemcu w/ ST? I am a little confused w/ some of the deprecation and forks. Any help would be greatly appreciated.

@lehighkid what part do you struggle with? I used alot of time with NodeMCU and both the RF send and receiver code. The send works very well, however it turns out that receive on the NodeMCU (although it works as well) has some timing irregularities that makes recording a RF signal more challenging. My best solution was to use an arduino nano with the rcswitch test project to record and then use the same binary bit string in nodemcu and the ST Anything fork I used. https://github.com/perivar/rcswitch-testing
On the nodemcu I connect a cheap 433 Mhz transmitter module from china to ground, 3.3v and RX.

1 Like

Thank you @perivar - I used a spare Arduino Mega and the receiver worked flawlessly. I have the nodemcu wired up as you said for the transmitter and flashed w/ your code and updated codes - now I need to figure out the ST integration and device handlers.

RESOLVED:

I modified @perivar’s rcswitch to accept pulse length in the new constructor and now successfully controlling outlets from SmartThings via Nodemcu! Thank you!

(leaving original notes below for reference)

Okay so the mega can receive/send the codes and it works w/ the outlets. The nodemcu can interact receive/send updates from Smartthings; however, the code send isn’t working on the nodemcu. I had to specify setProtocol(1,189) on the mega but can’t seem to set the pulselength with the constructor in your code. If I use the original constructor w/ pulselength it goes into a reboot cycle. Any ideas?

Here is the sniffed on code:
Received 79107 / 24bit Protocol: 1
Raw timing data: 5816,144,608,136,600,144,604,140,608,140,604,140,604,140,608,512,232,140,612,132,612,508,240,508,236,136,612,508,240,132,612,508,240,132,608,140,604,144,600,148,596,14
8,596,152,596,524,220,524,
Raw bitdata: 000000010011010100000011

Here is the sniffed off code:
Received 79116 / 24bit Protocol: 1
Raw timing data: 5812,144,604,144,600,144,600,144,604,144,600,144,604,140,604,520,224,144,608,136,604,516,232,512,232,144,604,516,228,144,604,520,224,148,596,148,596,152,596,148,596,52
4,224,520,228,148,596,148,
Raw bitdata: 000000010011010100001100

Here are the two constructors:
static st::EX_RCSwitch executor3(F(“switch2”), PIN_RCSWITCH, “000000010011010100000011”, “000000010011010100001100”, 1, 4, LOW);
static st::EX_RCSwitch executor4(F(“switch3”), PIN_RCSWITCH, 79107, 24, 79116, 24, 189, 1, 4, LOW);

Here is the working code in Arduino test:
mySwitch.setProtocol(1, 189);
mySwitch.setRepeatTransmit(4);
const char *everflourish4On = “000000010011010100000011”;
const char *everflourish4Off = “000000010011010100001100”;

1 Like

@lehighkid Brilliant! I would like to update “my” rcswitch library with your fix, can you please share your code?

Absolutely. I will share tonight. If you prefer I can figure out how to submit a pull request in github

@lehighkid a pull request would be the best if possible.

I submitted a pull request: https://github.com/perivar/ST_Anything_NodeMCU/pull/1

1 Like

@perivar @lehighkid did you work on the receive code?