Trying to understand how to add a "thing"

I have built a simple button using a sketch. But how do I configure Child id and node id when adding the thing?

This is what I have built:

 * 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 <>
 * Copyright (C) 2013-2015 Sensnology AB
 * Full contributor list:
 * Documentation:
 * Support Forum:
 * 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.
 * Simple binary switch example 
 * Connect button or door/window reed switch between 
 * digitial I/O pin 3 (BUTTON_PIN below) and GND.

#include <MySensor.h>
#include <SPI.h>
#include <Bounce2.h>

#define CHILD_ID 3
#define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch

MySensor gw;
Bounce debouncer = Bounce(); 
int oldValue=-1;

// Change to V_LIGHT if you use S_LIGHT in presentation below
MyMessage msg(CHILD_ID,V_TRIPPED);

void setup()  

 // Setup the button
  // Activate internal pull-up
  // After setting up the button, setup debouncer
  // 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, S_DOOR);  

//  Check if digital input has changed and send in new value
void loop() 
  // Get the update value
  int value =;
  if (value != oldValue) {
     // Send in the new value
     gw.send(msg.set(value==HIGH ? 1 : 0));
     oldValue = value;

It’s a lot easier than you think…assuming I know what I’m talking about(!). It seems to work this way for me:

You’ve got this bit right already:

#define CHILD_ID 3

…which sets the sensor child ID to 3. Then, if you want to set the Node ID, you do it in this statement:


Change that to something like:

gw.begin(NULL, 200);

…for a Node ID of 200.