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. Development
  3. some problem in sensor + repeater !

some problem in sensor + repeater !

Scheduled Pinned Locked Moved Development
15 Posts 3 Posters 3.3k 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.
  • R Offline
    R Offline
    Reza
    wrote on last edited by Reza
    #1

    hi i have some problem to convert a node to sensor+repeater !
    for example light sensor :

    #include <SPI.h>
    #include <MySensor.h>  
    #include <BH1750.h>
    #include <Wire.h> 
    
    #define CHILD_ID_LIGHT 0
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    
    BH1750 lightSensor;
    MySensor gw;
    
    // V_LIGHT_LEVEL should only be used for uncalibrated light level 0-100%.
    // If your controller supports the new V_LEVEL variable, use this instead for
    // transmitting LUX light level.
    MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
    // MyMessage msg(CHILD_ID_LIGHT, V_LEVEL);  
    uint16_t lastlux;
    
    void setup()  
    { 
      gw.begin();
    
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Light Lux Sensor", "1.0");
    
      // Register all sensors to gateway (they will be created as child devices)
      gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
      
      lightSensor.begin();
    }
    
    void loop()      
    {     
      uint16_t lux = lightSensor.readLightLevel();// Get Lux value
      Serial.println(lux);
      if (lux != lastlux) {
          gw.send(msg.set(lux));
          lastlux = lux;
      }
      
      gw.sleep(SLEEP_TIME);
    }
    

    i remove lines :
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    and
    gw.sleep(SLEEP_TIME);
    and i add #define MY_REPEATER_FEATURE
    sensor is start to report many lux... each second 1000 report . . .
    please change this code to a repeater+sensor and report every 1 min !

    B 1 Reply Last reply
    0
    • R Reza

      hi i have some problem to convert a node to sensor+repeater !
      for example light sensor :

      #include <SPI.h>
      #include <MySensor.h>  
      #include <BH1750.h>
      #include <Wire.h> 
      
      #define CHILD_ID_LIGHT 0
      unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
      
      BH1750 lightSensor;
      MySensor gw;
      
      // V_LIGHT_LEVEL should only be used for uncalibrated light level 0-100%.
      // If your controller supports the new V_LEVEL variable, use this instead for
      // transmitting LUX light level.
      MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
      // MyMessage msg(CHILD_ID_LIGHT, V_LEVEL);  
      uint16_t lastlux;
      
      void setup()  
      { 
        gw.begin();
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Light Lux Sensor", "1.0");
      
        // Register all sensors to gateway (they will be created as child devices)
        gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
        
        lightSensor.begin();
      }
      
      void loop()      
      {     
        uint16_t lux = lightSensor.readLightLevel();// Get Lux value
        Serial.println(lux);
        if (lux != lastlux) {
            gw.send(msg.set(lux));
            lastlux = lux;
        }
        
        gw.sleep(SLEEP_TIME);
      }
      

      i remove lines :
      unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
      and
      gw.sleep(SLEEP_TIME);
      and i add #define MY_REPEATER_FEATURE
      sensor is start to report many lux... each second 1000 report . . .
      please change this code to a repeater+sensor and report every 1 min !

      B Offline
      B Offline
      boozz
      wrote on last edited by
      #2

      @Reza
      You can change your code yourself: replace gw.sleep(sleep_time) by gw.wait(sleep_time).

      Given the posted code I think you use the MySensors 1.5 libraries.

      BR,

      Boozz

      R 1 Reply Last reply
      1
      • B boozz

        @Reza
        You can change your code yourself: replace gw.sleep(sleep_time) by gw.wait(sleep_time).

        Given the posted code I think you use the MySensors 1.5 libraries.

        BR,

        Boozz

        R Offline
        R Offline
        Reza
        wrote on last edited by Reza
        #3

        @boozz
        hi thank you for help me ,
        now i use 2 library . and in some sketchs (sensor without repeater) , there are 2 line for sleep :
        unsigned long SLEEP_TIME = 30000;
        sleep(SLEEP_TIME);

        for convert this sensors to sensor+repeater , what am i do ?
        add line:
        #define MY_REPEATER_FEATURE

        and change this line to :
        sleep(SLEEP_TIME); ~~> wait(SLEEP_TIME);

        is this correct ?

        B 1 Reply Last reply
        0
        • R Reza

          @boozz
          hi thank you for help me ,
          now i use 2 library . and in some sketchs (sensor without repeater) , there are 2 line for sleep :
          unsigned long SLEEP_TIME = 30000;
          sleep(SLEEP_TIME);

          for convert this sensors to sensor+repeater , what am i do ?
          add line:
          #define MY_REPEATER_FEATURE

          and change this line to :
          sleep(SLEEP_TIME); ~~> wait(SLEEP_TIME);

          is this correct ?

          B Offline
          B Offline
          boozz
          wrote on last edited by
          #4

          @Reza
          Instead of asking people in the forum at every step you take, you could use the trial and error method.

          BR,

          Boozz

          R 1 Reply Last reply
          1
          • B boozz

            @Reza
            Instead of asking people in the forum at every step you take, you could use the trial and error method.

            BR,

            Boozz

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

            @boozz
            :) ok but if it is possible guidance me just This time
            this is true ?
            sleep(SLEEP_TIME); ~~> wait(SLEEP_TIME); ?
            thank you

            B 1 Reply Last reply
            0
            • R Reza

              @boozz
              :) ok but if it is possible guidance me just This time
              this is true ?
              sleep(SLEEP_TIME); ~~> wait(SLEEP_TIME); ?
              thank you

              B Offline
              B Offline
              boozz
              wrote on last edited by
              #6

              @Reza
              just try it and see what happens

              R 1 Reply Last reply
              2
              • B boozz

                @Reza
                just try it and see what happens

                R Offline
                R Offline
                Reza
                wrote on last edited by
                #7

                @boozz said:

                just try it and see what happens

                ok thank you :(

                1 Reply Last reply
                0
                • scalzS Offline
                  scalzS Offline
                  scalz
                  Hardware Contributor
                  wrote on last edited by scalz
                  #8

                  @Reza
                  @boozz has already answered you how to. You should try, that does not hurt, and you may be happy by the result. You don't want a sleeping repeater? better a waiting repeater!
                  That said i would not use the wait, it's possible to code this quicker. But it's a little bit more advanced.
                  I advice you to read some reference about Arduino etc... and try. always try or you don't learn anything!
                  An howto which could be useful for you, perhaps later, is the blink led without delay from Arduino Reference for instance. And lot of other things. That's not always easy to write code for others, can take time or not same config. and others don't learn then..

                  R scalzS 2 Replies Last reply
                  4
                  • scalzS scalz

                    @Reza
                    @boozz has already answered you how to. You should try, that does not hurt, and you may be happy by the result. You don't want a sleeping repeater? better a waiting repeater!
                    That said i would not use the wait, it's possible to code this quicker. But it's a little bit more advanced.
                    I advice you to read some reference about Arduino etc... and try. always try or you don't learn anything!
                    An howto which could be useful for you, perhaps later, is the blink led without delay from Arduino Reference for instance. And lot of other things. That's not always easy to write code for others, can take time or not same config. and others don't learn then..

                    R Offline
                    R Offline
                    Reza
                    wrote on last edited by
                    #9

                    @scalz said:

                    has already answered you how to. You should try, that does not hurt, and you may be happy by the result. You don't want a sleeping repeater? better a waiting repeater!
                    That said i would not use the wait, it's possible to code this quicker. But it's a little bit more advanced.
                    I advice you to read some reference about Arduino etc... and try. always try or you don't learn anything!
                    An howto which could be useful for you, perhaps later, is the blink led without delay from Arduino Reference for instance. And lot of other things. That's not always easy to write code for others, can take time or not same config. and others don't learn then..

                    hi my friend , i know this but about this issue , i need this quickly and I don't have time for begin in arduino and full programming :(

                    1 Reply Last reply
                    0
                    • scalzS Offline
                      scalzS Offline
                      scalz
                      Hardware Contributor
                      wrote on last edited by scalz
                      #10

                      Have you tried ??
                      well, about needing quickly, without learning... you're perhaps misunderstanding a bit things.. imho mysensors is great, open, dynamic community which try to make things easier for noobs. Sure that's very attractive, but don't forget you're in arduino/dev/mcu world...if you don't want to read&learn a minimum, you will be stuck in the examples sketch folders...

                      R 1 Reply Last reply
                      3
                      • scalzS scalz

                        Have you tried ??
                        well, about needing quickly, without learning... you're perhaps misunderstanding a bit things.. imho mysensors is great, open, dynamic community which try to make things easier for noobs. Sure that's very attractive, but don't forget you're in arduino/dev/mcu world...if you don't want to read&learn a minimum, you will be stuck in the examples sketch folders...

                        R Offline
                        R Offline
                        Reza
                        wrote on last edited by
                        #11

                        @scalz said:

                        Have you tried ??
                        well, about needing quickly, without learning... you're perhaps misunderstanding a bit things.. imho mysensors is great, open, dynamic community which try to make things easier for noobs. Sure that's very attractive, but don't forget you're in arduino/dev/mcu world...if you don't want to read&learn a minimum, you will be stuck in the examples sketch folders...
                        i want try to learn but not now ! now i need this quickly :( so after this i try to learn step by step. . .

                        1 Reply Last reply
                        0
                        • scalzS Offline
                          scalzS Offline
                          scalz
                          Hardware Contributor
                          wrote on last edited by
                          #12

                          okay but have you tried wait instead of sleep?? we still don't know..

                          R 1 Reply Last reply
                          1
                          • scalzS scalz

                            okay but have you tried wait instead of sleep?? we still don't know..

                            R Offline
                            R Offline
                            Reza
                            wrote on last edited by
                            #13

                            @scalz said:

                            okay but have you tried wait instead of sleep?? we still don't know..

                            no
                            well , this topic for this !!! i told you , can i replace wait Instead sleep? i fear for The arbitrary action so before i want sure

                            1 Reply Last reply
                            0
                            • scalzS scalz

                              @Reza
                              @boozz has already answered you how to. You should try, that does not hurt, and you may be happy by the result. You don't want a sleeping repeater? better a waiting repeater!
                              That said i would not use the wait, it's possible to code this quicker. But it's a little bit more advanced.
                              I advice you to read some reference about Arduino etc... and try. always try or you don't learn anything!
                              An howto which could be useful for you, perhaps later, is the blink led without delay from Arduino Reference for instance. And lot of other things. That's not always easy to write code for others, can take time or not same config. and others don't learn then..

                              scalzS Offline
                              scalzS Offline
                              scalz
                              Hardware Contributor
                              wrote on last edited by scalz
                              #14

                              No fear to have! A sleep or wait won't burn your node.

                              I told you above:

                              @scalz said:

                              You don't want a sleeping repeater? better a waiting repeater!

                              what do you think ;) Does a repeater should sleep?? If so, how could he listens and repeat? So.. the repeater can't sleep! you would prefer to use wait, so it listens/wait and repeat.
                              I hope this is okay. If you have a problem then why not, but imho your issue is solved.

                              R 1 Reply Last reply
                              0
                              • scalzS scalz

                                No fear to have! A sleep or wait won't burn your node.

                                I told you above:

                                @scalz said:

                                You don't want a sleeping repeater? better a waiting repeater!

                                what do you think ;) Does a repeater should sleep?? If so, how could he listens and repeat? So.. the repeater can't sleep! you would prefer to use wait, so it listens/wait and repeat.
                                I hope this is okay. If you have a problem then why not, but imho your issue is solved.

                                R Offline
                                R Offline
                                Reza
                                wrote on last edited by
                                #15

                                @scalz
                                so i test with wait :) thank you my friend

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


                                19

                                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