433mhz outlet
-
Thanks Dwalt, understood now. I had assumed the code i received from the rc-switch sniffer sketch, could be translated to binary and used in your sketch.
Looks like i will need to build a different sniffer.
-
there is also a complete library RCSwitch to work with both transmitters and receivers
https://code.google.com/p/rc-switch/in my case I'm using a cheap wireless 433MHz motion sensor from my security system to drive the light too
@axillent Please can you share link of 433 motion sensor?
-
@axillent Please can you share link of 433 motion sensor?
-
Finally managed to get this working by modifying Dwalts sketch to use the rcswitch library.
I found this much simpler to use as it allows you to learn your existing codes using a simple RF-Sniffer sketch (Sniffer.ino) ie no need to mess around with recording signals, binary codes etc. This sketch simply displays a decimal number which you can just send back to control your devices.
ie
define CODE_1On 0x5FF0DC //Sniffed code converted to Hex.
Serial.println("Turn on Socket 1");
mySwitch.send(CODE_1On, 24); // These codes are unique to each outlet
delay(50);With this working i can now safely control a number of 240V devices around the home !
-
Below is a simple sketch I use for controlling 433Mhz outlets (sockets) with MySensors. I am not very good at coding but this sketch worked for my setup, I assume it could be improved.
https://codebender.cc/sketch:67827
I created a sensor node with a nano connected to a 433Mhz transmitter which is on mains power so the sensor is always "listening". I used the 5V from the nano to power the 433 transmitter but I believe it could run off 3.3V. The node controls four cheap 433Mhz outlets. I only have four but this sketch could be expanded to control many more. These outlets do not give feedback so the sketch is somewhat simple in that regard. These outlets use the PT2262 encoder which is common but may not work with your sockets. If you have a remote with your sockets, your can take it apart to see what encoder is used.
-Dwalt
Nice job, I want one now!
Much easier to copy the transmission data with that sketch than the other examples here...
To help simplify your code, you can try to add in arrays...
int rfMessageON[4][2]= { {0b0101000101010101, 0b00110011}, {0b0101000101010101, 0b11000011}, {0b0101000101010111, 0b00000011}, {0b0101000101011101, 0b00000011} }; int rfMessageOFF[4][2]= { {0b0101000101010101, 0b00111100}, {0b0101000101010101, 0b11001100}, {0b0101000101010111, 0b00001100}, {0b0101000101011101, 0b00001100} };to make a much simpler function...
void loop() { gw.process(); } // void incomingMessage(const MyMessage &message) { if (message.type==V_LIGHT) { Serial.print("Outlet #: "); Serial.println(message.sensor); Serial.print("Command: "); Serial.println(message.getBool()); pt2262Send(message.getBool()? rfMessageON[message.sensor - 1][0],rfMessageON[message.sensor - 1][1]: rfMessageOFF[message.sensor - 1][0],rfMessageOFF[message.sensor - 1][1]); } delay(50); }(not tested)
-
@C.r.a.z.y. said:
@axillent Please can you share link of 433 motion sensor?
with pleasure
what exactly do you need?@axillent Motion sensor ; brand, model, which chip in it?
I have an remote like this (attached) and it didnt work with RC-Switch. (RC-Switch works with SC5262 / SC5272, HX2262 / HX2272, PT2262 / PT2272, EV1527, RT1527, FP1527 or HS1527 chipsets)
If my remote is working with other chipset, how can i read and transmit it?
How can i find this remote's chipset?
----PIC16F630 ---update http://ww1.microchip.com/downloads/en/devicedoc/40039f.pdf -
Finally managed to get this working by modifying Dwalts sketch to use the rcswitch library.
I found this much simpler to use as it allows you to learn your existing codes using a simple RF-Sniffer sketch (Sniffer.ino) ie no need to mess around with recording signals, binary codes etc. This sketch simply displays a decimal number which you can just send back to control your devices.
ie
define CODE_1On 0x5FF0DC //Sniffed code converted to Hex.
Serial.println("Turn on Socket 1");
mySwitch.send(CODE_1On, 24); // These codes are unique to each outlet
delay(50);With this working i can now safely control a number of 240V devices around the home !
-
@C.r.a.z.y. my sensors are none brand)) all using PT2262
was purchased from here http://ru.aliexpress.com/item/-/1953282784.html?recommendVersion=1
I have PIR sensors, door sensors, water leakage and gas leakage sensors.
I also have a remote similar to your.Remote is easily recognized using radio 433MHz receiver connected to arduino and RCSwitch library
It is also a plan to create a gateway from 433MHZ to NRF24 network - this can help me to build vera3 automation using a security sensors without purchasing z-wave or building mysensors sensors
-
@C.r.a.z.y. my sensors are none brand)) all using PT2262
was purchased from here http://ru.aliexpress.com/item/-/1953282784.html?recommendVersion=1
I have PIR sensors, door sensors, water leakage and gas leakage sensors.
I also have a remote similar to your.Remote is easily recognized using radio 433MHz receiver connected to arduino and RCSwitch library
It is also a plan to create a gateway from 433MHZ to NRF24 network - this can help me to build vera3 automation using a security sensors without purchasing z-wave or building mysensors sensors
@axillent Thank you. Do you have dip switches in your sensors?
I found a comparasion table maybe this could help people like me;
If my remote is not a fixed code, how can i read and transmit it?
-
@C.r.a.z.y. some sensors do have dip switches, some have preprogrammed radio code
if you have RF receiver you can try to get a code from your remote using example receiver sketch from RCSwitch library. I build a custom arduino with RF receiver and a button which I use to program the first received code into arduino EEPROM. Later this code is used to identify which sensor should light up my leds.
-
@C.r.a.z.y. some sensors do have dip switches, some have preprogrammed radio code
if you have RF receiver you can try to get a code from your remote using example receiver sketch from RCSwitch library. I build a custom arduino with RF receiver and a button which I use to program the first received code into arduino EEPROM. Later this code is used to identify which sensor should light up my leds.
@axillent OK i understand fixed codes are fine with RCSwitch.
How can i transmit this data ?
1100 0011 0010 0010 0011 0000 1100 1000 1000
1100 0011 0001 0010 0011 0000 1100 0100 1000 -
@axillent OK i understand fixed codes are fine with RCSwitch.
How can i transmit this data ?
1100 0011 0010 0010 0011 0000 1100 1000 1000
1100 0011 0001 0010 0011 0000 1100 0100 1000@C.r.a.z.y. Open any transmitting example from RCSwitch
I never did it but I think send() function is designed for this
https://code.google.com/p/rc-switch/wiki/HowTo_Send?tm=6 -
@C.r.a.z.y. Open any transmitting example from RCSwitch
I never did it but I think send() function is designed for this
https://code.google.com/p/rc-switch/wiki/HowTo_Send?tm=6@axillent Thank you i know you are very helpful. I tried to copy my remote to an universal remote learner(which has no name chipset) but it didnt copy. It is hard to understand and solve for a newbie.
I simply tried to send 10101010codes with this sketch https://code.google.com/p/rc-switch/wiki/HowTo_Send?tm=6 and didnt work.
Something interesting i found while tranmitting,
If i remove the delay () than signal is always sent. I made a jammer! :) Any of my 433 remotes didnt work!I want to learn if any universal remote learner with EV1527 Chipset works with RCSwitch?
My plan is to copy some remote codes to EV1527 universal remote and read the code from serial with RCSwitch-rfSniffer.Now i will try IR SENDER-RECEIVER http://www.mysensors.org/build/ir maybe i can get new ideas for 433mhz things..
-
Finally managed to get this working by modifying Dwalts sketch to use the rcswitch library.
I found this much simpler to use as it allows you to learn your existing codes using a simple RF-Sniffer sketch (Sniffer.ino) ie no need to mess around with recording signals, binary codes etc. This sketch simply displays a decimal number which you can just send back to control your devices.
ie
define CODE_1On 0x5FF0DC //Sniffed code converted to Hex.
Serial.println("Turn on Socket 1");
mySwitch.send(CODE_1On, 24); // These codes are unique to each outlet
delay(50);With this working i can now safely control a number of 240V devices around the home !
@jribera Been try to get this happening myself. Can you provide the sketch you ended up using to get this happening so I can try it. I know what all my codes are, just need to get a sketch happening to interface back to my controller (Domoticz Serial)
Cheers
-
This is the sketch i'm using for controlling a number of sockets around the house.
/* RF433Mhz Transmitter node: This sketch allows On-Off-Keying (OOK) control of four 433Mhz relay outlets which utilize the common PT2262 encoding chip for signal transmission. The sketch could be easily expanded to include additional outlets. The sensor node consists of a nano connected to a NRF24L01 and a 433Mhz transmitter connected to pin 3, 5V and Gnd. The transmitter can run off of 3.3V as well. The sketch is based on the MySensors project (http://www.mysensors.org). Submitted by Dwalt. */ // Include related libraries #include <MySensor.h> #include <SPI.h> #include <RF24.h> #include <RCSwitch.h> // Define Constants #define RF433_CHILD_ID 0 #define NUMBER_OF_OUTLETS 4 // Each outlet will have 2 OOK codes //#define SEND_DATA 3 #define CODE_1On 6287582 #define CODE_1Off 6287574 #define CODE_2On 6287580 #define CODE_2Off 6287572 #define CODE_3On 6287578 #define CODE_3Off 6287570 #define CODE_4On 6287577 #define CODE_4Off 6287569 MySensor gw; RCSwitch mySwitch = RCSwitch(); void setup() { mySwitch.enableTransmit(3); Serial.begin(115200); // Not sure why this was included // The node is mains powered, so why not make it a repeater. gw.begin(incomingMessage, AUTO, true); // Send the sketch version information to gateway gw.sendSketchInfo("RF433", "1.1"); // Register outlets to gw (they will be created as child devices) for(int i=0; i<NUMBER_OF_OUTLETS;i++) { gw.present(i+1, 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("Turn on Socket 1"); mySwitch.send(CODE_1On, 24); // These codes are unique to each outlet delay(50); } if (incomingLightState==0) { // Turn off socket 1 Serial.println("Turn off Socket 1"); mySwitch.send(CODE_1Off, 24); delay(50); } } if (incomingOutlet==2) { if (incomingLightState==1) { // Turn on socket 2 Serial.println("Turn on Socket 2"); mySwitch.send(CODE_2On, 24); delay(50); } if (incomingLightState==0) { // Turn off socket 2 Serial.println("Turn off Socket 2"); mySwitch.send(CODE_2Off, 24); delay(50); } } if (incomingOutlet==3) { if (incomingLightState==1) { // Turn on socket 3 Serial.println("Turn on Socket 3"); mySwitch.send(CODE_3On, 24); delay(50); } if (incomingLightState==0) { // Turn off socket 3 Serial.println("Turn off Socket 3"); mySwitch.send(CODE_3Off, 24); delay(50); } } if (incomingOutlet==4) { if (incomingLightState==1) { // Turn on socket 4 Serial.println("Turn on Socket 4"); mySwitch.send(CODE_4On, 24); delay(50); } if (incomingLightState==0) { // Turn off socket 4 Serial.println("Turn off Socket 4"); mySwitch.send(CODE_4Off, 24); delay(50); } } } delay(50); } -
@jribera Your sketch works perfectly :)
I am trying to add also 433 receiver to allow domoticz update states of the switches is the Socket is switched on or off by remote control. Does anybody know how to do that? After receiving certain code change the state of the corresponding socket.
treb0r -
@jribera Your sketch works perfectly :)
I am trying to add also 433 receiver to allow domoticz update states of the switches is the Socket is switched on or off by remote control. Does anybody know how to do that? After receiving certain code change the state of the corresponding socket.
treb0r@treb0r said:
I am trying to add also 433 receiver to allow domoticz update states of the switches is the Socket is switched on or off by remote control. Does anybody know how to do that? After receiving certain code change the state of the corresponding socket.
treb0rIm an just trying to do this (also with domoticz) ;)
Here is my first try of the function using RCSwitch.h:
/**************************************** * Analyse the Radio traffic and set the states ****************************************/ void readRadio() { if (mySwitch.available()) { int value = mySwitch.getReceivedValue(); if (value == 0) { #ifdef DEBUG Serial.print("Unknown encoding"); #endif } else { led(false,4,150); #ifdef DEBUG Serial.print("Received "); Serial.print( mySwitch.getReceivedValue() ); Serial.print(" / "); Serial.print( mySwitch.getReceivedBitlength() ); Serial.print("bit "); Serial.print("Protocol: "); Serial.println( mySwitch.getReceivedProtocol() ); #endif if (value == 4373) //Stehlampe ON { #ifdef DEBUG Serial.println("Stehlampe ON detected"); #endif } else if (value == 4372 ) //Stehlampe OFF { #ifdef DEBUG Serial.println("Stehlampe OFF detected"); #endif resend((msgLight1.set(0)),m_repeat); } else if (value == 1048597 ) //Vitrine ON { #ifdef DEBUG Serial.println("Vitrine ON detected"); #endif resend((msgLight2.set(1)),m_repeat); } else if (value == 1048596 ) //Vitrine OFF { #ifdef DEBUG Serial.println("Vitrine OFF detected"); #endif resend((msgLight2.set(0)),m_repeat); } mySwitch.resetAvailable(); } } } -
This is the sketch i'm using for controlling a number of sockets around the house.
/* RF433Mhz Transmitter node: This sketch allows On-Off-Keying (OOK) control of four 433Mhz relay outlets which utilize the common PT2262 encoding chip for signal transmission. The sketch could be easily expanded to include additional outlets. The sensor node consists of a nano connected to a NRF24L01 and a 433Mhz transmitter connected to pin 3, 5V and Gnd. The transmitter can run off of 3.3V as well. The sketch is based on the MySensors project (http://www.mysensors.org). Submitted by Dwalt. */ // Include related libraries #include <MySensor.h> #include <SPI.h> #include <RF24.h> #include <RCSwitch.h> // Define Constants #define RF433_CHILD_ID 0 #define NUMBER_OF_OUTLETS 4 // Each outlet will have 2 OOK codes //#define SEND_DATA 3 #define CODE_1On 6287582 #define CODE_1Off 6287574 #define CODE_2On 6287580 #define CODE_2Off 6287572 #define CODE_3On 6287578 #define CODE_3Off 6287570 #define CODE_4On 6287577 #define CODE_4Off 6287569 MySensor gw; RCSwitch mySwitch = RCSwitch(); void setup() { mySwitch.enableTransmit(3); Serial.begin(115200); // Not sure why this was included // The node is mains powered, so why not make it a repeater. gw.begin(incomingMessage, AUTO, true); // Send the sketch version information to gateway gw.sendSketchInfo("RF433", "1.1"); // Register outlets to gw (they will be created as child devices) for(int i=0; i<NUMBER_OF_OUTLETS;i++) { gw.present(i+1, 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("Turn on Socket 1"); mySwitch.send(CODE_1On, 24); // These codes are unique to each outlet delay(50); } if (incomingLightState==0) { // Turn off socket 1 Serial.println("Turn off Socket 1"); mySwitch.send(CODE_1Off, 24); delay(50); } } if (incomingOutlet==2) { if (incomingLightState==1) { // Turn on socket 2 Serial.println("Turn on Socket 2"); mySwitch.send(CODE_2On, 24); delay(50); } if (incomingLightState==0) { // Turn off socket 2 Serial.println("Turn off Socket 2"); mySwitch.send(CODE_2Off, 24); delay(50); } } if (incomingOutlet==3) { if (incomingLightState==1) { // Turn on socket 3 Serial.println("Turn on Socket 3"); mySwitch.send(CODE_3On, 24); delay(50); } if (incomingLightState==0) { // Turn off socket 3 Serial.println("Turn off Socket 3"); mySwitch.send(CODE_3Off, 24); delay(50); } } if (incomingOutlet==4) { if (incomingLightState==1) { // Turn on socket 4 Serial.println("Turn on Socket 4"); mySwitch.send(CODE_4On, 24); delay(50); } if (incomingLightState==0) { // Turn off socket 4 Serial.println("Turn off Socket 4"); mySwitch.send(CODE_4Off, 24); delay(50); } } } delay(50); }@jribera What version of mysensors was this coded for? I'm having issues building this on 1.4 for some reason.
-
@jribera What version of mysensors was this coded for? I'm having issues building this on 1.4 for some reason.
Also 1.4