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. NodeManager
  4. NodeManager Motion Sensor: how to use the SensorSwitch class?

NodeManager Motion Sensor: how to use the SensorSwitch class?

Scheduled Pinned Locked Moved NodeManager
17 Posts 5 Posters 4.5k Views 6 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.
  • I Offline
    I Offline
    iahim67
    wrote on last edited by
    #3

    I'm not sure about that, what I really want is to learn how to use NodeManager.
    Like how can I make such changes as described.
    I want to experiment a bit and don't know how :simple_smile:

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

      Node manager is made to automate the most common tasks and the pir sensor normally needs to report both status changes, so if you need to experiment you'd probably need to write some code yourself ☺️

      1 Reply Last reply
      0
      • I Offline
        I Offline
        iahim67
        wrote on last edited by
        #5

        You're absolutely right :simple_smile:
        I am experimenting with mysensors as much as I can. My motion sensor works fine without NodeManager ... but I'm interested in NodeManager too.
        Back to my question however, how can solve my issue?

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

          Only author can answer that 😀

          1 Reply Last reply
          0
          • I Offline
            I Offline
            iahim67
            wrote on last edited by
            #7

            That fine ... I just don't know who's the author, I guess I have to solve this issue first :smile: , or I get lucky and he'll read my post!

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

              @user2684 is the guy

              1 Reply Last reply
              0
              • U Offline
                U Offline
                user2684
                Contest Winner
                wrote on last edited by
                #9

                Sorry for the delay guys, for some reasons I haven't got the notification of this thread, thanks @gohan for pulling me in! When using SENSOR_MOTION, the default mode is already RISING. To help you reading through the code, the registerSensor() in NodeManager.cpp would create an instance of the SensorMotion class. SensorMotion is derived from SensorSwitch (which has CHANGE has default mode) but in its constructor (SensorMotion::SensorMotion) you will find a setMode(RISING) which is then the default value.

                Whatever parameter you want to change, this requires three steps:

                • registering the sensor
                • retrieving the instance of the class
                • invoking its functions

                SensorSwitch in your example above is a class, you need the instantiated object to invoke its member functions. So something like the following:

                // register the sensor and keep track of its id
                int sensorPIR = nodeManager.registerSensor(SENSOR_MOTION,3);
                // retrieve the instance of the object. Since getSensor() will return a generic Sensor class, you need to cast it accordingly
                SensorMotion* sensorMotion = (SensorMotion*)nodeManager.getSensor(sensorPIR_Id);
                // invoke whatever function you need. Since sensorMotion is a pointer, you need to use the -> notation
                sensorMotion->setMode(CHANGE);
                sensorMotion->setInitial(LOW);
                

                Does it make sense now?
                Thanks

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  iahim67
                  wrote on last edited by
                  #10

                  Thank you very much sir, it start making sense to me, I still need to "digest" this :smile: as I am a HW engineer ... but trying to improve my SW skills.
                  I am comfortable with the basics of C and Arduino but not really with object oriented programming.
                  What literature would you suggest me to start with to understand this kind of coding? Java perhaps?

                  gohanG 1 Reply Last reply
                  0
                  • I iahim67

                    Thank you very much sir, it start making sense to me, I still need to "digest" this :smile: as I am a HW engineer ... but trying to improve my SW skills.
                    I am comfortable with the basics of C and Arduino but not really with object oriented programming.
                    What literature would you suggest me to start with to understand this kind of coding? Java perhaps?

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

                    @iahim67 c++? 😁

                    1 Reply Last reply
                    0
                    • I Offline
                      I Offline
                      iahim67
                      wrote on last edited by
                      #12

                      I thought you may say that :smile: ... is there a good C++ book for beginners that you would recommend?
                      On paper I mean, that I can buy?

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

                        I could sell you mine, it is still brand new but it is in Italian 😁

                        1 Reply Last reply
                        1
                        • U Offline
                          U Offline
                          user2684
                          Contest Winner
                          wrote on last edited by
                          #14

                          Agree starting from c++ would make more sense :-) Just a silly personal advise: pay attention not to get lost into the tons of capabilities c++ can provide, especially if you want to be just focused on arduino to start with since you can easily get lost. Sometimes I personally prefer just an electronic one-pager with a good amount of examples :-)

                          1 Reply Last reply
                          0
                          • I iahim67

                            I thought you may say that :smile: ... is there a good C++ book for beginners that you would recommend?
                            On paper I mean, that I can buy?

                            TerrenceT Offline
                            TerrenceT Offline
                            Terrence
                            wrote on last edited by
                            #15

                            @iahim67 Simon Monk's Programming Arduino: Getting Started... book is pretty good.

                            Look at the table of contents.

                            https://www.amazon.com/Programming-Arduino-Getting-Started-Sketches/dp/1259641635/

                            1 Reply Last reply
                            0
                            • I Offline
                              I Offline
                              iahim67
                              wrote on last edited by
                              #16

                              Thanks for your help, I'll start with Simon Monk's Programming Arduino :smile: !

                              1 Reply Last reply
                              0
                              • JoeyGJ Offline
                                JoeyGJ Offline
                                JoeyG
                                wrote on last edited by
                                #17
                                This post is deleted!
                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                21

                                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