@DiverAlpha
I am no expert in this. But when I started using MySensors few months ago, I also had some problems. Not because there is a problem with MySensors but because I was doing the simplest of the mistakes and I needed to think simple and do simple things first.
What I would suggest is just try the simplest of the code first. This post is considering that you are using MySensors library 2.0.
This is what I did when I was trying out MySensors and I think you can try this too.
Firstly connect Arduino you are using properly to the radio with the proper connections using the instructions here. If you are using Arduino Mega, the SPI pins are different. Here is the link for Arduino Mega: https://forum.mysensors.org/topic/4940/arduino-mega-nrf-wiring/3. Make sure you have decoupling capacitors attached between the VCC and GND pins of both the radios.
After you make the connections upload the code for the gateway to one of the Arduinos. You can find the code in Arduino IDE, File > Examples > MySensors > GatewaySerial. Don't make any changes just upload the code.
Then what I did the first time is just run the following motion sensor code to the other Arduino. I have made a few changes to make things simpler for the node to find the gateway.
// Enable debug prints
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
#define MY_NODE_ID 1
#define MY_PARENT_NODE_ID 0
#include <SPI.h>
#include <MySensors.h>
//unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
#define CHILD_ID 0 // Id of the sensor child
// Initialize motion message
MyMessage msg(CHILD_ID, V_TRIPPED);
void setup()
{
pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as 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);
}
void loop()
{
// Read digital motion value
boolean 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.
//sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
}
Here, I have defined a NODE ID and defined the PARENT NODE ID for the node. Defining parent ID makes sure that the gateway that you have is the one, the node is supposed to connect to. I didn't even have motion sensor connected to the node here. This is just to make sure that first time you get everything working.
If this is done correctly the node and gateway should talk to each other and gateway should have the motion sensor registered.
Hope this helps.