433mhz transmitter



  • Its kinda kludgy (of course- I made it!) but it works. As usual full of bits pinched from elsewhere....
    I am using this to control 4 effergy wall outlets. I already have mains switching ability but it's made by me and I am nervous about fire, so I figured this was a good compromise.
    I have some cheap 433 transmitters and receivers. Used the RCSwitch library to capture the codes. I have only got one switch functional at the moment but to add the rest is trivial. My coding Im sure is crap but it works.
    I have soldered a wee wire to the transmitter 12CM long and have no issues with range. I like the 'repeat command x times' function in the RCSwitch library, kinda makes not having feedback a non issue.

    // Enable debug prints to serial monitor
    //#define MY_DEBUG 
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    // Enable repeater functionality for this node
    // #define MY_REPEATER_FEATURE
    
    #include <SPI.h>
    #include <MySensors.h>
    #include <RCSwitch.h>
    
    #define NUMBER_OF_PLUGS 4 // Total number of attached plugs
    
    #define CODE_1On 1290271
    #define CODE_1Off 1290263
    #define CODE_2On 1290267
    #define CODE_2Off 1290259
    #define CODE_3On 1290269
    #define CODE_3Off 1290261
    #define CODE_4On 1290270
    #define CODE_4Off 1290262
    
    RCSwitch mySwitch = RCSwitch();
    
    void setup() {
      mySwitch.enableTransmit(4);
      mySwitch.setRepeatTransmit(15);
    }
    
    void presentation()  
    {   
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("433mhz switch", "1.0");
    
      for (int sensor=1 ; sensor<=NUMBER_OF_PLUGS;sensor++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_LIGHT);
      }
    }
    
    
    void loop() 
    {
      
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      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);
    }
    
    

  • Hero Member

    @Matt Great work... I may have to dust off some of my old Watts Clever sockets and give this a try 🙂



  • Thanks Boots. One thing I noticed was that three out of five of the receivers I bought did not work. If fact one heated up real quick. So buy a few cos QC in China is pants.



  • Nice! I did something very similar! I used rcswitch and sent the codes directly to the controller. That way I could use the codes received as scene toggles in domoticz. I had another sketch doing the TX part though. I have since retired that set up in favour of rflink for controlling my 433MHz stuff.



  • Can some one give me a electric schematic for this sketch , or a place where i can find it.



  • Hi Ton
    First of all I got a bunch (five) of these
    Im glad I got five because four of the transmitters did not work.
    If you have the effergy plugs these codes will work otherwise you need to sniff them out as per this
    instructable. Note I am using pin 4 for the transmitter, not 12 (the line mySwitch.enableTransmit(4); in code)
    The NRF24L01 is wired up as per the instructions on this site.
    Hope it all makes sense.



  • Just a note for those in the US. The 433 MHz stuff is for European use. Though it would probably work in the US, it is technically not legal according to FCC rules. Here is a version of the transmitters legal for use in the US. This should be a drop in replacement for the 433MHz version, but double check the pins if you do purchase these.



  • @Matt I used your code as a basis to control some 433Mhz outlets from Aldi (in Germany). The system is their "Easy Home" brand, made by Globaltronics. The model designation is GT-9000. It needed a few tweeks from your code. In case anyone else has, or will get, this package, here is the code (pay attention to the "void setup" section):

    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    // Enable repeater functionality for this node
    // #define MY_REPEATER_FEATURE
    
    #include <SPI.h>
    #include <MySensors.h>
    #include <RCSwitch.h>
    
    #define NUMBER_OF_PLUGS 4 // Total number of attached plugs
    
    #define CODE_1On "110001010000001101110000"
    #define CODE_1Off "110011011100000100010000"
    #define CODE_2On "110001010000001101110100"
    #define CODE_2Off "110011011100000100010100"
    #define CODE_3On "110001010000001101111100"
    #define CODE_3Off "110011011100000100011100"
    #define CODE_4On "110001010000001101110010"
    #define CODE_4Off "110011011100000100010010"
    
    RCSwitch mySwitch = RCSwitch();
    
    void setup() {
      mySwitch.enableTransmit(4);
      mySwitch.setRepeatTransmit(3);
      mySwitch.setPulseLength(510);
      mySwitch.setProtocol(5);
    }
    
    void presentation()  
    {   
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("433mhz switch", "1.0");
    
      for (int sensor=1 ; sensor<=NUMBER_OF_PLUGS;sensor++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_LIGHT);
      }
    }
    
    
    void loop() 
    {
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      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); // 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);
    delay(50); 
     }
     }
     if (incomingOutlet==2) {
     if (incomingLightState==1) {
        // Turn on  socket 2
        Serial.println("Turn on Socket 2");
    mySwitch.send(CODE_2On);
     delay(50); 
     }
     if (incomingLightState==0)  {
        // Turn off socket 2
     Serial.println("Turn off Socket 2");
    mySwitch.send(CODE_2Off);
    delay(50); 
     }
     }
     if (incomingOutlet==3) {
     if (incomingLightState==1) {
        // Turn on  socket 3
        Serial.println("Turn on Socket 3");
    mySwitch.send(CODE_3On);
     delay(50); 
     }
     if (incomingLightState==0)  {
        // Turn off socket 3
     Serial.println("Turn off Socket 3");
    mySwitch.send(CODE_3Off);
    delay(50); 
     }
     }
     if (incomingOutlet==4) {
     if (incomingLightState==1) {
        // Turn on  socket 4
        Serial.println("Turn on Socket 4");
     mySwitch.send(CODE_4On);
     delay(50); 
     }
     if (incomingLightState==0)  {
        // Turn off socket 4
     Serial.println("Turn off Socket 4");
    mySwitch.send(CODE_4Off);
    delay(50); 
     }
     }
      }
     delay(50);
    }```

  • Contest Winner

    @kchest Great. I have some of those aldi one's laying around doing nothing. Because I couldn't control them with my RFElink. I'll give your sketch a try.



  • @TheoL A couple of things to note:
    I hooked up the 433Mhz transmitter to pin 4.
    The device didn't show up under the MySensor section of the Hardware tab. However all 4 plugs appeared in the Devices list. Strange but it works.



  • @kchest
    Hello,
    I tried to switch the 433MHZ outlets from the "Intertechno / Brennenstuhl", but unfortunately does not work. I have changed the "pulse length" and the "protocol":

    MySwitch.setPulseLength (320);
    MySwitch.setProtocol (1);

    Do you have any experience with these outlets?


  • Hero Member

    @Tommi I've outlets from Intertechno (IT-1500) running fine for over a year now.

    The outlets have to learn the code, so shortly after pluggin in, when the led on the outlet blinks, send an ON from your MySensors node.

    Here is my sketch (its a combination of DHT22, 12V LED/PWM Switch and 433 MHz node):

    #define MY_DEFAULT_RX_LED_PIN 7
    #define MY_DEFAULT_TX_LED_PIN 6
    #define MY_DEFAULT_ERR_LED_PIN 4
    
    #define MY_RADIO_NRF24
    
    #define MY_NODE_ID 106
    
    // Enabled repeater feature for this node
    #define MY_REPEATER_FEATURE
    
    
    //#define MY_DEBUG
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DHT.h>
    #include "RCSwitch.h"
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_PWM_LIGHT 3
    #define CHILD_ID_433_1 4
    #define CHILD_ID_433_2 5
    #define CHILD_ID_433_3 6
    #define CHILD_ID_433_4 7
    #define CHILD_ID_433_5 8
    #define CHILD_ID_433_6 9
    
    
    #define HUMIDITY_SENSOR_DIGITAL_PIN 8
    #define PWM_LIGHT_PIN 5
    
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    unsigned long NEXT_CHECK = 0;
    
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = true;
    RCSwitch mySwitch = RCSwitch(); 
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgPWM(CHILD_ID_PWM_LIGHT, V_STATUS);
    
    
    void setup()  
    { 
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
    
      pinMode(PWM_LIGHT_PIN, OUTPUT);
      digitalWrite(PWM_LIGHT_PIN, LOW);
      
      mySwitch.enableTransmit(A0);
    }
    
    void presentation() {
      // Send the Sketch Version Information to the Gateway
      sendSketchInfo("GuestCombiSensor", "2.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
      present(CHILD_ID_PWM_LIGHT, S_LIGHT);
      present(CHILD_ID_433_1, S_LIGHT);
      present(CHILD_ID_433_2, S_LIGHT);
      present(CHILD_ID_433_3, S_LIGHT);
      present(CHILD_ID_433_4, S_LIGHT);
      present(CHILD_ID_433_5, S_LIGHT);
      present(CHILD_ID_433_6, S_LIGHT);
      
      metric = getConfig().isMetric;
    }
    
    void loop()      
    {   
     readDHT();
     wait(SLEEP_TIME); 
    }
    
    void readDHT() {
      float temperature = dht.getTemperature();
      if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT");
      } else if (temperature != lastTemp) {
        lastTemp = temperature;
        if (!metric) {
          temperature = dht.toFahrenheit(temperature);
        }
        send(msgTemp.set(temperature, 1));
        Serial.print("T: ");
        Serial.println(temperature);
      }
      
      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum) {
          lastHum = humidity;
          send(msgHum.set(humidity, 1));
          Serial.print("H: ");
          Serial.println(humidity);
      }
    }
    
    void changeSwitchStatus(char familyCode, int group, int device, bool status, int retries) {
      for(int i = 0; i < retries; i++) {
        if(status) {
          mySwitch.switchOn(familyCode, group, device);
        } else {
          mySwitch.switchOff(familyCode, group, device);
        }
        wait(50);
      }
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_LIGHT) {
         if(message.sensor==CHILD_ID_PWM_LIGHT) {
            if(message.getBool())
              digitalWrite(PWM_LIGHT_PIN, HIGH);
            else
              digitalWrite(PWM_LIGHT_PIN, LOW);
         } else if(message.sensor==CHILD_ID_433_1) {
            changeSwitchStatus('a', 1, 1, message.getBool(), 3);
         } else if(message.sensor==CHILD_ID_433_2) {
            changeSwitchStatus('a', 1, 2, message.getBool(), 3);
         } else if(message.sensor==CHILD_ID_433_3) {
            changeSwitchStatus('a', 1, 3, message.getBool(), 3);
         } else if(message.sensor==CHILD_ID_433_4) {
            changeSwitchStatus('a', 2, 1, message.getBool(), 3);
         } else if(message.sensor==CHILD_ID_433_5) {
            changeSwitchStatus('a', 2, 2, message.getBool(), 3);
         } else if(message.sensor==CHILD_ID_433_6) {
            changeSwitchStatus('a', 2, 3, message.getBool(), 3);
         }
       } 
    }
    

    I'm pretty amazed on how well this setup works. My wife and I use it daily and I've a scheduled task that switches on an outlet daily. Works like a charm.

    Only limitation: If you send commands too fast, for example switch on outlet 1 & 2 at the same time the outlets get confused. 🙂 Often outlet 3 gets switched on too in that case. Maybe it has something to do with the 3 retries I'm using.



  • @TimO
    Many thanks for your response !
    I have only the 433MHZ transmitter connected without DHT22 and LEDs, but it does not work unfortunately, I do not know what I doing wrong !?
    Shortly after the plug in, while the LED still flashes I do in FHEM "set MYSENSOR_xy status1 on" but without success.


  • Hero Member

    Did you verify that the message is received by the node?
    I'm not familiar with FHEM, please note, that the first outlet uses child ID 4.
    What's the debug output of the node?



  • This post is deleted!


  • This post is deleted!

Log in to reply
 

Suggested Topics

  • 8
  • 7
  • 1
  • 2
  • 1
  • 44

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts