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. My Project
  3. multiple door sensors, one arduino

multiple door sensors, one arduino

Scheduled Pinned Locked Moved My Project
multiple doordoor sensors
4 Posts 4 Posters 4.5k 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.
  • O Offline
    O Offline
    Opus40
    wrote on last edited by
    #1

    Hello every one

    I would like to first thank every one for their help. I have got a lot of sensors up and running and its all working well.

    What I am trying to do is have 3 door sensors running from the one arduino as they will all be in the same room, the garage. I realise that this is probably some thing but how would I go about changing the code to make this happen?

    I appreciate any help.

    thanks

    B 1 Reply Last reply
    0
    • E Offline
      E Offline
      ericvdb
      wrote on last edited by
      #2

      Look at the http://www.mysensors.org/build/temp code. It handles multiple temp sensors but you will get the point.

      1 Reply Last reply
      0
      • O Opus40

        Hello every one

        I would like to first thank every one for their help. I have got a lot of sensors up and running and its all working well.

        What I am trying to do is have 3 door sensors running from the one arduino as they will all be in the same room, the garage. I realise that this is probably some thing but how would I go about changing the code to make this happen?

        I appreciate any help.

        thanks

        B Offline
        B Offline
        BulldogLowell
        Contest Winner
        wrote on last edited by BulldogLowell
        #3

        @Opus40

        you can try like this:

        #include <MySensor.h>
        #include <SPI.h>
        #include <Bounce2.h>
        
        #define NUMBER_OF_SWITCHES 3
        
        MySensor gw;
        Bounce debouncer[NUMBER_OF_SWITCHES];
        
        int oldValue[NUMBER_OF_SWITCHES];
        byte switchPin[NUMBER_OF_SWITCHES] = {4,5,6}; //<<<<<<<<<<< set your switch pins here
        
        MyMessage msg(0,V_TRIPPED);
        
        void setup()  
        {  
          gw.begin();
        
          for (int i = 0; i < NUMBER_OF_SWITCHES; i++)
          {
            pinMode(switchPin[i],INPUT_PULLUP);
            debouncer[i] = Bounce();
            debouncer[i].attach(switchPin[i]);
            debouncer[i].interval(5);
          }
          for (int i = 0; i < NUMBER_OF_SWITCHES; i++)
          {
            gw.present(i, S_DOOR);
            delay(250);
          }
        }
        //
        void loop() 
        {
          for (int i = 0; i < NUMBER_OF_SWITCHES; i++)
          {
            debouncer[i].update();
            int value = debouncer[i].read();
            if (value != oldValue[i]) 
            {
              gw.send(msg.setSensor(i).set(value == HIGH? true : false), false); 
            }
            oldValue[i] = value;
          }
        } 
        

        not tested, but compiles....

        1 Reply Last reply
        0
        • E Offline
          E Offline
          emurr
          wrote on last edited by
          #4

          The sketch is working!

          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


          16

          Online

          12.0k

          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