Some advise needed for the first project SerialGW and MotionSensor
-
Hello,
I just have started to use mysensors which I have the feeling that I can do a lot with my projects but I've stuck in the first project of using serial gateway with Arduino nano and motion detector with Arduino uno.
I just have used the example sketches and used 10micoF 16V capacitors but can not able to register sensor client.
I have updated Arduino ide to latest version but this also had not helped.
I also have ran Clear EepromConfig successfully but this has not helped either..Please find the output from serial monitor of the sensor client below. After TSM:PDT it loops back to TSM:INIT.
Starting sensor (RNNNA-, 2.0.0)
TSM:INIT
TSM:RADIO:OK
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSP:MSG:READ 0-0-255 s=255,c=3,t=8,pt=1,l=1,sg=0:0
TSP:MSG:FPAR RES (ID=0, dist=0)
TSP:MSG:PAR OK (ID=0, dist=1)
TSM:FPAR:OK
TSM:ID
TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
TSM:ID
TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
TSM:ID
TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
TSM:ID
TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
!TSM:CHKID:FAIL (ID=255)
!TSM:FAILURE
TSM:PDTPlease find the serial log for the Gateway
0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSM:RADIO:OK
0;255;3;0;9;TSM:GW MODE
0;255;3;0;9;TSM:READY
0;255;3;0;14;Gateway startup complete.
0;255;0;0;18;2.0.0
0;255;3;0;9;No registration required
0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
0;255;3;0;9;TSP:MSG:READ 255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
0;255;3;0;9;TSP:MSG:BC
0;255;3;0;9;TSP:MSG:FPAR REQ (sender=255)
0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL)
0;255;3;0;9;TSP:MSG:GWL OK
0;255;3;0;9;TSP:MSG:SEND 0-0-255-255 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=bc:0
0;255;3;0;9;TSP:MSG:READ 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;
0;255;3;0;9;TSP:MSG:READ 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;
0;255;3;0;9;TSP:MSG:READ 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;
0;255;3;0;9;TSP:MSG:READ 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;Please advise where I should check or how to overcome "!TSM:CHKID:FAIL (ID=255)"
Thanks a lot
-
I have revised all wiring and reinstalled latest library. I just have switched gateway and sensor nodes.
I've checked that after TSP:MSG:SEND 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=ok: in sensor side there should be a TSP:MSG:READ line then TSP:ASSIGNID:OK but this is not happening.Any idea where I have to check? I've stuck in my project.
I'm just using example sketches in have not changed anything
Your help is appreciated. Thanks
-
@emrsen The node is asking for an ID. The ID is given out by a controller or you have to use static IDs in your sensor sketch.
-
Thanks for the reply I shall try
-
@TimO thanks for responding but I still can not get the ID from controller. I also have tried to set ID in node manually as 0 but this had not helped either.
I think I'm missing a very basic dumb thing please check the setup I've listed below and added sketches I've used and output log files.
As far as I understand from the output logs : Node requests ID from Gateway and I see that gateway also receives data from node but gateway do not respond to the node creating and delivering an ID.
Thanks a lot for your help
I've re-setup both Gateway and node from scratch. I've downloaded latest lib. from github. I also have cleared the eprom of the Node.
Gateway I used Arduino nano clone and NRF24L01+(not the powerful model with antenna) used 10 micF condensator as described. Code I've used created from example of Serial Gateway as below
/** * 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 * The ArduinoGateway prints data received from sensors on the serial link. * The gateway accepts input on seral which will be sent out on radio network. * * The GW code is designed for Arduino Nano 328p / 16MHz * * Wire connections (OPTIONAL): * - Inclusion button should be connected between digital pin 3 and GND * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series * * LEDs (OPTIONAL): * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly * - ERR (red) - fast blink on error during transmission error or recieve crc error * */ // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 // Set LOW transmit power level as default, if you have an amplified NRF-module and // power your radio separately with a good regulator you can turn up PA level. #define MY_RF24_PA_LEVEL RF24_PA_LOW // Enable serial gateway #define MY_GATEWAY_SERIAL // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender) #if F_CPU == 8000000L #define MY_BAUD_RATE 38400 #endif // Enable inclusion mode #define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway //#define MY_INCLUSION_BUTTON_FEATURE // Inverses behavior of inclusion button (if using external pullup) //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP // 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 // Flash leds on rx/tx/err //#define MY_LEDS_BLINKING_FEATURE // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Inverses the behavior of leds #define MY_WITH_LEDS_BLINKING_INVERSE // Flash leds on rx/tx/err // Uncomment to override default HW configurations #define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin #define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin #define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED #include <MySensors.h> void setup() { // Setup locally attached sensors } void presentation() { // Present locally attached sensors } void loop() { // Send locally attached sensor data here }
Output of the serial Gateway is below
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.0.1-beta 0;255;3;0;9;TSM:INIT 0;255;3;0;9;TSM:INIT:TSP OK 0;255;3;0;9;TSM:INIT:GW MODE 0;255;3;0;9;TSM:READY 0;255;3;0;14;Gateway startup complete. 0;255;0;0;18;2.0.1-beta 0;255;3;0;9;MCO:REG:NOT NEEDED 0;255;3;0;9;MCO:BGN:STP 0;255;3;0;9;MCO:BGN:INIT OK,ID=0,PAR=0,DIS=0,REG=1 0;255;3;0;9;TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0: 255;255;3;0;3; 0;255;3;0;9;TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0: 255;255;3;0;3; 0;255;3;0;9;TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;TSF:MSG:BC 0;255;3;0;9;TSF:MSG:FPAR REQ,ID=255 0;255;3;0;9;TSF:CHKUPL:OK 0;255;3;0;9;TSF:MSG:GWL OK 0;255;3;0;9;TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=bc:0 0;255;3;0;9;TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0: 255;255;3;0;3; 0;255;3;0;9;TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0: 255;255;3;0;3; 0;255;3;0;9;TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0: 255;255;3;0;3; 0;255;3;0;9;TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0: 255;255;3;0;3;
I used Arduino Uno Clone as node and uploaded Motion Sensor sketch not changing any thing please find the code below
/** * 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. * ******************************* * * REVISION HISTORY * Version 1.0 - Henrik Ekblad * * DESCRIPTION * Motion Sensor example using HC-SR501 * http://www.mysensors.org/build/motion * */ // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #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 1 // 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); }
This is the log screen in node device. Node requests ID from Gateway and I see that gateway also receives data from node but as far as I see from log gateway do not respond to the node creating and delivering an ID.
MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.0.1-beta TSM:INIT TSM:INIT:TSP OK TSM:FPAR TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc: TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0 TSF:MSG:FPAR RES,ID=0,D=0 TSF:MSG:FPAR OK,ID=0,D=1 TSM:FPAR:OK TSM:ID TSM:ID:REQ TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK: TSM:ID TSM:ID:REQ TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK: TSM:ID TSM:ID:REQ TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK: TSM:ID TSM:ID:REQ TSF:MSG:SEND,255-255-0-0,s=255,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK: !TSM:ID:FAIL,ID=255 TSM:FAILURE TSM:FAILURE:PDT TSM:FAILURE:RE-INIT TSM:INIT TSM:INIT:TSP OK TSM:FPAR```
-
@emrsen the gateway does not assign IDs. The controller does. Are you using a controller?
ID 0 is reserved for the gateway. Node IDs need to be 1-254 if you want to assign it manually. See https://www.mysensors.org/about/network for details.
-
@mfalkvidd Thanks a lot for the enlightment I'm not using a controller I've just asumed that gateway will be fine to manage the Nodes which is the dumb thing I was missing.
I've started to work on selecting a controller.
Can anyone advise which controller is most easy to setup and integrate for a newbee? I have Raspberry Pi3 at home hosting Blynk Server which I plan to setup on this platform.
Thanks again for the help and support so far.
-
Well, Domoticz is very easy to setup and the integration is good. I personally prefer OpenHAB2 because of the wide range of supported hardware. But the setup is definitely more advanced.
-
@TimO Thanks for the info I shall work on it at the weekend shall update about my progress
-
See here on another thread for what I did to make things work. It seems with Uno clones, you have to supply separate power (the USB does not supply enough juice).
https://forum.mysensors.org/topic/4896/solved-mysensors-node-not-working-trouble-finding-parent-node
N.B. When testing without a controller, the only code change you need to do is to add a line in the sensor node code to set the node id (see link for more details)
-
@TimO said:
Domoticz
Thanks for the advise
-
Thanks all you guys, now my first experimental system is working