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. How do I get multiple different mock barometers?

How do I get multiple different mock barometers?

Scheduled Pinned Locked Moved Development
53 Posts 6 Posters 10.9k Views 5 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.
  • N Offline
    N Offline
    NeverDie
    Hero Member
    wrote on last edited by NeverDie
    #12

    In what library file does "msg_S_BARO_P(ID_S_BARO,V_PRESSURE)" get defined? Maybe I could just go there and create a new thing, called "msg_S_BARO_P2(ID_S_BARO2,V_PRESSURE2)" Then maybe I'd have two different, but similar, barometer things to use for transporting the voltage measurements I want to send?

    It just seems strange, though. Surely I can't be the first person to run into this? For instance, lots of people have more than one TH sensor. The same type of limitation would seem to apply to multiple TH sensors as well.

    mfalkviddM 1 Reply Last reply
    0
    • N NeverDie

      In what library file does "msg_S_BARO_P(ID_S_BARO,V_PRESSURE)" get defined? Maybe I could just go there and create a new thing, called "msg_S_BARO_P2(ID_S_BARO2,V_PRESSURE2)" Then maybe I'd have two different, but similar, barometer things to use for transporting the voltage measurements I want to send?

      It just seems strange, though. Surely I can't be the first person to run into this? For instance, lots of people have more than one TH sensor. The same type of limitation would seem to apply to multiple TH sensors as well.

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

      @NeverDie https://www.mysensors.org/build/pressure has an example on how to use two child IDs to report two values. Just use the same type for both, but different child ids.

      Multiple child ids is one of the basics of MySensors. I've actually never considered that people might not know how to use them :)

      N 1 Reply Last reply
      3
      • mfalkviddM mfalkvidd

        @NeverDie https://www.mysensors.org/build/pressure has an example on how to use two child IDs to report two values. Just use the same type for both, but different child ids.

        Multiple child ids is one of the basics of MySensors. I've actually never considered that people might not know how to use them :)

        N Offline
        N Offline
        NeverDie
        Hero Member
        wrote on last edited by
        #14

        @mfalkvidd
        Can I use that as a pattern, then, to add more than one child ID to the barometer as well?

        mfalkviddM 1 Reply Last reply
        0
        • N NeverDie

          @mfalkvidd
          Can I use that as a pattern, then, to add more than one child ID to the barometer as well?

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

          @NeverDie yes. use something like

          #define BARO_1_CHILD 0
          #define BARO_2_CHILD 1
          ...
          MyMessage pressure1Msg(BARO_1_CHILD, V_PRESSURE);
          MyMessage pressure2Msg(BARO_2_CHILD, V_PRESSURE);
          ...
          present(BARO_1_CHILD, S_BARO);
          present(BARO_2_CHILD, S_BARO);
          ...
          send(pressure1Msg.set(pressure1, 0));
          send(pressure2Msg.set(pressure2, 0));
          

          You can of course use arrays and/or loops if you prefer that (like the relay example does), but duplicating the code like this makes it more readable when you only have a few sensors.

          Do you think there is something we could add to the examples or the documentation to make it clearer how to use child ids?

          1 Reply Last reply
          1
          • mfalkviddM Offline
            mfalkviddM Offline
            mfalkvidd
            Mod
            wrote on last edited by
            #16

            Child id is also described at https://www.mysensors.org/download/sensor_api_20#presentation

            N 1 Reply Last reply
            1
            • mfalkviddM mfalkvidd

              Child id is also described at https://www.mysensors.org/download/sensor_api_20#presentation

              N Offline
              N Offline
              NeverDie
              Hero Member
              wrote on last edited by
              #17

              @mfalkvidd said in How do I get multiple different mock barometers?:

              Child id is also described at https://www.mysensors.org/download/sensor_api_20#presentation

              Thanks for that link. It certainly helps. It's funny, though, that in the simple example NODE_ID appears to be completely undefined. I assume it's missing this line?

              #define NODE_ID 0
              
              mfalkviddM 1 Reply Last reply
              0
              • N NeverDie

                @mfalkvidd said in How do I get multiple different mock barometers?:

                Child id is also described at https://www.mysensors.org/download/sensor_api_20#presentation

                Thanks for that link. It certainly helps. It's funny, though, that in the simple example NODE_ID appears to be completely undefined. I assume it's missing this line?

                #define NODE_ID 0
                
                mfalkviddM Offline
                mfalkviddM Offline
                mfalkvidd
                Mod
                wrote on last edited by mfalkvidd
                #18

                @NeverDie if NODE_ID is not defined in the sketch, the controller will(/needs to) provide the next available node id.
                https://www.mysensors.org/download/sensor_api_20#received-node-id

                Node id 0 is reserved for the gateway.

                N 1 Reply Last reply
                0
                • K Offline
                  K Offline
                  korttoma
                  Hero Member
                  wrote on last edited by korttoma
                  #19

                  The correct line for API 2.x is actually:

                  #define MY_NODE_ID 1
                  
                  • Tomas
                  1 Reply Last reply
                  1
                  • mfalkviddM mfalkvidd

                    @NeverDie if NODE_ID is not defined in the sketch, the controller will(/needs to) provide the next available node id.
                    https://www.mysensors.org/download/sensor_api_20#received-node-id

                    Node id 0 is reserved for the gateway.

                    N Offline
                    N Offline
                    NeverDie
                    Hero Member
                    wrote on last edited by NeverDie
                    #20

                    @mfalkvidd said in How do I get multiple different mock barometers?:

                    Node id 0 is reserved for the gateway.

                    The text of the wiki says:

                    child-sensor-id This is where you specify the child sensor that's reporting the data. In the example we only have one child sensor so we pick 0.

                    So, based on @mfalkvidd and @korttoma remarks, that is wrong and we should avoid naming child sensor id's as zero? Or, is this confusing the node-id with the child-id?

                    Regarding the node-id, doesn't the gateway provide the actual node-id, not the programmer?

                    mfalkviddM 1 Reply Last reply
                    0
                    • N NeverDie

                      @mfalkvidd said in How do I get multiple different mock barometers?:

                      Node id 0 is reserved for the gateway.

                      The text of the wiki says:

                      child-sensor-id This is where you specify the child sensor that's reporting the data. In the example we only have one child sensor so we pick 0.

                      So, based on @mfalkvidd and @korttoma remarks, that is wrong and we should avoid naming child sensor id's as zero? Or, is this confusing the node-id with the child-id?

                      Regarding the node-id, doesn't the gateway provide the actual node-id, not the programmer?

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

                      @NeverDie child sensor id and sensor node id are different things.

                      A sensor node (usually arduino + radio) has a node id. Node id 0 is reserved for the gateway. A sensor node can have many child sensors (two bme280 for example). There is no reservation for child sensor id (except maybe 255, I think that is used by some controllers for special data)

                      1 Reply Last reply
                      2
                      • N Offline
                        N Offline
                        NeverDie
                        Hero Member
                        wrote on last edited by
                        #22

                        I have it working now, but why are:

                        #define LONG_WAIT 500
                        #define SHORT_WAIT 50
                        
                        

                        needed?

                        R gohanG 2 Replies Last reply
                        0
                        • N NeverDie

                          I have it working now, but why are:

                          #define LONG_WAIT 500
                          #define SHORT_WAIT 50
                          
                          

                          needed?

                          R Offline
                          R Offline
                          rmtucker
                          wrote on last edited by
                          #23

                          @NeverDie
                          Why barometer instead of voltage and multimeter?

                          N 1 Reply Last reply
                          0
                          • R rmtucker

                            @NeverDie
                            Why barometer instead of voltage and multimeter?

                            N Offline
                            N Offline
                            NeverDie
                            Hero Member
                            wrote on last edited by
                            #24

                            @rmtucker said in How do I get multiple different mock barometers?:

                            @NeverDie
                            Why barometer instead of voltage and multimeter?

                            No real reason anymore. If you rewind the tape to the beginning, though, it was because barometer compiled and volt meter didn't.

                            R 1 Reply Last reply
                            0
                            • N NeverDie

                              I have it working now, but why are:

                              #define LONG_WAIT 500
                              #define SHORT_WAIT 50
                              
                              

                              needed?

                              gohanG Offline
                              gohanG Offline
                              gohan
                              Mod
                              wrote on last edited by
                              #25

                              @NeverDie said in How do I get multiple different mock barometers?:

                              I have it working now, but why are:

                              #define LONG_WAIT 500
                              #define SHORT_WAIT 50
                              
                              

                              needed?

                              I think those are used in the code to delay the sending of mock values

                              N 1 Reply Last reply
                              0
                              • N NeverDie

                                @rmtucker said in How do I get multiple different mock barometers?:

                                @NeverDie
                                Why barometer instead of voltage and multimeter?

                                No real reason anymore. If you rewind the tape to the beginning, though, it was because barometer compiled and volt meter didn't.

                                R Offline
                                R Offline
                                rmtucker
                                wrote on last edited by
                                #26

                                @NeverDie

                                Here is a little sketch that compiles on the NRF5.

                                // Enable debug prints to serial monitor
                                //#define MY_DEBUG
                                
                                // Enable and select radio type attached
                                #define MY_RADIO_NRF5_ESB
                                
                                /**
                                   @def MY_NRF5_ESB_PA_LEVEL
                                   @brief Default nRF5 PA level. Override in sketch if needed.
                                
                                   - NRF5_PA_MIN = -40dBm
                                   - NRF5_PA_LOW = -16dBm
                                   - NRF5_PA_HIGH = 0dBm
                                   - NRF5_PA_MAX = 4dBm
                                */
                                #define MY_NRF5_ESB_PA_LEVEL (NRF5_PA_MAX)
                                
                                #define MY_NRF5_ESB_CHANNEL (76)
                                
                                #define MY_NRF5_ESB_MODE (NRF5_250KBPS)
                                
                                #define MY_NODE_ID 10
                                #define VOLTAGE     0
                                #include <MySensors.h>
                                
                                float vcc = (hwCPUVoltage() / 1000.0);
                                
                                MyMessage VoltageMsg(VOLTAGE, V_VOLTAGE);
                                
                                void presentation()
                                {
                                  sendSketchInfo("General sensor", "1.0");
                                  present(VOLTAGE, S_MULTIMETER);
                                }
                                
                                
                                void setup() {
                                //  Serial.begin(115200);
                                //  while (!Serial) ; // wait for Arduino Serial Monitor
                                }
                                
                                void loop() {
                                  send(VoltageMsg.set(vcc, 3));
                                //  Serial.print(F("Voltage = "));
                                //  Serial.print(vcc, 3);
                                //  Serial.println(F("v"));
                                  sleep(60000);
                                }
                                
                                
                                N 1 Reply Last reply
                                1
                                • gohanG gohan

                                  @NeverDie said in How do I get multiple different mock barometers?:

                                  I have it working now, but why are:

                                  #define LONG_WAIT 500
                                  #define SHORT_WAIT 50
                                  
                                  

                                  needed?

                                  I think those are used in the code to delay the sending of mock values

                                  N Offline
                                  N Offline
                                  NeverDie
                                  Hero Member
                                  wrote on last edited by NeverDie
                                  #27

                                  @gohan said in How do I get multiple different mock barometers?:

                                  @NeverDie said in How do I get multiple different mock barometers?:

                                  I have it working now, but why are:

                                  #define LONG_WAIT 500
                                  #define SHORT_WAIT 50
                                  
                                  

                                  needed?

                                  I think those are used in the code to delay the sending of mock values

                                  Yes, but why? Is it to give the serial gateway time to process it?

                                  I'd like to know the motivation for it because I'm using an ESP8266 as my serial gateway (the Easy-Peasy), and it's considerably faster than, say, an Arduino UNO. For instance, maybe it doesn't need these delays on the sending side to keep up.

                                  1 Reply Last reply
                                  0
                                  • gohanG Offline
                                    gohanG Offline
                                    gohan
                                    Mod
                                    wrote on last edited by
                                    #28

                                    I think it's more related to allow enough time for people to read the log without flooding it

                                    N 2 Replies Last reply
                                    0
                                    • gohanG gohan

                                      I think it's more related to allow enough time for people to read the log without flooding it

                                      N Offline
                                      N Offline
                                      NeverDie
                                      Hero Member
                                      wrote on last edited by
                                      #29

                                      @gohan said in How do I get multiple different mock barometers?:

                                      I think it's more related to allow enough time for people to read the log without flooding it

                                      LOL. Glad I asked!

                                      1 Reply Last reply
                                      0
                                      • gohanG gohan

                                        I think it's more related to allow enough time for people to read the log without flooding it

                                        N Offline
                                        N Offline
                                        NeverDie
                                        Hero Member
                                        wrote on last edited by NeverDie
                                        #30

                                        @gohan said in How do I get multiple different mock barometers?:

                                        I think it's more related to allow enough time for people to read the log without flooding it

                                        No, there's more going on than just that apparently. If I reduce their value to zero, it bombs. Reducing short-wait to zero causes the mote to get stuck in a loop somewhere, and reducing long-wait to zero causes the gateway to miss receiving some packets.

                                        If these examples are meant to teach, it sure would be nice if it was documented code!

                                        mfalkviddM 1 Reply Last reply
                                        0
                                        • gohanG Offline
                                          gohanG Offline
                                          gohan
                                          Mod
                                          wrote on last edited by
                                          #31

                                          It is always good practice not to flood the gateway anyway :)

                                          1 Reply Last reply
                                          0

                                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                          With your input, this post could be even better 💗

                                          Register Login
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          18

                                          Online

                                          12.1k

                                          Users

                                          11.2k

                                          Topics

                                          113.4k

                                          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