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. OpenHardware.io
  3. 💬 OH 433Mhz Mysensors Bridge

💬 OH 433Mhz Mysensors Bridge

Scheduled Pinned Locked Moved OpenHardware.io
contest2017mysensors433mhz
4 Posts 3 Posters 2.1k 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.
  • openhardware.ioO Offline
    openhardware.ioO Offline
    openhardware.io
    wrote on last edited by
    #1

    https://www.openhardware.io/view/351/OH-433Mhz-Mysensors-Bridge

    rvendrameR 1 Reply Last reply
    0
    • L Offline
      L Offline
      LastSamurai
      Hardware Contributor
      wrote on last edited by
      #2

      I have just received two new (433 Mhz) switches that I will add to my network :) I also just upgraded my serial gateway to use a PLNA+ module and an external power supply, which seems to make the whole network react a little faster too. I will post a update once its done. I might also design a proper pcb for this bridge, maybe even in combination with a gateway.

      1 Reply Last reply
      0
      • openhardware.ioO openhardware.io

        https://www.openhardware.io/view/351/OH-433Mhz-Mysensors-Bridge

        rvendrameR Offline
        rvendrameR Offline
        rvendrame
        Hero Member
        wrote on last edited by rvendrame
        #3

        @LastSamurai , thanks for the great work. I just built one of these and it is working great.

        If your controller accepts long scene numbers (like my Vera does), we have the option to present it as a scene controller, instead individual buttons. The scene number will be the number of the button pressed. That makes life easy to add new panels around the house.

        Bellow is the sketch I created, based on your example. I also added a short/long-press logic, so for example for a 3-button panel, 6 different scenes can be triggered.

        /*
          This is a gateway node between mysensors and 433Mhz devices. A 433Mhz receiver is connected to pin 3 (int 1).
          This works with any 433Mhz device (as long as rc-switch understands the protocol).
        
          This is based on the MySensors network: https://www.mysensors.org
          This uses the rc-switch library to detect button presses: https://github.com/sui77/rc-switch
        
          Written by Oliver Hilsky 07.03.2017
          Adjusted to Scene controller by Ricardo Vendrame  03.06.2017 
        */
        
        #define LONG_PRESS_OFFSET 10000000UL  // Offset for long-press
        #define LONG_PRESS_COUNT  5           // Number of messages for long-press
        
        #define MY_RADIO_NRF24
        //#define MY_NODE_ID 25
        #define MY_BAUD_RATE 115200
        #define MY_DEBUG    // Enables debug messages in the serial log
        #define VCC_PIN 5
        #define GND_PIN 2
        #define RECEIVER_PIN 3
        
        //#include <EEPROM.h>
        #include <SPI.h>
        #include <MyConfig.h>
        #include <MySensor.h>
        //#include <Vcc.h>
        #include <RCSwitch.h>
        
        MySensor gw; 
        MyMessage msgSceneOn( 0 , V_SCENE_ON ); 
        MyMessage msgSceneOff( 0, V_SCENE_OFF ); 
        
        RCSwitch wirelessSwitch = RCSwitch();
        
        // Short/long press control 
        unsigned long lastreceive, count; 
        
        // add the decimal codes for your switches here
        unsigned long received_val; 
        
        void presentation()
        {
           
        #ifdef MY_NODE_ID
          gw.begin(NULL, MY_NODE_ID, false);
        #else
          gw.begin(NULL,AUTO,false);
        #endif
        
          gw.sendSketchInfo("433 Wireless Gateway", "1.0");
          gw.present( 0 , S_SCENE_CONTROLLER );
        
        }
        
        void setup() {
          
          Serial.begin(MY_BAUD_RATE); 
        
          // Power to Radio... 
          pinMode( VCC_PIN , OUTPUT ); 
          pinMode( GND_PIN , OUTPUT ); 
          digitalWrite( GND_PIN , LOW ); 
          digitalWrite( VCC_PIN , HIGH ); 
        
          // mySensors startup
          presentation(); 
          
          // Enable 433 receiving 
          wirelessSwitch.enableReceive(RECEIVER_PIN-2);  // Receiver on interrupt 
          
          Serial.println("Started listening on pin 3 for incoming 433Mhz messages");
        
          lastreceive = millis(); 
          
        }
        
        void loop() {
        
          gw.process(); 
          
          if ( wirelessSwitch.available() ) {  
        
            if ( ( millis() - lastreceive ) <= 200 ) count ++;
              else count = 1; 
              
            received_val = wirelessSwitch.getReceivedValue();
            wirelessSwitch.resetAvailable();
        
            lastreceive = millis(); 
            //Serial.println( lastreceive ); 
            
          }
        
          if ( count >= LONG_PRESS_COUNT || 
           ( ( millis() - lastreceive ) > 200 && count > 0 ) ) {
            
            // Send scene ID to the gateway
            if ( count >= LONG_PRESS_COUNT ) 
               received_val += LONG_PRESS_OFFSET;
                
            gw.send( msgSceneOn.set( received_val )); 
            
            Serial.print("Scene ");
            Serial.print( received_val ); 
            Serial.println( count < LONG_PRESS_COUNT ? " ON" : " OFF"); 
        
            // software debounce
            gw.wait(750); 
            //delay(750);
            count = 0; 
            wirelessSwitch.resetAvailable();
        
        
          } 
        
        }
        
        

        The edge for short/long press is defined by count of messages received (each message takes about 100ms to be received), so the default "5" in the sketch defines >= ~500ms as long press.

        #define LONG_PRESS_COUNT  5           // Number of messages for long-press
        

        And to distinguish between short and long press, a offset is added to the button number, defined here:

        #define LONG_PRESS_OFFSET 10000000UL  // Offset for long-press
        

        Home Assistant / Vera Plus UI7
        ESP8266 GW + mySensors 2.3.2
        Alexa / Google Home

        1 Reply Last reply
        1
        • L Offline
          L Offline
          LastSamurai
          Hardware Contributor
          wrote on last edited by
          #4

          Wow, great! Its alway nice to see others using my work too. Your code improvement seem to be very helpful too.
          I have most recently also integrated this directly into my gateway build (see here). I am still struggling with code there though.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          18

          Online

          11.7k

          Users

          11.2k

          Topics

          113.1k

          Posts


          Copyright 2025 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