I've posted this in the HA Forums too but hoping someone here might be able to help too
I am stuck setting up MySensors and if anyone could help me I would be very grateful. I am completely new to Arduino's and the syntax (and I'm not a programmer anyway!) so I am aware I'm on a steep learning curve here!
I have followed the tutorials to set up an Ethernet Gateway and a basic motion sensor. I then assigned static ID's to these as at this point I wasn't using a controller and I could get the two to talk successfully. I used the serial monitor to check both devices and when I wave my hand in front of the sensor I get the following:
If I've misinterpreted this then please let me know, but it appears to me that the 1 (motion) and 0 (reset) on both devices almost simultaneously would suggest that they are communicating.
I also set up a repeater and had communication between these, and could even pass the sensor data through it (we have thick walls so I took the sensor out of range and put the repeater in the middle).
At this point I was thinking, this is all pretty easy, just need to hook it up to HA and I'll be away! However, I cannot get it to work. My understanding is that the controller - HA in this case - hands out the ID's to the nodes and therefore I don't want to define these in the sketch. I believe I am also right in saying that the gateway always has an ID of 0.
I added the following to my HA configuration.yaml
- device: '192.168.86.19'
I restarted HA, and it appeared to be communicating as I was getting the following in the serial monitor for the gateway:
Again, please correct me if I'm wrong but I believe this is telling me that the gateway and HA are communicating?
The issue, and where I am currently stuck is that my sensor won't connect to the gateway. I have cleared the EEPROM from the board (using the MySensors clear eeprom sketch) and removed the ID from the sketch before uploading it again. I've done the same on the repeater and switched the boards for brand new ones but get the same issue each time.
__ __ ____
| \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___
| |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
| | | | |_| |___| | __/ | | \__ \ _ | | \__ \
|_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/
16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2
34 TSM:INIT:TSP OK
2048 !TSM:FPAR:NO REPLY
4060 !TSM:FPAR:NO REPLY
6072 !TSM:FPAR:NO REPLY
This just loops with the count incrementing by one each time. There is nothing on the gateway serial monitor beyond the messages in the log above. It doesn't even seem to be aware anything is trying to communicate with it.
I have looked through the Debug info on the MySensors website and I think I have an understanding of what is happening based on the values for s,c,t. (I'm assuming s=255 is like a broadcast message rather than a defined value for the sensor). The line
TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK is the sensor looking for the gateway and the next line
!TSM:FPAR:NO REPLY is saying there is no response.
I'm sure I have missed something blindingly obvious but no amount of reading or research has helped me, so I'd be very grateful if someone could point a newbie in the right direction!
The sketch for Gateway is:
// Enable debug prints to serial monitor
// Enable and select radio type attached
// Enable gateway ethernet module type
// W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
//#define MY_W5100_SPI_EN 4
// Enable Soft SPI for NRF radio (note different radio wiring is required)
// The W5100 ethernet module seems to have a hard time co-operate with
// radio on the same spi bus.
#if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
#define MY_SOFT_SPI_SCK_PIN 14
#define MY_SOFT_SPI_MISO_PIN 16
#define MY_SOFT_SPI_MOSI_PIN 15
// When W5100 is connected we have to move CE/CSN pins for NRF radio
#define MY_RF24_CE_PIN 5
#define MY_RF24_CS_PIN 6
// Enable UDP communication
//#define MY_USE_UDP // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS below
// Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
#define MY_IP_ADDRESS 192,168,86,19
// If using static ip you can define Gateway and Subnet address as well
#define MY_IP_GATEWAY_ADDRESS 192,168,86,1
#define MY_IP_SUBNET_ADDRESS 255,255,254,0
// Renewal period if using DHCP
//#define MY_IP_RENEWAL_INTERVAL 60000
// The port to keep open on node server mode / or port to contact in client mode
#define MY_PORT 5003
// Controller ip address. Enables client mode (default is "server" mode).
// Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
//#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254
// The MAC address can be anything you want but should be unique on your network.
// Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
// Note that most of the Arduino examples use "DEAD BEEF FEED" for the MAC address.
#define MY_MAC_ADDRESS 0xBE, 0x93, 0x51, 0x91, 0xF0, 0x22
// Enable inclusion mode
// Enable Inclusion mode button on gateway
// Set inclusion mode duration (in seconds)
#define MY_INCLUSION_MODE_DURATION 60
// Digital pin used for inclusion mode button
//#define MY_INCLUSION_MODE_BUTTON_PIN 3
// Set blinking period
#define MY_DEFAULT_LED_BLINK_PERIOD 300
// Flash leds on rx/tx/err
// Uncomment to override default HW configurations
//#define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin
//#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN 9 // Transmit led pin
// Setup locally attached sensors
// Present locally attached sensors here
// Send locally attached sensors data here
The sketch for the sensor is:
// Enable debug prints
// Enable and select radio type attached
//#define MY_NODE_ID 1
uint32_t 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 1 // Id of the sensor child
// Initialize motion message
MyMessage msg(CHILD_ID, V_TRIPPED);
pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input
// 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)
// Read digital motion value
bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
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);