Five module limit?

9 years 4 months ago #1935 by EasyIoT
Replied by EasyIoT on topic Five module limit?

piman wrote: Has anyone come up with an answer for More then five nodes?

Definitely it can work. I have thermostat with more than 4 controls, but it uses ATMEGA2560. If you are using ATMEGA328 then sometimes there is not enough RAM.

Please Log in or Create an account to join the conversation.

9 years 4 months ago - 9 years 4 months ago #1968 by bit
Replied by bit on topic Five module limit?
i made a door/window sensors node (arduino pro-mini + MySensors) with 6 modules without problems.

I'm sorry for my poor english.

Please Log in or Create an account to join the conversation.

9 years 4 months ago #1969 by asm7100
Replied by asm7100 on topic Five module limit?
Will you shere the code?

//
Allan

Please Log in or Create an account to join the conversation.

9 years 4 months ago #1970 by bit
Replied by bit on topic Five module limit?
sure, that's my code:
#include <MySensor.h>
#include <SPI.h> 

#define CHILD_ID1 0
#define CHILD_ID2 1
#define CHILD_ID3 2
#define CHILD_ID4 3
#define CHILD_ID5 4
#define CHILD_ID6 5

#define BUTTON_PIN1  2  // Arduino Digital I/O pin for button/reed switch
#define BUTTON_PIN2  3  // Arduino Digital I/O pin for button/reed switch
#define BUTTON_PIN3  4  // Arduino Digital I/O pin for button/reed switch
#define BUTTON_PIN4  5  // Arduino Digital I/O pin for button/reed switch
#define BUTTON_PIN5  6  // Arduino Digital I/O pin for button/reed switch
#define BUTTON_PIN6  7  // Arduino Digital I/O pin for button/reed switch

MySensor gw;
//Bounce debouncer = Bounce(); 
int oldValue[6] = {
  -1, -1, -1, -1, -1, -1};

// Change to V_LIGHT if you use S_LIGHT in presentation below
MyMessage msg1(CHILD_ID1 ,V_TRIPPED);
MyMessage msg2(CHILD_ID2 ,V_TRIPPED);
MyMessage msg3(CHILD_ID3 ,V_TRIPPED);
MyMessage msg4(CHILD_ID4 ,V_TRIPPED);
MyMessage msg5(CHILD_ID5 ,V_TRIPPED);
MyMessage msg6(CHILD_ID6 ,V_TRIPPED);

void setup()  
{  
  gw.begin();

  // Setup the button
  pinMode(BUTTON_PIN1,INPUT_PULLUP); 
  pinMode(BUTTON_PIN2,INPUT_PULLUP); 
  pinMode(BUTTON_PIN3,INPUT_PULLUP); 
  pinMode(BUTTON_PIN4,INPUT_PULLUP); 
  pinMode(BUTTON_PIN5,INPUT_PULLUP); 
  pinMode(BUTTON_PIN6,INPUT_PULLUP);   


  // 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_ID1, S_DOOR);  
  gw.present(CHILD_ID2, S_DOOR);  
  gw.present(CHILD_ID3, S_DOOR);  
  gw.present(CHILD_ID4, S_DOOR);  
  gw.present(CHILD_ID5, S_DOOR); 
  gw.present(CHILD_ID6, S_DOOR);   

}


//  Check if digital input has changed and send in new value
void loop() 
{

  byte value[6];

  for (byte i=0; i<6; i++){
    value[i] = digitalRead(i+2);


    if (value[i] != oldValue[i]) {
      // Send in the new value

      switch (i){
      case 0:
        gw.send( msg1.set(value[i] == HIGH ? 1 : 0));
        break;
      case 1:
        gw.send( msg2.set(value[i] == HIGH ? 1 : 0));
        break;
      case 2:
        gw.send( msg3.set(value[i] == HIGH ? 1 : 0));
        break;
      case 3:
        gw.send( msg4.set(value[i] == HIGH ? 1 : 0));
        break;
      case 4:
        gw.send( msg5.set(value[i] == HIGH ? 1 : 0));
        break; 
      case 5:
        gw.send( msg6.set(value[i] == HIGH ? 1 : 0));
        break;         
      } 
      oldValue[i] = value[i];
    } 
  } 
} 

I'm sorry for my poor english.
The following user(s) said Thank You: asm7100

Please Log in or Create an account to join the conversation.

9 years 4 months ago - 9 years 4 months ago #1971 by bit
Replied by bit on topic Five module limit?

EasyIoT wrote: Definitely it can work. I have thermostat with more than 4 controls, but it uses ATMEGA2560. If you are using ATMEGA328 then sometimes there is not enough RAM.


there is a little library to check available RAM:
github.com/maniacbug/MemoryFree

I'm sorry for my poor english.

Please Log in or Create an account to join the conversation.

Time to create page: 0.410 seconds

Forum latest

  • No posts to display.