Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. RF433MHZ sensor

RF433MHZ sensor

Scheduled Pinned Locked Moved Hardware
6 Posts 3 Posters 5.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Terence Faul
    wrote on last edited by
    #1

    Hi I found this sketch in the MySensors library, if does great to sniff 433 codes, can anybody assist in having it create devices that are able to transmit a 433 code to allow control of these devices?

    /*
     * This sketch demonstrates how to use InterruptChain to receive and
     * decode remote switches (old and new) and remote sensors.
     *
     * Basically, this sketch combines the features of the ShowReceivedCode
     * and ShowReceivedCodeNewKaku examples of RemoteSwitch and the
     * ThermoHygroReceiver of RemoteSensor all at the same time!
     *
     * After uploading, enable the serial monitor at 115200 baud.
     * When you press buttons on a 433MHz remote control, as supported by 
     * RemoteSwitch or NewRemoteSwitch, the code will be echoed.
     * At the same time, if data of a remote thermo/hygro-sensor is
     * received, as supported by RemoteSensor, it will be echoed as well.
     *
     * Setup:
     * - connect a 433MHz receiver on digital pin 2.
     *
     *
     * MySensor note: This example has not yet been adopted but can be used as an example
     * of receiving 433Mhz stuff. 
     * 
     * One idea could be to echo received 433 codes back to gateway to be able to pick up and
     * handle data over there.
     *
     */
    
    #include <RemoteReceiver.h>
    #include <NewRemoteReceiver.h>
    #include <SensorReceiver.h>
    #include <InterruptChain.h>
    
    void setup() {
      Serial.begin(115200);
    
      // Interrupt -1 to indicate you will call the interrupt handler with InterruptChain
      RemoteReceiver::init(-1, 2, showOldCode);
      
      // Again, interrupt -1 to indicate you will call the interrupt handler with InterruptChain
      NewRemoteReceiver::init(-1, 2, showNewCode);
    
      // And once more, interrupt -1 to indicate you will call the interrupt handler with InterruptChain
      SensorReceiver::init(-1, showTempHumi);
    
      // On interrupt, call the interrupt handlers of remote and sensor receivers
      InterruptChain::addInterruptCallback(0, RemoteReceiver::interruptHandler);
      InterruptChain::addInterruptCallback(0, NewRemoteReceiver::interruptHandler);
      InterruptChain::addInterruptCallback(0, SensorReceiver::interruptHandler);
    }
    
    void loop() {
       // You can do other stuff here!
    }
    
    // shows the received code sent from an old-style remote switch
    void showOldCode(unsigned long receivedCode, unsigned int period) {
      // Print the received code.
      Serial.print("Code: ");
      Serial.print(receivedCode);
      Serial.print(", period: ");
      Serial.print(period);
      Serial.println("us.");
    }
    
    // Shows the received code sent from an new-style remote switch
    void showNewCode(NewRemoteCode receivedCode) {
      // Print the received code.
      Serial.print("Addr ");
      Serial.print(receivedCode.address);
      
      if (receivedCode.groupBit) {
        Serial.print(" group");
      } else {
        Serial.print(" unit ");
        Serial.print(receivedCode.unit);
      }
      
      switch (receivedCode.switchType) {
        case NewRemoteCode::off:
          Serial.print(" off");
          break;
        case NewRemoteCode::on:
          Serial.print(" on");
          break;
        case NewRemoteCode::dim:
          Serial.print(" dim level ");
          Serial.print(receivedCode.dimLevel);
          break;
        case NewRemoteCode::on_with_dim:
          Serial.print(" on with dim level ");
          Serial.print(receivedCode.dimLevel);
          break;
      }
      
      Serial.print(", period: ");
      Serial.print(receivedCode.period);
      Serial.println("us.");
    }
    
    // Shows the received sensor data
    void showTempHumi(byte *data) {
      // is data a ThermoHygro-device?
      if ((data[3] & 0x1f) == 0x1e) {
        // Yes!
        byte channel, randomId;
        int temp;
        byte humidity;
    
        // Decode the data
        SensorReceiver::decodeThermoHygro(data, channel, randomId, temp, humidity);
      
        // Print temperature. Note: temp is 10x the actual temperature!
        Serial.print("Temperature: ");
        Serial.print(temp / 10); // units
        Serial.print('.');
        Serial.println(temp % 10); // decimal
      }
    }
    

    Regards

    1 Reply Last reply
    0
    • AWIA Offline
      AWIA Offline
      AWI
      Hero Member
      wrote on last edited by
      #2

      For inspiration... this sketch uses a variant of the RemoteTransmitter libraries for European Home Easy (not the same as the UK/ world one). Basically just a creating a 433 Mhz transmitter. with fixed codes.

      https://codebender.cc/sketch:81535

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Terence Faul
        wrote on last edited by Terence Faul
        #3

        does it need a specific library?
        Are codes held in the controller or the sketch?

        on compile I get

        sketch_feb24a:13: error: 'HomeEasyEUSwitch' does not name a type
        sketch_feb24a.ino: In function 'void incomingMessage(const MyMessage&)':
        sketch_feb24a:56: error: 'homeeasySwitch' was not declared in this scope

        AWIA 1 Reply Last reply
        0
        • T Terence Faul

          does it need a specific library?
          Are codes held in the controller or the sketch?

          on compile I get

          sketch_feb24a:13: error: 'HomeEasyEUSwitch' does not name a type
          sketch_feb24a.ino: In function 'void incomingMessage(const MyMessage&)':
          sketch_feb24a:56: error: 'homeeasySwitch' was not declared in this scope

          AWIA Offline
          AWIA Offline
          AWI
          Hero Member
          wrote on last edited by
          #4

          @Terence-Faul Sorry, it was only meant for inspiration, there are some libraries needed. If you don't need the EU HomeEasy, you need to create an instance of the RemoteSwitch. For some examples just search for the Remoteswitch on the net.

          1 Reply Last reply
          0
          • HeinzH Offline
            HeinzH Offline
            Heinz
            Hero Member
            wrote on last edited by Heinz
            #5

            Hi Terence,
            There are a couple of protocols that can be transmitted via 433Mhz. There is no "universal"-receiver that understands all protocols. Which specific type of device do you want to control?

            1 Reply Last reply
            0
            • T Offline
              T Offline
              Terence Faul
              wrote on last edited by
              #6

              I am not sure, I bought some relays from Ebay.

              If I use the MySensors 433RF Sketch, the receiver recognises the remotes.

              /*
               * This sketch demonstrates how to use InterruptChain to receive and
               * decode remote switches (old and new) and remote sensors.
               *
               * Basically, this sketch combines the features of the ShowReceivedCode
               * and ShowReceivedCodeNewKaku examples of RemoteSwitch and the
               * ThermoHygroReceiver of RemoteSensor all at the same time!
               *
               * After uploading, enable the serial monitor at 115200 baud.
               * When you press buttons on a 433MHz remote control, as supported by 
               * RemoteSwitch or NewRemoteSwitch, the code will be echoed.
               * At the same time, if data of a remote thermo/hygro-sensor is
               * received, as supported by RemoteSensor, it will be echoed as well.
               *
               * Setup:
               * - connect a 433MHz receiver on digital pin 2.
               *
               *
               * MySensor note: This example has not yet been adopted but can be used as an example
               * of receiving 433Mhz stuff. 
               * 
               * One idea could be to echo received 433 codes back to gateway to be able to pick up and
               * handle data over there.
               *
               */
              
              #include <RemoteReceiver.h>
              #include <NewRemoteReceiver.h>
              #include <SensorReceiver.h>
              #include <InterruptChain.h>
              
              void setup() {
                Serial.begin(115200);
              
                // Interrupt -1 to indicate you will call the interrupt handler with InterruptChain
                RemoteReceiver::init(-1, 2, showOldCode);
                
                // Again, interrupt -1 to indicate you will call the interrupt handler with InterruptChain
                NewRemoteReceiver::init(-1, 2, showNewCode);
              
                // And once more, interrupt -1 to indicate you will call the interrupt handler with InterruptChain
                SensorReceiver::init(-1, showTempHumi);
              
                // On interrupt, call the interrupt handlers of remote and sensor receivers
                InterruptChain::addInterruptCallback(0, RemoteReceiver::interruptHandler);
                InterruptChain::addInterruptCallback(0, NewRemoteReceiver::interruptHandler);
                InterruptChain::addInterruptCallback(0, SensorReceiver::interruptHandler);
              }
              
              void loop() {
                 // You can do other stuff here!
              }
              
              // shows the received code sent from an old-style remote switch
              void showOldCode(unsigned long receivedCode, unsigned int period) {
                // Print the received code.
                Serial.print("Code: ");
                Serial.print(receivedCode);
                Serial.print(", period: ");
                Serial.print(period);
                Serial.println("us.");
              }
              
              // Shows the received code sent from an new-style remote switch
              void showNewCode(NewRemoteCode receivedCode) {
                // Print the received code.
                Serial.print("Addr ");
                Serial.print(receivedCode.address);
                
                if (receivedCode.groupBit) {
                  Serial.print(" group");
                } else {
                  Serial.print(" unit ");
                  Serial.print(receivedCode.unit);
                }
                
                switch (receivedCode.switchType) {
                  case NewRemoteCode::off:
                    Serial.print(" off");
                    break;
                  case NewRemoteCode::on:
                    Serial.print(" on");
                    break;
                  case NewRemoteCode::dim:
                    Serial.print(" dim level ");
                    Serial.print(receivedCode.dimLevel);
                    break;
                  case NewRemoteCode::on_with_dim:
                    Serial.print(" on with dim level ");
                    Serial.print(receivedCode.dimLevel);
                    break;
                }
                
                Serial.print(", period: ");
                Serial.print(receivedCode.period);
                Serial.println("us.");
              }
              
              // Shows the received sensor data
              void showTempHumi(byte *data) {
                // is data a ThermoHygro-device?
                if ((data[3] & 0x1f) == 0x1e) {
                  // Yes!
                  byte channel, randomId;
                  int temp;
                  byte humidity;
              
                  // Decode the data
                  SensorReceiver::decodeThermoHygro(data, channel, randomId, temp, humidity);
                
                  // Print temperature. Note: temp is 10x the actual temperature!
                  Serial.print("Temperature: ");
                  Serial.print(temp / 10); // units
                  Serial.print('.');
                  Serial.println(temp % 10); // decimal
                }
              }
              
              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              11

              Online

              11.7k

              Users

              11.2k

              Topics

              113.0k

              Posts


              Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • MySensors
              • OpenHardware.io
              • Categories
              • Recent
              • Tags
              • Popular