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. Controllers
  3. Domoticz
  4. Motion sensors

Motion sensors

Scheduled Pinned Locked Moved Domoticz
4 Posts 2 Posters 1.9k Views 1 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.
  • J Offline
    J Offline
    Jacek Slawinski
    wrote on last edited by
    #1

    Hi all
    Could you please help me?
    I want to hook more than one motion detector to arduino.
    In the program I see both sensors and contatron
    The first motion sensor works and the second one does not change states
    Contatron works
    What's wrong with the scripts?

    https://pastebin.com/baMUK4zj

    mfalkviddM 1 Reply Last reply
    0
    • J Jacek Slawinski

      Hi all
      Could you please help me?
      I want to hook more than one motion detector to arduino.
      In the program I see both sensors and contatron
      The first motion sensor works and the second one does not change states
      Contatron works
      What's wrong with the scripts?

      https://pastebin.com/baMUK4zj

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

      @Jacek-Slawinski welcome to the MySensors community!

      The code in your sketch first sleeps waiting for sensor1, then sleeps waiting for sensor2. So when "the other" sensor is triggered, the Arduino does not wake.

      Remove the first sleep and change the last sleep to something like

      wakeupReason = sleep(digitalPinToInterrupt(CzujnikRuchu1), CHANGE, digitalPinToInterrupt(CzujnikRuchu2), CHANGE, SLEEP_TIME);
      

      Then check the value of wakeupReason and act accordingly.

      See https://www.mysensors.org/download/sensor_api_20#sleeping for full description on how to sleep with two interrupt pins and how to use the return value of sleep().

      Also note that only some pins can be used for interrupt.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jacek Slawinski
        wrote on last edited by Jacek Slawinski
        #3

        Thank you very much
        It works
        I add this

        sleep(digitalPinToInterrupt(CzujnikRuchu1), CHANGE, digitalPinToInterrupt(CzujnikRuchu2), CHANGE, SLEEP_TIME);``````
        Insert Code Here
        

        However, in the devices from time to time themselves add new ones not used.
        I don't know why

        foto

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jacek Slawinski
          wrote on last edited by Jacek Slawinski
          #4

          Hi
          I have coneccted the arduino mega to RPI 3 via usb
          I can not handle the script on more than one motion sensor

          #define MY_DEBUG 
          
          
          
          
          // Enable serial gateway
          #define MY_GATEWAY_SERIAL
          
          // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
          #if F_CPU == 8000000L
          #define MY_BAUD_RATE 38400
          #endif
          
          
          
          // Enable inclusion mode
          #define MY_INCLUSION_MODE_FEATURE
          // Enable Inclusion mode button on gateway
          #define MY_INCLUSION_BUTTON_FEATURE
          
          
          
          // Set inclusion mode duration (in seconds)
          #define MY_INCLUSION_MODE_DURATION 60 
          // Digital pin used for inclusion mode button
          #define MY_INCLUSION_MODE_BUTTON_PIN  3 
          
          
          #include <SPI.h>
          #include <MySensors.h>  
          #include <Bounce2.h>
          
          unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
          #define DIGITAL_INPUT_SENSOR 6   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
          #define CHILD_ID 1   // Id of the sensor child
          #define DIGITAL_INPUT_SENSOR_2 7   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
          #define CHILD_ID_2 2   // Id of the sensor child
          
          // Initialize motion message
          MyMessage msg(CHILD_ID, V_TRIPPED);
          MyMessage msg2(CHILD_ID_2, V_TRIPPED);
          
          void setup()
          {
              pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
              pinMode(DIGITAL_INPUT_SENSOR_2, INPUT); 
          }
          
          void presentation()
          {
              // Send the sketch version information to the gateway and Controller
              sendSketchInfo("Motion Sensor", "1.0");
          
              // Register all sensors to gw (they will be created as child devices)
              present(CHILD_ID, S_MOTION);
              present(CHILD_ID_2, S_MOTION);
          }
          
          void loop()
          {
            {
              // Read digital motion value
              bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
          
              Serial.println(tripped);
              send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
          
              // Sleep until interrupt comes in on motion sensor. Send update every two minute.
              
          }
          {// Read digital motion value
              bool tripped = digitalRead(DIGITAL_INPUT_SENSOR_2) == HIGH;
          
              Serial.println(tripped);
              send(msg2.set(tripped?"1":"0"));  // Send tripped value to gw
              sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE,digitalPinToInterrupt(DIGITAL_INPUT_SENSOR_2), CHANGE, SLEEP_TIME);
          }
          }
          

          This script generates a lot of different sensors in the domoticz and should only two.
          I don't now why? :(

          When it erases:

           sleep(digitalPinToInterrupt(CzujnikRuchu1), CHANGE, digitalPinToInterrupt(CzujnikRuchu2), CHANGE, SLEEP_TIME); ``````
          
          

          It's the same

          Could you help me with this?

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


          18

          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