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. Troubleshooting
  3. What is wrong with this sketch?

What is wrong with this sketch?

Scheduled Pinned Locked Moved Troubleshooting
20 Posts 4 Posters 3.6k 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.
  • Cliff KarlssonC Offline
    Cliff KarlssonC Offline
    Cliff Karlsson
    wrote on last edited by
    #10

    Ok, I am going to try to make some use of that info. But can I still use "sleep( <interrupt>, <time>) ;" when I also need to monitor the A0 (Pressure)? Will the Pressure still trigger when the sensor sleeps and there are no motion?

    corbinC AWIA 2 Replies Last reply
    0
    • Cliff KarlssonC Cliff Karlsson

      Ok, I am going to try to make some use of that info. But can I still use "sleep( <interrupt>, <time>) ;" when I also need to monitor the A0 (Pressure)? Will the Pressure still trigger when the sensor sleeps and there are no motion?

      corbinC Offline
      corbinC Offline
      corbin
      wrote on last edited by
      #11

      @Cliff-Karlsson
      You cannot use sleep of any kind, because it will power down the radio, and you need that running 100% of the time for the repeater function.

      1 Reply Last reply
      0
      • Cliff KarlssonC Cliff Karlsson

        Ok, I am going to try to make some use of that info. But can I still use "sleep( <interrupt>, <time>) ;" when I also need to monitor the A0 (Pressure)? Will the Pressure still trigger when the sensor sleeps and there are no motion?

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

        @Cliff-Karlsson It depends what kind of pressure sensor you have, i will probably be enough if you poll it each second or so. And as @corbin mentioned don't use repeater function when you sleep.

        Cliff KarlssonC 1 Reply Last reply
        0
        • AWIA AWI

          @Cliff-Karlsson It depends what kind of pressure sensor you have, i will probably be enough if you poll it each second or so. And as @corbin mentioned don't use repeater function when you sleep.

          Cliff KarlssonC Offline
          Cliff KarlssonC Offline
          Cliff Karlsson
          wrote on last edited by
          #13

          Ok, I know this is probably very basic. But exactly how would I modify the original sketch to have it behave like this?

          nielsokkerN 1 Reply Last reply
          0
          • Cliff KarlssonC Cliff Karlsson

            Ok, I know this is probably very basic. But exactly how would I modify the original sketch to have it behave like this?

            nielsokkerN Offline
            nielsokkerN Offline
            nielsokker
            wrote on last edited by
            #14

            @Cliff-Karlsson

            I dont really understand what you mean. You want it to send its value every second? In that case my attempt still works. You want to use interrupts?

            1 Reply Last reply
            0
            • Cliff KarlssonC Offline
              Cliff KarlssonC Offline
              Cliff Karlsson
              wrote on last edited by
              #15

              @nielsokker said:

              I dont really understand what you mean. You want it to send its value every second? In that case my attempt still works. You want to use interrupts?

              I just want a sketch that updates the status of the pressure sensor when it goes from HIGH to LOW or from LOW to HIGH. And when Movement is detected, but does only report back to the controller when a actual change has happened.

              In my last sketch all seemed to work except it "spammed" the controller with the motion-sensor:

              2016-07-19 11:38:53.250 (RFM) Lighting 2 (Säng Motion)
              2016-07-19 11:38:54.354 (RFM) Lighting 2 (Säng Motion)
              2016-07-19 11:38:54.411 (RFM) Lighting 2 (Säng Motion)
              2016-07-19 11:38:55.515 (RFM) Lighting 2 (Säng Motion)
              2016-07-19 11:38:55.574 (RFM) Lighting 2 (Säng Motion)
              2016-07-19 11:38:56.678 (RFM) Lighting 2 (Säng Motion)
              2016-07-19 11:38:56.736 (RFM) Lighting 2 (Säng Motion)
              2016-07-19 11:38:57.842 (RFM) Lighting 2 (Säng Motion)
              2016-07-19 11:38:57.899 (RFM) Lighting 2 (Säng Motion)
              2016-07-19 11:38:59.003 (RFM) Lighting 2 (Säng Motion)
              2016-07-19 11:38:59.061 (RFM) Lighting 2 (Säng Motion)
              2016-07-19 11:39:00.166 (RFM) Lighting 2 (Säng Motion)
              
              nielsokkerN 1 Reply Last reply
              0
              • Cliff KarlssonC Cliff Karlsson

                @nielsokker said:

                I dont really understand what you mean. You want it to send its value every second? In that case my attempt still works. You want to use interrupts?

                I just want a sketch that updates the status of the pressure sensor when it goes from HIGH to LOW or from LOW to HIGH. And when Movement is detected, but does only report back to the controller when a actual change has happened.

                In my last sketch all seemed to work except it "spammed" the controller with the motion-sensor:

                2016-07-19 11:38:53.250 (RFM) Lighting 2 (Säng Motion)
                2016-07-19 11:38:54.354 (RFM) Lighting 2 (Säng Motion)
                2016-07-19 11:38:54.411 (RFM) Lighting 2 (Säng Motion)
                2016-07-19 11:38:55.515 (RFM) Lighting 2 (Säng Motion)
                2016-07-19 11:38:55.574 (RFM) Lighting 2 (Säng Motion)
                2016-07-19 11:38:56.678 (RFM) Lighting 2 (Säng Motion)
                2016-07-19 11:38:56.736 (RFM) Lighting 2 (Säng Motion)
                2016-07-19 11:38:57.842 (RFM) Lighting 2 (Säng Motion)
                2016-07-19 11:38:57.899 (RFM) Lighting 2 (Säng Motion)
                2016-07-19 11:38:59.003 (RFM) Lighting 2 (Säng Motion)
                2016-07-19 11:38:59.061 (RFM) Lighting 2 (Säng Motion)
                2016-07-19 11:39:00.166 (RFM) Lighting 2 (Säng Motion)
                
                nielsokkerN Offline
                nielsokkerN Offline
                nielsokker
                wrote on last edited by
                #16

                @Cliff-Karlsson

                I see why. But once again, i think i made your sketch work.

                As i see it. This is the current desired logic.

                once per second, you want to check the following things:

                • is there motion?
                • has there been a change in pressure (HIGH to LOW or LOW to HIGH)?

                But actually you want to check both ALWAYS. The thing you are obviously looking for, are interrupts. I do not know how these work if you do not want to sleep. Maybe there is a wait(interrupt_pin_1_functor, interrupt_pin_2_functor, waittime=forever) function (I know the sleep() version exists).

                Maybe you already know what interrupts are but, in short: When a given interrupt pin notices a difference in value (HIGH to LOW, for example) it gives a signal. The current code is being stopped and the function that is bound to the pin is executed. This function could be sending the new value to the gateway.

                Can someone confirm this?

                1 Reply Last reply
                0
                • Cliff KarlssonC Offline
                  Cliff KarlssonC Offline
                  Cliff Karlsson
                  wrote on last edited by
                  #17

                  I tried again with your sketch @nielsokker , I think I only added some sleep. But the motion-sensor just turns on/off super-quick every time the motion triggers. What am I doing wrong ?

                  AWIA nielsokkerN 2 Replies Last reply
                  0
                  • Cliff KarlssonC Cliff Karlsson

                    I tried again with your sketch @nielsokker , I think I only added some sleep. But the motion-sensor just turns on/off super-quick every time the motion triggers. What am I doing wrong ?

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

                    @Cliff-Karlsson how is your motion sensor powered? It needs a solid power supply

                    1 Reply Last reply
                    0
                    • Cliff KarlssonC Cliff Karlsson

                      I tried again with your sketch @nielsokker , I think I only added some sleep. But the motion-sensor just turns on/off super-quick every time the motion triggers. What am I doing wrong ?

                      nielsokkerN Offline
                      nielsokkerN Offline
                      nielsokker
                      wrote on last edited by nielsokker
                      #19

                      @Cliff-Karlsson said:

                      I tried again with your sketch @nielsokker , I think I only added some sleep. But the motion-sensor just turns on/off super-quick every time the motion triggers. What am I doing wrong ?

                      Yea, my example just checks both sensors every second. So it sends both values every second. I know now that is not what you want. At least the code looks better in my opinion (ofc its my code :) ).

                      I have to agree with @AWI that it seems like your sensor does not work properly.

                      1 Reply Last reply
                      0
                      • Cliff KarlssonC Offline
                        Cliff KarlssonC Offline
                        Cliff Karlsson
                        wrote on last edited by
                        #20

                        ahh!!!, you where right. I powered the node using a mobile charger but had not connected the PIR to the same GND as the charger. Now it works.

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


                        10

                        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