How does the serial GW work after all?
-
Hi,
I'm doing my initial experiments in mysensors and I'm using a serial GW on an arduino UNO connected to a raspberry PI 1 with OpenHab.
I reached a point where the sensors were automatically detected (appeared in OpenHab inbox magically) but the setup wasn't stable (the relays and door sensors weren't working 100% of the times). I associated it to the fact that when trying to make it work, I tried many things and installed two different versions of the binding and there could be some interference:
org.openhab.binding.mysensors-2.2.0-SNAPSHOT.jar
org.openhab.binding.mysensors-2.3.0-SNAPSHOT.jar
I wasn't sure what was the problem, so I cleaned everything in OpenHab and re-compiled the GW, now with the debug flag set to off (in order to have more available resources). Then, to start from scratch, I followed these instructions.
Now, although OpeHab seems to detect the gateway, no more sensors appear. I connected the GW to my PC and I just get the initial printout (GW setup complete) but nothing else appears, even if I restart the nodes.
I also added an inclusion button (pin D3/GND) and uncomented the corresponding flags, but still no luck....
The resources of the serial GW seem OK (~50% RAM free). Its basically the GW sketch example with signing and inclusion activated (by the way, the first time was working with signing, so I guess the failure now is not related with it).
I have no idea what is going on, is it mandatory for the GW to have the debuging option so it could interact with a controller?
Would it be the case that the GW caches the node IDs and doesn't present it to the controller because it believes he already knows about it?
How does the inclusion mode work? After pressing the button, what should I do? Should I restart the nodes in order to force a presentation?
Thanks
-
I don't use OpenHab so I'll only answer the parts I know about. Hopefully someone else can fill in with the rest.
I have no idea what is going on, is it mandatory for the GW to have the debuging option so it could interact with a controller?
No, there is no need to have debug turned on. Troubleshooting without debug is almost impossible though.
Would it be the case that the GW caches the node IDs and doesn't present it to the controller because it believes he already knows about it?
No. The GW is stateless (except for a routing table). But nodes only present themselves at startup, so if they are not restarted they will not present themselves.
-
So, if I connect the Serial GW to my PC, run "serial monitor", and I restart a nearby node, I should "see" something comming from the serial port, even if the debug mode is off, right?
If I don't see anything coming, should I assume something must be wrong with the GW?
I've read somewhere in the forum that the GW sketch is made for Arduino nano, since I'm runing it on an UNO, would it make a difference?
Thanks
-
@joaoabs said in How does the serial GW work after all?:
So, if I connect the Serial GW to my PC, run "serial monitor", and I restart a nearby node, I should "see" something comming from the serial port, even if the debug mode is off, right?
Yes. But without debug you will probably not be able to learn anything more than "working" or "not working".
If I don't see anything coming, should I assume something must be wrong with the GW?
Or with the node.
I've read somewhere in the forum that the GW sketch is made for Arduino nano, since I'm runing it on an UNO, would it make a difference?
Nano and Uno are practically the same. But both are 5V devices and need special handling since radios are 3.3V. Which transport (radio) are you using?
-
Hi,
I'm using the NRF24L01+ with a 4.7uF capacitor between 3.3v and GND on the GW and all nodes.
If I turn debug mode on I can see all the presentations from the nodes (even with signing), so I guess the transport should be OK.
Just for the sake of clarity, the serial port I should "listen" should be /dev/ttyUSBx, right?
I'm asking this becasue I've seen in some places the default configuration of /dev/pts/x and this wouldn't make any sense to me becasue arduino is always conencted via USB, and therefore it should be /dev/ttyUSBx, right? Or would it somehow create some kind of virtual pts port and that should be what we should be listining to?At the moment I just have nanos, mini pros and a UNO. Trying an ethernet GW with SW signing on these nodes will be waste of time, right? (I've read they lack enough resources, so it would be better a more powerful arduino).
I have also an arduino micro, but this doesn't work well with my sensors, right?
Thanks,
-
@joaoabs I haven't used the micro with MySensors so I don't know.
The ethernet shield libraries seem to require a lot of flash and ram yes. I have not tried any myself.
Have you considered using the Raspberry Pi's gpio pins to create a raspberry pi gateway?
What name the gateway is given depends on which linux distribution your Pi is running. But if the device disappears when you unplug the gateway, and reappears when you plug it in again, you can be fairly sure you've got the right one.
The power supply sounds good, as long as you're not using the PA+LNA version of the nrf24.
-
Yes, I have tried the NRF directly in the PI some years ago and it raised its CPU usage to 100%.
I guess the code today should be more stable, if I can't figure out what is the problem with the GW I'll probabily try it.
-
This is actually strange. Its the same sketch, the difference is just the commented debug flag.
With the debug flag off, I reset the GW, wait for the startup and then I reset some nodes in order to force presentation, but all I get is this:
0;255;3;0;14;Gateway startup complete. 0;255;0;0;18;2.2.0
With the debug flag on, I don't even need to reset the nodes, I get "automagically" the communication from my 3 test nodes (4, 10 and 44).
0;255;3;0;9;0 MCO:BGN:INIT GW,CP=RNNGA---,VER=2.2.0 0;255;3;0;9;4 TSM:INIT 0;255;3;0;9;6 TSF:WUR:MS=0 0;255;3;0;9;14 TSM:INIT:TSP OK 0;255;3;0;9;17 TSM:INIT:GW MODE 0;255;3;0;9;20 TSM:READY:ID=0,PAR=0,DIS=0 0;255;3;0;9;23 MCO:REG:NOT NEEDED 0;255;3;0;14;Gateway startup complete. 0;255;0;0;18;2.2.0 0;255;3;0;9;28 MCO:BGN:STP 0;255;3;0;9;34 MCO:BGN:INIT OK,TSP=1 0;255;3;0;9;1915 TSF:MSG:READ,4-4-0,s=1,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;4982 TSF:MSG:READ,44-44-0,s=3,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;6920 TSF:MSG:READ,4-4-0,s=2,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;10014 TSF:MSG:READ,44-44-0,s=4,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;11924 TSF:MSG:READ,4-4-0,s=70,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;15047 TSF:MSG:READ,44-44-0,s=30,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;16928 TSF:MSG:READ,4-4-0,s=71,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;20079 TSF:MSG:READ,44-44-0,s=31,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;21932 TSF:MSG:READ,4-4-0,s=10,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;25122 TSF:MSG:READ,44-44-0,s=70,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;26937 TSF:MSG:READ,4-4-0,s=50,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;30155 TSF:MSG:READ,44-44-0,s=10,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;31941 TSF:MSG:READ,4-4-0,s=60,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;35186 TSF:MSG:READ,44-44-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2 0;255;3;0;9;35194 TSF:MSG:SEND,0-0-44-44,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1 0;255;3;0;9;35217 TSF:MSG:READ,44-44-0,s=30,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;36947 TSF:MSG:READ,4-4-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2 0;255;3;0;9;36955 TSF:MSG:SEND,0-0-4-4,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1 0;255;3;0;9;39106 TSF:MSG:READ,4-4-0,s=70,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;40248 TSF:MSG:READ,44-44-0,s=31,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;44111 TSF:MSG:READ,4-4-0,s=71,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;45270 TSF:MSG:READ,44-44-0,s=70,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;50302 TSF:MSG:READ,44-44-0,s=70,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;53968 TSF:MSG:READ,10-10-0,s=30,c=3,t=16,pt=0,l=0,sg=1: 0;255;3;0;9;64184 TSF:MSG:READ,10-10-0,s=30,c=3,t=16,pt=0,l=0,sg=1: 0;255;3;0;9;69276 TSF:MSG:READ,4-4-0,s=10,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;76290 TSF:MSG:READ,4-4-0,s=60,c=3,t=16,pt=0,l=0,sg=0: 0;255;3;0;9;81298 TSF:MSG:READ,4-4-0,s=50,c=3,t=16,pt=0,l=0,sg=0:
What should I see in the serial GW when the debug mode is off?
My serial GW code is prety standard, I'd say:
/** * 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 serial 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 received. In inclusion mode will blink fast only on presentation received * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly * - ERR (red) - fast blink on error during transmission error or receive crc error * */ // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_NRF5_ESB //#define MY_RADIO_RFM69 //#define MY_RADIO_RFM95 // 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 Arduinos 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 180 // Digital pin used for inclusion mode button #define MY_INCLUSION_MODE_BUTTON_PIN 3 // 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 }
Thanks,