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. Controllers
  3. Home Assistant
  4. RF433 MHZ connected to Serial Gateway

RF433 MHZ connected to Serial Gateway

Scheduled Pinned Locked Moved Home Assistant
7 Posts 3 Posters 1.2k Views 4 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.
  • R Offline
    R Offline
    ryolaxe
    wrote on last edited by
    #1

    Hello,

    I'm running a few nodes with a serial gateway with Hats.io but I would like to add a 433 MHz transmitter directly on the gateway to control a few devices (ON / OFF with DiO codes), but I can't find a way to add it in the loop (via serial listening) without blocking the other messages coming from NRF24L01 nodes.
    Do you have an idea ?

    #define MY_DEBUG
    #define MY_GATEWAY_SERIAL
    #define MY_INCLUSION_MODE_FEATURE
    #define MY_INCLUSION_MODE_DURATION 60
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    #define MY_RADIO_NRF24
    
    #define MY_RF24_PA_LEVEL (RF24_PA_MAX)
    
    #define CHILD_ID_HUM  0
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_STATE_RAD_SALON 4
    
    #include <SPI.h>
    #include <MySensors.h>
    
    #include <DiOremote.h>
    const unsigned long OFF_CODE  = 1278825104;
    const unsigned long ON_CODE = 1278825088;
    const int TX_PIN = 2;
    DiOremote myRemote = DiOremote(TX_PIN);
    
    #include <Custom_SHT.h>
    Custom_SHT SHT;
    static bool metric = true;
    
    uint32_t period = 1 * 60000L;
    static const uint64_t UPDATE_INTERVAL = 60000;
    
    String incomingByte;
    
    
    void presentation()  
    { 
      // Send the sketch info to the gateway
      sendSketchInfo("TemperatureAndHumidity", "1.0");
    
      // Present sensors as children to gateway
      present(CHILD_ID_HUM, S_HUM,   "Humidity");
      present(CHILD_ID_TEMP, S_TEMP, "Temperature");
      //present(CHILD_ID_STATE_RAD_SALON, S_CUSTOM);
    
      metric = getControllerConfig().isMetric;
    }
    
    void setup()
    {
    
    }
    
    
    void loop()      
    {  
      // Read temperature & humidity from sensor.
    
      unsigned long start = millis();
      SHT.begin();
      float humidity = SHT.GetHumidity();
      float temperature = SHT.GetTemperature();
      static MyMessage msgHum( CHILD_ID_HUM,  V_HUM );
      static MyMessage msgTem(CHILD_ID_TEMP, V_TEMP);
    
      send(msgTem.set(temperature, 2));
      send(msgHum.set(humidity, 2));
      for( uint32_t tStart = millis();  (millis()-tStart) < period;  ){
        if (Serial.available() > 0) {
          // read the incoming byte:
          String Incoming = Serial.readString();
          if (Incoming = "0") {
          // say what you got:
          Serial.print("I received: ");
          Serial.println(incomingByte);
          myRemote.send(OFF_CODE);
          }
        if (Incoming = "1") {
          // say what you got:
          Serial.print("I received: ");
          Serial.println(incomingByte);
          myRemote.send(ON_CODE);
          }
        }
      }
      // Sleep until next update to save energy (deactivated for now)
      //sleep(UPDATE_INTERVAL); 
    }
    

    Thanks,

    mfalkviddM 1 Reply Last reply
    0
    • R ryolaxe

      Hello,

      I'm running a few nodes with a serial gateway with Hats.io but I would like to add a 433 MHz transmitter directly on the gateway to control a few devices (ON / OFF with DiO codes), but I can't find a way to add it in the loop (via serial listening) without blocking the other messages coming from NRF24L01 nodes.
      Do you have an idea ?

      #define MY_DEBUG
      #define MY_GATEWAY_SERIAL
      #define MY_INCLUSION_MODE_FEATURE
      #define MY_INCLUSION_MODE_DURATION 60
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      #define MY_RADIO_NRF24
      
      #define MY_RF24_PA_LEVEL (RF24_PA_MAX)
      
      #define CHILD_ID_HUM  0
      #define CHILD_ID_TEMP 1
      #define CHILD_ID_STATE_RAD_SALON 4
      
      #include <SPI.h>
      #include <MySensors.h>
      
      #include <DiOremote.h>
      const unsigned long OFF_CODE  = 1278825104;
      const unsigned long ON_CODE = 1278825088;
      const int TX_PIN = 2;
      DiOremote myRemote = DiOremote(TX_PIN);
      
      #include <Custom_SHT.h>
      Custom_SHT SHT;
      static bool metric = true;
      
      uint32_t period = 1 * 60000L;
      static const uint64_t UPDATE_INTERVAL = 60000;
      
      String incomingByte;
      
      
      void presentation()  
      { 
        // Send the sketch info to the gateway
        sendSketchInfo("TemperatureAndHumidity", "1.0");
      
        // Present sensors as children to gateway
        present(CHILD_ID_HUM, S_HUM,   "Humidity");
        present(CHILD_ID_TEMP, S_TEMP, "Temperature");
        //present(CHILD_ID_STATE_RAD_SALON, S_CUSTOM);
      
        metric = getControllerConfig().isMetric;
      }
      
      void setup()
      {
      
      }
      
      
      void loop()      
      {  
        // Read temperature & humidity from sensor.
      
        unsigned long start = millis();
        SHT.begin();
        float humidity = SHT.GetHumidity();
        float temperature = SHT.GetTemperature();
        static MyMessage msgHum( CHILD_ID_HUM,  V_HUM );
        static MyMessage msgTem(CHILD_ID_TEMP, V_TEMP);
      
        send(msgTem.set(temperature, 2));
        send(msgHum.set(humidity, 2));
        for( uint32_t tStart = millis();  (millis()-tStart) < period;  ){
          if (Serial.available() > 0) {
            // read the incoming byte:
            String Incoming = Serial.readString();
            if (Incoming = "0") {
            // say what you got:
            Serial.print("I received: ");
            Serial.println(incomingByte);
            myRemote.send(OFF_CODE);
            }
          if (Incoming = "1") {
            // say what you got:
            Serial.print("I received: ");
            Serial.println(incomingByte);
            myRemote.send(ON_CODE);
            }
          }
        }
        // Sleep until next update to save energy (deactivated for now)
        //sleep(UPDATE_INTERVAL); 
      }
      

      Thanks,

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by mfalkvidd
      #2

      Hi @ryolaxe, welcome to the forum.

      How to do this depends mainly on how the DiOremote library works. I tried to google for it, but wasn't able to find it. Could you share a link to its documentation/source code?

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ryolaxe
        wrote on last edited by ryolaxe
        #3

        Hello and thanks for your reply,

        I don’t have a documentation but I downloaded it here : http://charleslabs.fr/fr/project-Contrôle+de+prises+DiO+avec+Arduino.

        But I think I could use RCSwitch instead.

        mfalkviddM 1 Reply Last reply
        0
        • R ryolaxe

          Hello and thanks for your reply,

          I don’t have a documentation but I downloaded it here : http://charleslabs.fr/fr/project-Contrôle+de+prises+DiO+avec+Arduino.

          But I think I could use RCSwitch instead.

          mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #4

          @ryolaxe seems like the protocol needs quite precise timing, so it might not be possible to send working commands and still handle incoming messages.

          One thing you could do is to set DiOremote_DEFAULT_TRY_COUNT to 1 and call myRemote.send 5 times from the loop, checking serial between each call. You would probably need to add a queue to handle the incoming messages.

          An (maybe easier) alternative is to move the code for the 433 transmitter to a separate node so it doesn't need to handle incoming messages for other nodes.

          R 1 Reply Last reply
          0
          • mfalkviddM mfalkvidd

            @ryolaxe seems like the protocol needs quite precise timing, so it might not be possible to send working commands and still handle incoming messages.

            One thing you could do is to set DiOremote_DEFAULT_TRY_COUNT to 1 and call myRemote.send 5 times from the loop, checking serial between each call. You would probably need to add a queue to handle the incoming messages.

            An (maybe easier) alternative is to move the code for the 433 transmitter to a separate node so it doesn't need to handle incoming messages for other nodes.

            R Offline
            R Offline
            ryolaxe
            wrote on last edited by ryolaxe
            #5

            @mfalkvidd Alright.
            Thanks for your quick analysis, I’ll put it on a different node to start then if I find the time, i’ll Try to add it to the gateway.

            1 Reply Last reply
            1
            • alowhumA Offline
              alowhumA Offline
              alowhum
              Plugin Developer
              wrote on last edited by
              #6

              I tried to create a gateway with this functionality too, but stopped because it took too much memory, and indeed requires an uninterrupted high speeds burst of signals once in a while.

              I have now been working on a node that can recognise and replay signals. It's universal: it can copy and then recognise and replay any signal. Well, any signal from 4 to 16 bytes. Which is all of them as far as I can tell. No need to mess with timings, it figures that out as well. It compresses the signals an stores them in EEPROM. On average 25 replayable signals can be stored in 512 bytes of storage this way. If you only want to re-detect the signal it's about 50.

              If you wait a few days I'll have some working code I can share.

              1 Reply Last reply
              1
              • alowhumA Offline
                alowhumA Offline
                alowhum
                Plugin Developer
                wrote on last edited by
                #7

                As promised, here's a link to the project.

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


                23

                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