3 BinarySwitch + 3 motions



  • Hi,

    I tried to integrate 3 BinarySwitch and 3 motions around the same Arduino Pro.
    The 3 Binary are working perfectly, but on the 3 motions, they are always at '1' value, despite I move them.
    Do you know if there is a limit of the number of sensors per Ardino Pro?
    Or simply I did mistakes on the script:

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * DESCRIPTION
     *
     * Simple binary switch example 
     * Connect button or door/window reed switch between 
     * digitial I/O pin 3 (BUTTON_PIN below) and GND.
     * http://www.mysensors.org/build/binary
     */
    
    
    #include <MySensor.h>
    #include <SPI.h>
    #include <Bounce2.h>
    
    #define CHILD_ID_1 101 // ID 1
    #define CHILD_ID_2 102 // ID 2
    #define CHILD_ID_3 103 // ID 3
    #define CHILD_ID_4 104 // ID 4
    #define CHILD_ID_5 105 // ID 5
    #define CHILD_ID_6 106 // ID 6
    
    #define BUTTON_PIN_1  3  // Arduino Digital I/O pin for button/reed switch
    #define BUTTON_PIN_2  4  // Arduino Digital I/O pin for button/reed switch
    #define BUTTON_PIN_3  5  // Arduino Digital I/O pin for button/reed switch
    #define BUTTON_PIN_4  6  // Arduino Digital I/O pin for button/reed switch
    #define BUTTON_PIN_5  7  // Arduino Digital I/O pin for button/reed switch
    #define BUTTON_PIN_6  8  // Arduino Digital I/O pin for button/reed switch
    
    MySensor gw;
    Bounce debouncer1 = Bounce(); 
    Bounce debouncer2 = Bounce(); 
    Bounce debouncer3 = Bounce(); 
    Bounce debouncer4 = Bounce(); 
    Bounce debouncer5 = Bounce(); 
    Bounce debouncer6 = Bounce(); 
    
    int oldValue1=-1;
    int oldValue2=-1;
    int oldValue3=-1;
    int oldValue4=-1;
    int oldValue5=-1;
    int oldValue6=-1;
    
    // Change to V_LIGHT if you use S_LIGHT in presentation below
    MyMessage msg1(CHILD_ID_1,V_TRIPPED);
    MyMessage msg2(CHILD_ID_2,V_TRIPPED);
    MyMessage msg3(CHILD_ID_3,V_TRIPPED);
    MyMessage msg4(CHILD_ID_4,V_TRIPPED);
    MyMessage msg5(CHILD_ID_5,V_TRIPPED);
    MyMessage msg6(CHILD_ID_6,V_TRIPPED);
    
    void setup()  
    {  
      gw.begin();
    
      // Setup the button
      pinMode(BUTTON_PIN_1,INPUT);
      pinMode(BUTTON_PIN_2,INPUT);
      pinMode(BUTTON_PIN_3,INPUT);
      pinMode(BUTTON_PIN_4,INPUT);
      pinMode(BUTTON_PIN_5,INPUT);
      pinMode(BUTTON_PIN_6,INPUT);
    
      // Activate internal pull-up
      digitalWrite(BUTTON_PIN_1,HIGH);
      digitalWrite(BUTTON_PIN_2,HIGH);
      digitalWrite(BUTTON_PIN_3,HIGH);
      digitalWrite(BUTTON_PIN_4,LOW);
      digitalWrite(BUTTON_PIN_5,LOW);
      digitalWrite(BUTTON_PIN_6,LOW);
    
      // After setting up the button, setup debouncer
      debouncer1.attach(BUTTON_PIN_1);
      debouncer1.interval(5);
      debouncer2.attach(BUTTON_PIN_2);
      debouncer2.interval(5);
      debouncer3.attach(BUTTON_PIN_3);
      debouncer3.interval(5);
      debouncer4.attach(BUTTON_PIN_4);
      debouncer4.interval(5);
      debouncer5.attach(BUTTON_PIN_5);
      debouncer5.interval(5);
      debouncer6.attach(BUTTON_PIN_6);
      debouncer6.interval(5);
    
      // Register binary input sensor to gw (they will be created as child devices)
      // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
      // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
      gw.present(CHILD_ID_1, S_DOOR);  
      gw.present(CHILD_ID_2, S_DOOR);  
      gw.present(CHILD_ID_3, S_DOOR);  
      gw.present(CHILD_ID_4, S_MOTION);
      gw.present(CHILD_ID_5, S_MOTION);
      gw.present(CHILD_ID_6, S_MOTION);
    }
    
    //  Check if digital input has changed and send in new value
    void loop() 
    {
      debouncer1.update();
      // Get the update value
      int value1 = debouncer1.read();
     
      if (value1 != oldValue1) {
         // Send in the new value
         gw.send(msg1.set(value1==HIGH ? 1 : 0));
         oldValue1 = value1;
      }
      
      debouncer2.update();
      // Get the update value
      int value2 = debouncer2.read();
     
      if (value2 != oldValue2) {
         // Send in the new value
         gw.send(msg2.set(value2==HIGH ? 1 : 0));
         oldValue2 = value2;
      }
      
      debouncer3.update();
      // Get the update value
      int value3 = debouncer3.read();
     
      if (value3 != oldValue3) {
         // Send in the new value
         gw.send(msg3.set(value3==HIGH ? 1 : 0));
         oldValue3 = value3;
      }
     
      debouncer4.update();
      // Get the update value
      int value4 = debouncer4.read();
     
      if (value4 != oldValue4) {
         // Send in the new value
         gw.send(msg4.set(value4==HIGH ? 1 : 0));
         oldValue4 = value4;
      }
    
      debouncer5.update();
      // Get the update value
      int value5 = debouncer5.read();
     
      if (value5 != oldValue5) {
         // Send in the new value
         gw.send(msg5.set(value5==HIGH ? 1 : 0));
         oldValue5 = value5;
      }
    
      debouncer6.update();
      // Get the update value
      int value6 = debouncer6.read();
     
      if (value6 != oldValue6) {
         // Send in the new value
         gw.send(msg6.set(value6==HIGH ? 1 : 0));
         oldValue6 = value6;
      }
    
    } 
    

    Thanks for your support!


  • Hardware Contributor

    As far as I know of, there is no software limitation to the maximum sensor count per node. However I may be wrong so don't quote me on this, lets get some responses from more experienced guys around here.


  • Admin

    255 is the maximum per node. (0-254)


  • Hardware Contributor

    Of course it is,

    "A MySensor radio network can consist of up to 254 different radio nodes and each radio node can report data for 254 attached child sensors. This means that you can, in theory, manage data for up to 64516 sensors in a single radio network. If this isn't enough, you can create another parallel radio network on a different channel and there are 126 available channels."

    The above was an extract from the getting started page.

    Thank you for correcting me.


Log in to reply
 

Suggested Topics

  • 1
  • 6
  • 10
  • 3
  • 5
  • 3

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts