Still not going well for me.



  • Hi there, I apologise in advance if the questions I am about to ask has a post that relates to it already. I have spent the last 2 weeks trying to get this working and I have been all over the forum many times without success so I have resorted to posting here. I have already posted earlier explaining my setup and how it all fits together. If your interested you can read it here.
    https://forum.mysensors.org/topic/5657/im-brand-new-to-mysensor-and-its-not-going-well
    but to recap, I have an Arduino mega with a WS5100 Ethernet Shield, an Arduino Nano, 2 x NRF24L01 modules and a relay module. The post above asks how about errors I was getting on the Mega with the NRF24L01 module, this is now solved or at least it appears to be. Thanks very much mfalkvidd and FotoFieber for your assistance.
    So here is what’s happening now. All I am trying to do to start with is connect the Mega and the Nano together, the mega is my gateway and the Nano is my Node. As the troubleshooting guide suggests, I am starting small therefore I have removed the WS5100 Ethernet shield to simplify.
    Below is a drawing of my Mega setup, as you can see the NRF24L01 is connected to pins 9.10,14,15,16 and 2. This now appears to be working

    0_1484787734665_upload-756de2e0-a520-42bd-b19f-1a6e10d13935

    Below is the sketch for the mega

    * 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
    
    // 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
    }
    

    I am using the default MyConfig.h for the Mega, with one small exception, the #define MY_SOFTSPI is enabled because I am using the Soft SPI pins.

    Below is the Serial-Monitor output.

    0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.0
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;TSF:WUR:MS=0
    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:ID=0,PAR=0,DIS=0
    0;255;3;0;9;MCO:REG:NOT NEEDED
    0;255;3;0;14;Gateway startup complete.
    0;255;0;0;18;2.1.0
    0;255;3;0;9;MCO:BGN:STP
    0;255;3;0;9;MCO:BGN:INIT OK,TSP=1

    So far so good!
    Now we get to the Nano. Below is a drawing, as you can see the NRF24L01 is connected to pins 9.10,13,11,12 and 2. This now appears to be working but it doesn’t seem to be able to reach the gateway.

    0_1484787886579_upload-0ae79ecc-191a-4ca5-aeef-128cf0ca7a3a

    The two devices are sitting about a meter apart so it is very very unlikely to be a range issue.
    Below is the sketch for the Nano

    /**
     * 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 print
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #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
    	bool 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);
    }
    
    

    The MyConfig.h for the Nano is default.

    Below is the Serial-Monitor output.

    0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.0
    3 TSM:INIT
    4 TSF:WUR:MS=0
    11 TSM:INIT:TSP OK
    13 TSF:SID:OK,ID=10
    14 TSM:FPAR
    51 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    2058 !TSM:FPAR:NO REPLY
    2060 TSM:FPAR
    2096 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4104 !TSM:FPAR:NO REPLY
    4106 TSM:FPAR
    4142 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6150 !TSM:FPAR:NO REPLY
    6152 TSM:FPAR
    6188 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    8196 !TSM:FPAR:FAIL
    8197 TSM:FAIL:CNT=1
    8199 TSM:FAIL:PDT

    I have seen on one of the troubleshooting posts that you can use MYSController to try and fault find this. But I can’t find any instructions on how to use it which is to say the least annoying. I tried my best to figure it out but it doesn’t seem to be working. It says it is connected but nothing happens. If you happen to know of instructions that would probably be a good first step.

    It appears to me that the node is not able to connect to the gateway, originally I was getting an error
    4142 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6150 !TSM:FPAR:NO REPLY

    Which if I read the API document correctly is a broadcast. But I set the define MY_NODE_ID 10 in an attempt to connect it to MYSController but could not get it to work so I switched it back to Auto.

    What am I missing?... thanks for any assistance. I am about to give up because this is starting to seem to me to be unnecessarily difficult.



  • @Coffeesnob I had exactly that and it turned out that my radio was faulty. Do you have any spare radio's? The other thing I did to improve the situation was adding an LC filter on the power as well as running the radio's from their own supplies, not from the 3.3v on the mega or Nanos.

    I suggest first use external power for the radios. Directly from the supply a 3.3v regulator and large decoupling cap. If you want you can add an LC filter as well for high frequency filtering (25kHz to 50kHz). If that does not fix things stop out the radios. If you have another nano/mini try to replace the mega. I had problems getting my mega to work as well.



  • Have you tried using 10uf? That fixes the problem for me.
    You can use between 4.7 upto 47uf. Most people I've read the 10uf fixes it.

    As stipulate at mysensors:
    0_1484820424349_47uf.JPG

    Maybe, Mysensors should really highlight that? :)



  • MarcoE- thanks for the tip. I don't have a spare radio but I have another Arduino project I can load which is from another home automation system (DeviceBit) , when load that up I get 100% reliable communication between the two radios so I'm pretty sure its nothing at all to do with hardware.

    iotearoa- I am not convinced that the issues is power related. given that the Devicebit method doesn't require a cap and it is using the power from the Arduino. Never the less, i have a 10uf cap i can try.

    Having said that clearly given the very low number of responses I must be the only one with this issue. so i think what I'm going to do now is reverse engineer a test communication network using the code from DeviceBit. if I get this to work, then I will post the results here. this may also end up being useful for somebody else because, to be honest, the diagnostics on mysensors are a little bit light on and this makes the exercise a lot frustrating.


  • Admin

    @Coffeesnob If you can, you may want to try using two nanos or pro minis before trying to use the Mega. Mega's can be tricky to get right the first time. Also, where are you defining the radio pins for both of the sketches? Did you do it in myconfig.h? If so, did you change it back when you uploaded the nano code?



  • @petewill, thanks for the tip. I think you might actually be onto something. But as I don't have any other nano's that's not really an option today. I have order more but they will take at least 3 weeks to get here.

    having said that, I have made some important discoveries in the last 24 hours. bottom line I have written a test sketch that runs on both a nano and a Mega and it send messages back and forth between them. This has proven 100% that the issue is not hardware related but it is software related. Now my plan is to write a script that uses the MyConfig.h to get the SPI settings. That way once it's all working with the test sketch you will have a very high probability of it working with Mysensors.

    also while I have your attention. I really found your troubleshooting video very very helpful, thanks a lot for doing that. but I wonder do you happen to have or know of a video which shows how to use MYSController. once I get past my current woes I suspect I will need MYSController to resolve other issues.

    thanks for your help so far. i really do appreciate it.


  • Admin

    @Coffeesnob Yeah, I would order a couple of Nanos (or Pro Minis). They are cheap and are always helpful for troubleshooting.
    Here is how I have my devices wired:
    0_1485012164542_upload-fb984670-b18c-497b-9167-e19bfd517a28
    *need to configure these pins in the sketch

    Here is the code you will need to configure the sketch of the Mega. Make sure to put these lines above the #include <MySensors.h> line.
    #define MY_RF24_CE_PIN 49
    #define MY_RF24_CS_PIN 53
    You should not need to change anything in MyConfig.h if you wire as described above.

    The Nano can be wired as described above and no changes need to be made in your sketch or MyConfig.h. This code assumes you are using MySensors 2.x.

    I hope that makes sense.

    As for a MYSController video, I'm not aware of any out there yet. I have it on my list of videos to make but it's not at the top...



  • @petewill, Wow this is EXACTLY what I have been looking for. thanks very very much. I will give it a try.



  • @petewill, you sir are a star... this was the information I was missing and it is now working as expected. below is the serial monitor trace from both the Mega and the Uno.

    First the Mega

    0;255;3;0;9;MCO:BGN:STP
    0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
    0;255;3;0;9;TSF:MSG:READ,10-10-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
    0;255;3;0;9;TSF:MSG:SEND,0-0-10-10,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
    0;255;3;0;9;TSF:MSG:READ,10-10-0,s=1,c=1,t=16,pt=0,l=1,sg=0:1
    0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.0
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;TSF:WUR:MS=0
    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:ID=0,PAR=0,DIS=0
    0;255;3;0;9;MCO:REG:NOT NEEDED

    and this is the Uno...
    8994 TSF:MSG:SEND,10-10-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:1
    9000 MCO:SLP:MS=120000,SMS=0,I1=1,M1=1,I2=255,M2=255
    9006 MCO:SLP:TPD

    I have literally spent hours on this. I think the documentation in terms of getting started needs to be expanded on considerably. I get this is a huge task but if you don't know much about Arduino or know where to look you pretty much screwed.


  • Mod

    @Coffeesnob we try to add as much information as possible in the documentation, without overwhelming users with more information than they can handle. Too much information will make people cringe and go somewhere else.

    The Mega is big and relatively expensive. Therefore most people use Nano or Pro Mini. I'm hesitant to add a lot of information for non-common use cases because that information will not be relevant for most users and therefore will just be annoying when people try to create their first sensor.

    I have updated the connecting the radio page to include wiring information and the defines for Mega.

    Could you list the top 3-5 things that would have helped you the most, and where you would have expected to find that information? That would be great input.



  • @mfalkvidd thanks for your reply. I was going to try and contact you about this very thing. If its ok can I PM you will suggestions, I completely get what you’re talking about, I know this problem very well. But there is a way you can provide the information required that is not so in your face which I agree can be an issue.
    I would also like to develop a test Sketch that can be used to prove that all the hardware is working independent of anything in the API. This would have made my experience that much easier because I was not actually able to determine where the issue was until I had first proven that it was not the radio or the two different boards I am using (which was suggested in this post as well as in the troubleshooting guide). Are we able to perhaps have a chat via email or something about how to facilitate that?


  • Mod

    @Coffeesnob Great, thanks!
    PM is ok if you don't want to discuss it in a forum thread.


  • Admin

    @Coffeesnob Sorry for the delayed reply. I was in the mountains the last few days. I'm glad you got it working! There are a lot of different factors at play when designing your own sensors and learning something new can take time but I think you are over the biggest hurdle now.

    @mfalkvidd thanks for updating the documentation. You are awesome!



  • @petewill, appreciate it. I'm very happy with the outcome, for the most part. However, I now have a new challenger. I am using a relay module and I can happily turn relays on using MYSController but can't seem to figure out how to turn them off. I know you know a little about this product so I wonder if you can point me in the right direction.
    I have also connected to my gateway serially using HomeGenie and it can't turn either on or off. but I haven't had time to do any further fault finding there yet.

    As soon as I have time, I will provide promised doc. i then need to know where to send them.



  • @mfalkvidd, I can post here no problem. but I also want to provide a how-to of sorts that will help newbies like me to rule out anything that is Mysensors related. I just thought this would require me a to PM you


  • Admin

    @Coffeesnob said in Still not going well for me.:

    I am using a relay module and I can happily turn relays on using MYSController but can't seem to figure out how to turn them off.

    Can't you just send a 0 instead of a 1? I don't ever use MYSController for controlling devices. Only for monitoring traffic. All my control is done with Vera. That being said though you should only need to send a 0 to turn off the relay.



  • @petewill, yep you would think that would do it... however, it doesn't seem to work. what is interesting is if I send a 1 it also doesn't turn on the relay, only sending an empty message turns it on. I think I might post in the MYSController forum to see if they have any ideas.


  • Admin

    @Coffeesnob hmm, can you post your sketch and the debug logs, I assume something must be wrong the way you process incoming messages.



  • @tekka, will do. I have had a hardware related issue that is unrelated to this directly. (i bricked my Nano trying to flush the eprom) but it means that until I get this fixed or get new hardware I am not going to be able to do anymore. Im hoping that Im getting close because this is really getting pretty frustrating.



  • @mfalkvidd, I have finally had the opportunity to reply to your question from a week back “Could you list the top 3-5 things that would have helped you the most, and where you would have expected to find that information? That would be great input.”
    Ok so I think the big thing is there is not a lot of detail in troubleshooting. Clearly the radios are the most problematic part and not being able to get access to how they actually work makes it very frustrating. The table that peterwill provided is very helpful but this also requires you to have some background information.
    I understand that you are trying to limit the amount of detail so as not to scare people away but I personally believe that having optional reference material would be extremely helpful. For example a diagram which explains how all the different liberties link together, this would have helped me to determine how the SPI components are setup.
    It would have been extremely helpful if in your initial radio setup guide you had a reference to how the SPI components of the radios work. This would be an optional reference that people could look at if they wanted to. At the moment, the way these radios work is very much black magic, and because I am new to the whole Arduino thing I was unable to determine if you are using the standard SPI features of the Arduino or if you had created your own. An example of a reference might be https://www.arduino.cc/en/reference/SPI however it is also important to explain that Mysensors is using its own SPI library, you could (should) go into more detail about how the SPI library is setup from the Mysensors point of view, because if you have to work it out your self this is very chanalgin because there is no common reference to understand how Arduino default SPI relates to mysensors SPI

    And finally, something which would make things oh so much easier, is a sample sketch that will just allow you to test the radios, i.e you type the number 1 into the serial monitor on the gateway and you will see a message on the node if the radios are all working. And vice versa. I am willing to take this on as a project as I am already working on it however I would ideally like it to use all the Mysensors library’s. In other words, it should behave like any other sensor network would. But I really need a lot more information to work out how to do this. In the meantime, once I get my radios back up and running again I will post a very quick and dirty version and let you have a look at it.
    I hope this all makes sense. I am a huge fan of the work the my sensors team have done here. I want to do what I can to help make it better.


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.