Relay actuator sketch - auto off function
-
@BulldogLowell thanks again.
great, let me know if it works for you
-
great, let me know if it works for you
@BulldogLowell I tested it today and it works as expected.
On the hardware side do you think it would make more sense to use transistor instead of relay (since I am dealing only with 12 volts)?
-
@BulldogLowell I tested it today and it works as expected.
On the hardware side do you think it would make more sense to use transistor instead of relay (since I am dealing only with 12 volts)?
I would consider what I'm switching (the load) as much as the voltage and the way they are being powered.
" ...simple 12v 433 mhz remote control..."
what kind of remote is this?
-
I would consider what I'm switching (the load) as much as the voltage and the way they are being powered.
" ...simple 12v 433 mhz remote control..."
what kind of remote is this?
-
@BulldogLowell it is remote control fob similar to this one. It uses 12 volt battery (27A).
@niccodemi
I am curious why you chose arduino -> relay -> 433 transmitter for your project and not simpler arduino -> 433 transmitter. I ask because I have one of these key fob RF cloners lying around and have not put it to use yet. I was considering using it to trigger scenes via a 433 receiver on a yet-to-be-built node. -
@niccodemi
I am curious why you chose arduino -> relay -> 433 transmitter for your project and not simpler arduino -> 433 transmitter. I ask because I have one of these key fob RF cloners lying around and have not put it to use yet. I was considering using it to trigger scenes via a 433 receiver on a yet-to-be-built node.@Dwalt initially I tried with Vera and Rfxtrx433 but only later I learned there are many different coding systems on 433 Mhz and many (including Lightning4) are not supported in Rfxtrx plugin. I wanted to try with arduino + 433 transmitter but about same time I found out about mysensors and abandoned 433+arduino altogether. That said I've still got couple 433 mhz controlled switches and I want to integrate them to Vera-Mysensors environment. Until now I thought that the only option is to use relay. I would be interested to try other solutions.
-
@Dwalt initially I tried with Vera and Rfxtrx433 but only later I learned there are many different coding systems on 433 Mhz and many (including Lightning4) are not supported in Rfxtrx plugin. I wanted to try with arduino + 433 transmitter but about same time I found out about mysensors and abandoned 433+arduino altogether. That said I've still got couple 433 mhz controlled switches and I want to integrate them to Vera-Mysensors environment. Until now I thought that the only option is to use relay. I would be interested to try other solutions.
@niccodemi I have several of these 433 switches and use a nano (w/mains power) with the 433 transmitter from the store to control them thru MySensors/Vera. The drawback is that these cheap outlets do not give feedback (with MySensors or RFXtrx) but Vera tracks their state by last command.
The four I have on my setup work very reliably and have not failed a trigger command during the past two months of operation. The 433Mhz transmitter seems to have better distance within my house than the NRF24 and is very reliable, at least thru my limited experience. My 433 transmitter node is within line of sight of my gateway and only 3m distant. The 433 outlets are scattered throughout my house, on different floors and through multiple walls. I use them to control floor lamps and a fan.
I sniffed the RF code from the included remote using the 433 receiver and then put the codes within the sketch on the nano controlling the 433transmitter. I used this blog for details on the sniffing process. I got the set of four outlets for about $18 shipped during a sale so it worked out to $4.50 each.
-
@niccodemi I have several of these 433 switches and use a nano (w/mains power) with the 433 transmitter from the store to control them thru MySensors/Vera. The drawback is that these cheap outlets do not give feedback (with MySensors or RFXtrx) but Vera tracks their state by last command.
The four I have on my setup work very reliably and have not failed a trigger command during the past two months of operation. The 433Mhz transmitter seems to have better distance within my house than the NRF24 and is very reliable, at least thru my limited experience. My 433 transmitter node is within line of sight of my gateway and only 3m distant. The 433 outlets are scattered throughout my house, on different floors and through multiple walls. I use them to control floor lamps and a fan.
I sniffed the RF code from the included remote using the 433 receiver and then put the codes within the sketch on the nano controlling the 433transmitter. I used this blog for details on the sniffing process. I got the set of four outlets for about $18 shipped during a sale so it worked out to $4.50 each.
-
The original sketch was posted here. It is crude (my first arduino sketch) but it worked and continued to work for the past 9 months. I sniffed the codes and then hard coded them into the sketch rather than use one of the RF libraries which I couldn't figure out.
I recently updated it for it to work under MyS 1.5 but did not refine it. It is still ugly:
#include <MySensor.h> #include <SPI.h> #include <EEPROM.h> #include <NewRemoteReceiver.h> #include <NewRemoteTransmitter.h> #include <MyTransportNRF24.h> #include <MyHwATMega328.h> #define TRANSMITTER_PIN 3 #define RECEIVER_INTERRUPT 1 #define RF433_CHILD_ID 0 #define NUMBER_OF_OUTLETS 4 #define DELAYSHORT 160 #define DELAYLONG 500 #define SEND_DATA 3 MySensor gw; static void ookPulse(int on, int off) { digitalWrite(SEND_DATA, HIGH); delayMicroseconds(on); digitalWrite(SEND_DATA, LOW); delayMicroseconds(off); } static void pt2262Send(uint16_t signature, uint8_t command) { byte i, k; // send 16 times for(k=0;k<16;k++) { // send signature first for(i=0;i<16;i++) { if((signature>>(15-i)) & 0x1) { ookPulse(DELAYLONG, DELAYSHORT); } else { ookPulse(DELAYSHORT, DELAYLONG); } } for(i=0;i<8;i++) { if((command>>(7-i)) & 0x1) { ookPulse(DELAYLONG, DELAYSHORT); } else { ookPulse(DELAYSHORT, DELAYLONG); } } // end with a '0' ookPulse(DELAYSHORT, DELAYLONG); // short delay gw.wait(5); } } void setup() { Serial.begin(115200); gw.begin(incomingMessage, AUTO, true); gw.sendSketchInfo("RF433", "1.1"); for (int sensor=1; sensor<=NUMBER_OF_OUTLETS; sensor++){ gw.present(sensor, S_LIGHT); } } void loop() { gw.process(); } void incomingMessage(const MyMessage &message) { if (message.type==V_LIGHT) { int incomingLightState = message.getBool(); int incomingOutlet = message.sensor; /* Serial.print("Outlet #: "); Serial.println(message.sensor); Serial.print("Command: "); Serial.println(message.getBool()); */ if (incomingOutlet==1) { if (incomingLightState==1) { // Turn on socket 1 // Serial.println("\nTurn on Socket 1"); pt2262Send(0b0101000101010101, 0b00110011); gw.wait(100); } if (incomingLightState==0) { // Turn off socket 1 // Serial.println("\nTurn off Socket 1"); pt2262Send(0b0101000101010101, 0b00111100); gw.wait(100); } } if (incomingOutlet==2) { if (incomingLightState==1) { // Turn on socket 2 // Serial.println("\nTurn on Socket 2"); pt2262Send(0b0101000101010101, 0b11000011); gw.wait(100); } if (incomingLightState==0) { // Turn off socket 2 // Serial.println("\nTurn off Socket 2"); pt2262Send(0b0101000101010101, 0b11001100); gw.wait(100); } } if (incomingOutlet==3) { if (incomingLightState==1) { // Turn on socket 3 // Serial.println("\nTurn on Socket 3"); pt2262Send(0b0101000101010111, 0b00000011); gw.wait(100); } if (incomingLightState==0) { // Turn off socket 3 // Serial.println("\nTurn off Socket 3"); pt2262Send(0b0101000101010111, 0b00001100); gw.wait(100); } } if (incomingOutlet==4) { if (incomingLightState==1) { // Turn on socket 4 // Serial.println("\nTurn on Socket 4"); pt2262Send(0b0101000101011101, 0b00000011); gw.wait(100); } if (incomingLightState==0) { // Turn off socket 4 // Serial.println("\nTurn off Socket 4"); pt2262Send(0b0101000101011101, 0b00001100); gw.wait(100); } } } gw.wait(100); } -
The original sketch was posted here. It is crude (my first arduino sketch) but it worked and continued to work for the past 9 months. I sniffed the codes and then hard coded them into the sketch rather than use one of the RF libraries which I couldn't figure out.
I recently updated it for it to work under MyS 1.5 but did not refine it. It is still ugly:
#include <MySensor.h> #include <SPI.h> #include <EEPROM.h> #include <NewRemoteReceiver.h> #include <NewRemoteTransmitter.h> #include <MyTransportNRF24.h> #include <MyHwATMega328.h> #define TRANSMITTER_PIN 3 #define RECEIVER_INTERRUPT 1 #define RF433_CHILD_ID 0 #define NUMBER_OF_OUTLETS 4 #define DELAYSHORT 160 #define DELAYLONG 500 #define SEND_DATA 3 MySensor gw; static void ookPulse(int on, int off) { digitalWrite(SEND_DATA, HIGH); delayMicroseconds(on); digitalWrite(SEND_DATA, LOW); delayMicroseconds(off); } static void pt2262Send(uint16_t signature, uint8_t command) { byte i, k; // send 16 times for(k=0;k<16;k++) { // send signature first for(i=0;i<16;i++) { if((signature>>(15-i)) & 0x1) { ookPulse(DELAYLONG, DELAYSHORT); } else { ookPulse(DELAYSHORT, DELAYLONG); } } for(i=0;i<8;i++) { if((command>>(7-i)) & 0x1) { ookPulse(DELAYLONG, DELAYSHORT); } else { ookPulse(DELAYSHORT, DELAYLONG); } } // end with a '0' ookPulse(DELAYSHORT, DELAYLONG); // short delay gw.wait(5); } } void setup() { Serial.begin(115200); gw.begin(incomingMessage, AUTO, true); gw.sendSketchInfo("RF433", "1.1"); for (int sensor=1; sensor<=NUMBER_OF_OUTLETS; sensor++){ gw.present(sensor, S_LIGHT); } } void loop() { gw.process(); } void incomingMessage(const MyMessage &message) { if (message.type==V_LIGHT) { int incomingLightState = message.getBool(); int incomingOutlet = message.sensor; /* Serial.print("Outlet #: "); Serial.println(message.sensor); Serial.print("Command: "); Serial.println(message.getBool()); */ if (incomingOutlet==1) { if (incomingLightState==1) { // Turn on socket 1 // Serial.println("\nTurn on Socket 1"); pt2262Send(0b0101000101010101, 0b00110011); gw.wait(100); } if (incomingLightState==0) { // Turn off socket 1 // Serial.println("\nTurn off Socket 1"); pt2262Send(0b0101000101010101, 0b00111100); gw.wait(100); } } if (incomingOutlet==2) { if (incomingLightState==1) { // Turn on socket 2 // Serial.println("\nTurn on Socket 2"); pt2262Send(0b0101000101010101, 0b11000011); gw.wait(100); } if (incomingLightState==0) { // Turn off socket 2 // Serial.println("\nTurn off Socket 2"); pt2262Send(0b0101000101010101, 0b11001100); gw.wait(100); } } if (incomingOutlet==3) { if (incomingLightState==1) { // Turn on socket 3 // Serial.println("\nTurn on Socket 3"); pt2262Send(0b0101000101010111, 0b00000011); gw.wait(100); } if (incomingLightState==0) { // Turn off socket 3 // Serial.println("\nTurn off Socket 3"); pt2262Send(0b0101000101010111, 0b00001100); gw.wait(100); } } if (incomingOutlet==4) { if (incomingLightState==1) { // Turn on socket 4 // Serial.println("\nTurn on Socket 4"); pt2262Send(0b0101000101011101, 0b00000011); gw.wait(100); } if (incomingLightState==0) { // Turn off socket 4 // Serial.println("\nTurn off Socket 4"); pt2262Send(0b0101000101011101, 0b00001100); gw.wait(100); } } } gw.wait(100); }@Dwalt oh wow.. thanks so much.. i was waiting for you to get back to me but never saw this post.. and i just happened to stumble on it when i was looking to see if you had been back on the forum or not.
I'm good with the hardware side of things and can shell script and do windows scripting. but still have not learned this coding yet.
i have all the hardware for the 433 stuff.
i even got the RF stuff to work (on my RPI2) and sniffed all my codes
i could just never get it to work with my arduino stuff.
likely the code, so i'm excited to give your code a go.
Thanks!