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. Combine multisensor with switch

Combine multisensor with switch

Scheduled Pinned Locked Moved Development
10 Posts 4 Posters 4.0k Views 3 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.
  • n3roN Offline
    n3roN Offline
    n3ro
    wrote on last edited by n3ro
    #1

    Hey Guys,

    I want to build a USB-powered-sensor. I need to change an internal variable per switch. There is not a pin to be driven.

    link to sketch

    I have not yet understood how the interrupt and the time for reading the sensors is maintained. is that even possible?

    Regards,
    n3ro

    pimatic + MySensors + Homeduino + z-way
    https://github.com/n3roGit/MySensors_n3ro

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maltimus
      wrote on last edited by
      #2

      Not sure I completely understand what you are wanting to accomplish, are you wanting to change some variable in your code from the z-wave controller? This is possible(limited), but we need to know a little before we can help you with this. What type of variable are you wanting to chance(bool, int, float, char, string)?

      Interrupts and read times:
      Assuming you uncomment the code you have in your loop; the line that reads "gw.sleep(PIR_SENSOR_DIGITAL - 2, CHANGE, SLEEP_TIME);" is what is controlling the interrupt and sleep timing. This is saying that if the PIR_SENSOR_DIGITAL pin CHANGE(s) states, continue the loop. SLEEP_TIME sets the amount of time between triggering a timer interrupt(in other words the amount of time before continuing even if the PIR interrupt is not triggered).

      1 Reply Last reply
      0
      • n3roN Offline
        n3roN Offline
        n3ro
        wrote on last edited by n3ro
        #3

        Hey =)
        Sorry my question wasn't good.

        Let me explain what i mean.
        I have just updated my sketch in Github to make i a little bit better to understood (there is no z-wave component).

        I want to Build a USB-powered-sensor with the following functions:

        1. Read some Sensors every x Seconds (done with millis and working)
        2. Read a PIR (done and working without interrupt)
        3. Read AirQuality (implemented but never tested because i haven't this component at the moment)
        4. If Smoke is detected make alarm with beeper (same like the AirQuality Sensor)
        5. a switch to disable the beeper (i don't know how to implement this)

        I hope it's better to follow.

        Regards,
        n3ro

        Update:
        This is the beeper

        pimatic + MySensors + Homeduino + z-way
        https://github.com/n3roGit/MySensors_n3ro

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jan Gatzke
          wrote on last edited by
          #4

          What exactly should the switch do? Silence the alert till what?

          n3roN 1 Reply Last reply
          0
          • J Jan Gatzke

            What exactly should the switch do? Silence the alert till what?

            n3roN Offline
            n3roN Offline
            n3ro
            wrote on last edited by
            #5

            @Jan-Gatzke

            Yes, i want to disable the Smoke alarm, because sometime i make really much smoke in the kitchen without any fire :D

            pimatic + MySensors + Homeduino + z-way
            https://github.com/n3roGit/MySensors_n3ro

            AWIA 1 Reply Last reply
            0
            • n3roN n3ro

              @Jan-Gatzke

              Yes, i want to disable the Smoke alarm, because sometime i make really much smoke in the kitchen without any fire :D

              AWIA Offline
              AWIA Offline
              AWI
              Hero Member
              wrote on last edited by
              #6

              @n3ro I read from you information that you need a kind of switch to disable some functionality in your sketch. You can implement this by creating booleans (best stored in EEPROM) that indicate the current state of the the switch. In the "incomingMessage" code frrom your sketch the framework is present (in the commented part). You can define a boolean for the Beeper which can be switched on/off by the incoming message.

              (you need to define the beeper_id as a switch (S_LIGHT) and the status beeperState first..

              void incomingMessage(const MyMessage &message) //Turn Alarm on/off
              {
                // We only expect one type of message from controller. But we better check anyway.
                if (message.type == V_LIGHT) {
                   // Change beeper on/off  
                  if (message.sensor == beeper_id){ 				// check if message is beeper
              		beeperState = message.getBool(); 
              		gw.saveState( message.sensor,  beeperState ); // save sensor state in EEPROM (location == sensor number)
              		}
                  }
              }
              
              
              n3roN 1 Reply Last reply
              0
              • AWIA AWI

                @n3ro I read from you information that you need a kind of switch to disable some functionality in your sketch. You can implement this by creating booleans (best stored in EEPROM) that indicate the current state of the the switch. In the "incomingMessage" code frrom your sketch the framework is present (in the commented part). You can define a boolean for the Beeper which can be switched on/off by the incoming message.

                (you need to define the beeper_id as a switch (S_LIGHT) and the status beeperState first..

                void incomingMessage(const MyMessage &message) //Turn Alarm on/off
                {
                  // We only expect one type of message from controller. But we better check anyway.
                  if (message.type == V_LIGHT) {
                     // Change beeper on/off  
                    if (message.sensor == beeper_id){ 				// check if message is beeper
                		beeperState = message.getBool(); 
                		gw.saveState( message.sensor,  beeperState ); // save sensor state in EEPROM (location == sensor number)
                		}
                    }
                }
                
                
                n3roN Offline
                n3roN Offline
                n3ro
                wrote on last edited by
                #7

                @AWI cool!
                Now it works but i cant switch it off every time. i have to stitch it on and off again multiple times to deactivate it

                pimatic + MySensors + Homeduino + z-way
                https://github.com/n3roGit/MySensors_n3ro

                AWIA 1 Reply Last reply
                0
                • n3roN n3ro

                  @AWI cool!
                  Now it works but i cant switch it off every time. i have to stitch it on and off again multiple times to deactivate it

                  AWIA Offline
                  AWIA Offline
                  AWI
                  Hero Member
                  wrote on last edited by
                  #8

                  @n3ro Probably a receive error. Put a Serial.print statement in the incomingMessage part and see if it receives messages.

                  n3roN 1 Reply Last reply
                  0
                  • AWIA AWI

                    @n3ro Probably a receive error. Put a Serial.print statement in the incomingMessage part and see if it receives messages.

                    n3roN Offline
                    n3roN Offline
                    n3ro
                    wrote on last edited by
                    #9

                    @AWI you are right. i get this on the GW:

                    <- I_LOG_MESSAGE 0;0;3;0;9;send: 0-0-10-10 s=5,c=1,t=2,pt=0,l=1,st=fail:0
                    -> Sending 10;5;1;1;2;1

                    <- I_LOG_MESSAGE 0;0;3;0;9;send: 0-0-10-10 s=5,c=1,t=2,pt=0,l=1,st=fail:1
                    -> Sending 10;5;1;1;2;0

                    It is possible that the node only accept the switching signal in the "right" moment?

                    pimatic + MySensors + Homeduino + z-way
                    https://github.com/n3roGit/MySensors_n3ro

                    AWIA 1 Reply Last reply
                    0
                    • n3roN n3ro

                      @AWI you are right. i get this on the GW:

                      <- I_LOG_MESSAGE 0;0;3;0;9;send: 0-0-10-10 s=5,c=1,t=2,pt=0,l=1,st=fail:0
                      -> Sending 10;5;1;1;2;1

                      <- I_LOG_MESSAGE 0;0;3;0;9;send: 0-0-10-10 s=5,c=1,t=2,pt=0,l=1,st=fail:1
                      -> Sending 10;5;1;1;2;0

                      It is possible that the node only accept the switching signal in the "right" moment?

                      AWIA Offline
                      AWIA Offline
                      AWI
                      Hero Member
                      wrote on last edited by
                      #10

                      @n3ro As long as your node is frequently using the gw.process() statement then it will receive the sent messages. Can be any kind of radio disturbance i.e. supply / noise / interference with other 2.4 GHz sources. I would do a few tests with sending messages back and forth. A lot has been written on the forum with respect to "fail" messages.

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


                      11

                      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