πŸ’¬ Connecting the Radio


  • Admin

    This thread contains comments for the article "Connecting the Radio" posted on MySensors.org.



  • If you are powering the device by batteries, I'd suggest to avoid electrolytic decoupling capacitors and go for ceramic or film one since the latter have a smaller leakage current, avoiding battery drain.


  • Hardware Contributor

    Don't forget the antenna if you use a RFM69 or you may damage your device.


  • Hardware Contributor

    @FotoFieber - Good one, I added the warning on the build site.


  • Admin

    Might be good with a antenna wire-cutting guide for different frequencies as well.


  • Hardware Contributor

    @hek - I can look into that.



  • Hi all,

    I'm using the Arduino Micro with al NRF24L01 radio. With the micro it's not posible to use the pin config of the Nano.
    I got it working with the connections below.

    NRF24 > Micro
    Miso > Miso
    Mosi > Mosi
    SCK > SCK
    CSN > Pin D7
    CE > Pin D8

    Thereby I put the code below in my arduino code before de "#include <SPI.h>"

    // Pin Confuguration for Arduino Micro
    #define MY_RF24_CE_PIN 8
    #define MY_RF24_CS_PIN 7

    Maybe this is helpful for some other users.

    Grtz Diver



  • "try adding a decoupling capacitor of 4.7Β΅ - 47Β΅F (the exact size usually doesn't matter)"

    I can use 4.7Β΅ or 47Β΅ only ? or a size between 4.7 and 47 ?



  • @carmelo42 Any size between 4.7Β΅ any 47Β΅ will be fine.



  • thanks @arraWX πŸ™‚



  • Can I use a RFM69HCW as radio?



  • Can I use an arduino nano for this? If so, What pins do I use? Also, will I need to change the code?


  • Admin

    @drradkin said:

    Can I use an arduino nano for this? If so, What pins do I use? Also, will I need to change the code?

    Yes you can. Use the same pins for Nano.



  • I used RFM69 with Arduino before and a library where I have to initialize the radio with the frequency (868MHZ in my case) Does the mysensors library work for all frequencies of RFM69 without telling it which frequency to use?


  • Mod

    @gvorster 868 is the default so you don't need to do anything. If you want to change it, add

    #define MY_RFM69_FREQUENCY
    

    before including MySensors.h in your sketch. See https://github.com/mysensors/MySensors/blob/a31eff112e4895198bf6ec385fdeedb2910bb628/MyConfig.h#L588 for valid settings.



  • @mfalkvidd said:

    @gvorster 868 is the default so you don't need to do anything. If you want to change it, add

    #define MY_RFM69_FREQUENCY
    

    Great, thanks!



  • @DiverAlpha said:

    Hi all,

    I'm using the Arduino Micro with al NRF24L01 radio. With the micro it's not posible to use the pin config of the Nano.
    I got it working with the connections below.

    NRF24 > Micro
    Miso > Miso
    Mosi > Mosi
    SCK > SCK
    CSN > Pin D7
    CE > Pin D8

    Thereby I put the code below in my arduino code before de "#include <SPI.h>"

    // Pin Confuguration for Arduino Micro
    #define MY_RF24_CE_PIN 8
    #define MY_RF24_CS_PIN 7

    Maybe this is helpful for some other users.

    Grtz Diver

    @DiverAlpha
    Thanx a lot for commenting with that information. I was having problems with the Arduino Mega. I connected the NRF24L01+ to the appropriate SPI pins on the Mega and then just defined the CE and CS pins in the code an now it works. Thanks again



  • Hi all,

    I tried a lot in the last coup[le of days but I can't get my network up and running...

    I've got a Micro DHT sensor ans a Uno Ethernet Gateway.

    The output of 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
    IP: 192.168.5.8

    So I think this is nice but I'm not complete sure.

    The output of the DHT sensor:
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=105)
    TSM:FPAR
    TSP:MSG:SEND 105-105-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 105-105-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 105-105-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 105-105-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    !TSM:FPAR:FAIL
    !TSM:FAILURE
    TSM:PDT

    To me it seems that the sensor cannot get a good connection to the gateway by the RF connection. The physical distance between de two RF modules is about 15 cm and I'm using a 10uF condensator on both of the RF modules.

    Can someone tell me what I'm doing wrong?

    Tnx in advance!


  • Mod

    @DiverAlpha try moving the nodes further apart. It might be counter-intuitive, but many have had problems when nodes are too close.

    Do you get nothing at all in the log of the gateway when the sensor tries to find parent?



  • @mfalkvidd, They are now 2 meters apart from each other but still the same problem. I was thinking in this direction also but because I build those two on the same breadboard, it was a bit difficult to separate them. I now build the sensor on another breadboard and moved is 2 meters away. It can't be any longer because of the length of my USB cables.

    All the logging I got from the gateway is posted in my previous post. So there is nothing about any child in there.


  • Mod

    @DiverAlpha strange. You could try hard-coding the parent on the node, see MY_PARENT_NODE_IS_STATIC and MY_PARENT_NODE_ID on https://www.mysensors.org/download/sensor_api_20



  • @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.



  • Hy all,

    Thanks for your help. Unfortunately it didn't solved the problem :-(.
    I tried it with putting the NODE_ID's om static but that didn't help. MY_PARENT_NODE_IS_STATIC is totally not recognized in the Arduino IDE...

    I tried just what @palande.vaibhav mentioned with the code he posted. The only adjustment is that I had to change the CE and CS pin on the sensot because I'm using a Adruino Micro. Further the code was just copy-paste but the same result in the serial communication as I posted earlier. (Except now the ID was 1 in stead of 105...)



  • @DiverAlpha
    I tried it on my setup. The node shows the output with BC (st=bc) when I only have the node connected in that is powered ON. But when I power ON my gateway in they start communicating and I get st=ok.

    Here is the node without gateway connected:

    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=1)
    TSM:FPAR
    TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    !TSM:FPAR:FAIL
    !TSM:FAILURE
    TSM:PDT
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=1)
    TSM:FPAR
    TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    

    After I power ON the gateway I get following output:

    TSM:PDT
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=1)
    TSM:FPAR
    TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-1 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
    TSM:CHKID:OK (ID=1)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:MSG:READ 0-0-1 s=255,c=3,t=25,pt=1,l=1,sg=0:1
    TSP:MSG:PONG RECV (hops=1)
    TSP:CHKUPL:OK
    TSM:UPL:OK
    TSM:READY
    SHT31 test
    TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
    TSP:MSG:SEND 1-1-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0
    TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:0
    TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=11,pt=0,l=22,sg=0,ft=0,st=ok:Temperature and switch
    TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=ok:1.0
    TSP:MSG:SEND 1-1-0-0 s=0,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=ok:
    TSP:MSG:SEND 1-1-0-0 s=1,c=0,t=7,pt=0,l=0,sg=0,ft=0,st=ok:
    TSP:MSG:SEND 1-1-0-0 s=2,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=ok:
    Request registration...
    TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2
    TSP:MSG:READ 0-0-1 s=255,c=3,t=27,pt=1,l=1,sg=0:1
    Node registration=1
    Init complete, id=1, parent=0, distance=1, registration=1
    TSP:MSG:SEND 1-1-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.0
    Temp *C = 21.32
    TSP:MSG:SEND 1-1-0-0 s=2,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:21.32
    Hum. % = 75.48
    TSP:MSG:SEND 1-1-0-0 s=1,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=ok:75.48
    

    Basically you need to have at least one node and a gateway working for MySensors to run properly.
    Here is the thread I started when I had the same problem: https://forum.mysensors.org/topic/4941/problem-getting-the-code-to-run-with-mysensors-library-2-0/35

    Read last few comments, you will get the idea of what I am saying. You can also try the fix for this suggested by ayo in the comment #35.



  • @gvorster said:

    @mfalkvidd said:

    @gvorster 868 is the default so you don't need to do anything. If you want to change it, add

    #define MY_RFM69_FREQUENCY
    

    Great, thanks!

    I have a RFM69HCW and was getting a terrible connection from 5 meters through two thin walls.

    After using:

    #define IS_RFM69HW
    

    The connection and range is incredible!
    I live in an appartment 3rd floor, put a node in my mailbox which is 15 meters below and still got sensor data.
    This did not work for me before using NRF24L01+



  • Hi
    how long is real range on radio RFM69HW ? It is better than NRF24L01 ?


  • Admin

    @pepson said:

    how long is real range on radio RFM69HW ? It is better than NRF24L01 ?

    Yes, generally, lower frequency -> longer range (but also lower transmission speed).



  • But speed RFM69HW is too slow ? For use it to relay switch and some sensors... ? What is better to home automation ? RFM69HW or NRF24L01 ?



  • @pepson said:

    Hi
    how long is real range on radio RFM69HW ? It is better than NRF24L01 ?

    This post has some more info on this: Which is better: RFM69 or NRF24L01+

    I want to use these radio's indoors and need to have a good connection through a couple of thin walls. My impression is that the RFM69 has at least better wall penetration. I'm using the RFM69HCW 868Mhz with only a 82mm wire connected to the ANT pin.

    I tested the Mock sketch and enabled a few mock sensors. Throughout my appartment I have no problem having a good connection.

    But, there are fake NRF24L01+ chips out there which might be the cause of my penetration connections errors.

    I'm buying my RFM69 radio's from a reliable distributor in the Netherlands http://webshop.ideetron.nl/HopeRF



  • When uusing RFM69HW i must also use Capacitor as for NRF24L01 ?


  • Hero Member

    @pepson

    I do not think that the RFM69HW is as sensitive as the NRF24L01 but adding a Capacitor will not hurt.
    It also depends on how clean your power source is. If the power is clean you do not need to filter it using Capacitor.



  • Hi guys!

    I'd like to ask you about a problem. When I use RFM69 radios on my nodes, they are working fine, but when I try to use the NRFs everything is falling apart and that's driving me crazy. I can't find the solution to use NRFs (I've got 20 of them). I tried everything, read the forum a hundred times, but can't find the solution. Poer sources are perfect, every NRF has it's own 3.3v source and after a few hours or a few days perfect working, the nodes disappear (not all and not in the same time). I'm using Domoticz as controller on a RPI 2. I saw the node's L13 led's blinking is much lighter after the node disappears. When it's working okay, the led is blinking on full.

    Thank you for the suggestions, and have a nice day


  • Mod

    @ZsoltZombori what does the serial debug output of the nodes say?



  • @ZsoltZombori

    I had a problem of the LED on pin 13 glowing dim after some time of system running fine when I had 2 sensors connected to the Arduino and sensors had their own separate 5V power supply. So, I had a 5V power supply separate from the Arduino's 5V and that was supplying current to those sensors.

    I had the sensor's data pins connected to Arduino but I didn't have GND of power supply and Arduino connected. I solved the problem by connecting the GND of power supply to the GND of the Arduino.

    See if that is the case with you.

    Hope this helps.



  • @mfalkvidd I put the node on serial for the night and everything works fine now. No errors occured, I'm still waiting.
    @palande-vaibhav The GNDs are always connected in my circuits to prevent GND problems. Thanks for the tip.



  • @ZsoltZombori
    Exactly that was a problem with my system too. When I had it connected to the computer using the serial cable everything would just run fine but as soon as I removed the serial cable from computer and let it run on its own with the power supply connected with a DC jack, everything would just fall apart the LED's would go dim and that's when I discovered the problem of the ground but you already have all the grounds connected so I'm out of clues here.
    I would suggest you to check the power supply connections again with a multimeter to make sure that everything is connected properly.



  • @palande.vaibhav I double checked everything and the PCB is perfect. Still waiting for a failure, but it's working now. I'm wondering what was the problem for weeks with the NRFs. The RFMs are working like a charm. Anyway, thank you for the ideas πŸ™‚
    Edit: there were two fails in ~21hrs, I attach the debug code:

    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=3)
    TSM:FPAR
    TSP:MSG:SEND 3-3-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-3 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
    TSM:CHKID:OK (ID=3)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:MSG:READ 0-0-3 s=255,c=3,t=25,pt=1,l=1,sg=0:1
    TSP:MSG:PONG RECV (hops=1)
    TSP:CHKUPL:OK
    TSM:UPL:OK
    TSM:READY
    TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
    TSP:MSG:SEND 3-3-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0
    TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:0
    TSP:MSG:READ 0-0-3 s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    TSP:MSG:READ 0-0-3 s=255,c=3,t=6,pt=0,l=1,sg=0:M
    TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=11,pt=0,l=18,sg=0,ft=0,st=ok:Temperature Sensor
    TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=ok:1.1
    TSP:MSG:SEND 3-3-0-0 s=0,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=ok:
    Request registration...
    TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2
    TSP:MSG:READ 0-0-3 s=255,c=3,t=27,pt=1,l=1,sg=0:1
    Node registration=1
    Init complete, id=3, parent=0, distance=1, registration=1
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.6
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.6
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.6
    [...]
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.6
    !TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=fail:22.6
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=1,st=ok:22.6
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.6
    [...]
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.5
    !TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=fail:22.5
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=1,st=ok:22.5
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.4
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.4
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.4
    [...]
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.5
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.5
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.5
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.4
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.4
    TSP:MSG:SEND 3-3-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:22.4
    


  • How i must change sketch Gateway and node to use radio RFM69HW ? In sketch i see only for simple RFM69 not RFM69HW.


  • Hardware Contributor

    for using RFM69HW, you just need to use the common rfm69 defines and add this

    #define MY_IS_RFM69HW
    


  • @scalz
    Do you add the rfm69hw def to the gateway sketch or to the myconfig.h?


  • Hero Member

    @rmtucker

    You add the #define to your sketch

    Hi @scalz ,
    Will a RFM69HW work without the "#define MY_IS_RFM69HW" ?

    What exactly does this #define do for the HW version?

    Have only used RFM69W so far but have ordered some HW now also.


  • Hardware Contributor

    to your GW sketch.
    Also, for using RFM69H you need this define,else the radio can't work properly. This allow us to set the right Radio power level registers in lib.
    @korttoma just curious πŸ™‚ Have you tried my rfm69 repo?


  • Hero Member

    @scalz
    So does a H version radio work if you do not set the high power registers?

    @scalz said:

    @korttoma just curious Have you tried my rfm69 repo?

    Sorry, I have not yet had the opportunity to test your repo. There is so much non MySensors activities now when Christmas is approaching.



  • With radio RFM69HW for gateway sketch should looks as:

    /**

    • 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
    #define MY_IS_RFM69HW

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

    // Send the sketch version information to the gateway and Controller
    sendSketchInfo("MySensors Serial Gateway", "2.0.0");
    }

    void loop() {
    // Send locally attached sensor data here
    }

    ?????


  • Hardware Contributor

    @pepson if you're using an Arduino Mini pro or equivalent, and follow the recommanded wiring for the radio (CS and INT), looks ok to me.

    @korttoma oki. no it won't work if the define is not set for HW version, and vice versa. Because the W and HW use different registers for setting power levels



  • Now i test it on Arduino nano byt finally i want use it on Arduino Mini Pro. Wirering i use as show on this page.


  • Hardware Contributor

    @pepson oki. But you've not explained what's your problem, without logs etc..



  • Now any problem. I only need info how write sketch to use radio RFM69HW.



  • @scalz
    Is there an instruction to alter the power level on the RFM69?
    From inside a mysensors sketch like the NRF24_PA_level?


  • Hardware Contributor

    @rmtucker no not yet (not sure, i need to check). But yes, in the next release πŸ˜‰



  • @pepson said:

    Now any problem. I only need info how write sketch to use radio RFM69HW.

    Try the MockMySensors.ino sketch and enable a few sensors.



  • Good will be add manual how in sketch change level for RFM69HW when new version released. I know that should be released on chrismass


  • Hardware Contributor

    @pepson if you have been kind this year, perhaps πŸ˜†



  • I'm having trouble with the distance between my 2 RFM69 radios. If I use this tutorial and change the frequency to 433 mhz I get distances of up to 10 meters - https://learn.adafruit.com/adafruit-rfm69hcw-and-rfm96-rfm95-rfm98-lora-packet-padio-breakouts/rfm69-test

    However if I use the Mysensor libraries for the SerialGateway and the door sensor I don't even get 1 meter.
    I tried to declare these variables as well but no success.

    #define RFM69_FREQUENCY RF69_433MHZ
    #define IS_RFM69HW

    Any suggestions I might try out?

    Thanks,
    Martin



  • If i buy from aliexpress RFM69HW and when buy i select to seller info that i want 868MHz and on PCB RFM69HW has select/write 868MHz in sketch i must use item:
    #define RFM69_FREQUENCY RF69_868MHZ ?



  • @martins

    Solved. This is the extra variables for the RFM69H / HW versions and to set the frequency.

    #define MY_RFM69_FREQUENCY RF69_433MHZ
    #define MY_IS_RFM69HW

    Range is now acceptible.

    Regards,
    Martin



  • @pepson

    From library API:

    MY_RFM69_FREQUENCY RF69_868MHZ For other frequency, add this define to your sketch and set it to your preferred value in RF69_433MHZ, RF69_868MHZ or RF69_915MHZ

    So it seems that 868MHZ is the default value.

    Regards



  • Ok thanks



  • I m getting symbols when I send Hello World message from Arduino Uno to an Arduino Pro Mini (5V).
    Yes I have put an input of 3.3V to the pro mini.
    Baud rate used is 9600.
    Any clue why this is happening? I can provide the code.


  • Mod

    @LaMB95 are you using a Pro Mini 5V 16MHz or Pro Mini 3.3V 8MHz?

    If the wrong variant is selected in the Arduino IDE, all timings will be off, including the timings for serial communication.



  • @mfalkvidd

    I have an arduino pro mini 5V. But I have attached a breakout CP2102 usb connection to it. On the board there is a 3.3V point which I have plugged in as Vcc to the NRF24L01+ module.

    To upload the code I have selected the 5V 16Mhz as processor.


  • Mod

    @LaMB95 Interesting. I have never seen a 5V Pro Mini with 3.3V output. Where did you get it?

    Try different serial speeds in the serial monitor and see if you get something readable.



  • This post is deleted!

  • Mod

    This post is deleted!


  • @flopp :
    No, it isn't that easy.
    To improve your NRF, please have a look at https://forum.mysensors.org/topic/1851/extending-range-of-regular-nrf24l01.

    I tried solution Nr. 2. It is easy to do and cheap. Improvements are noticeable but not dramatically.

    In regard to effort it is worth trying.

    If you aimed at changing NRF's frequency - no this is not possible at all. Base frequencies are selected within the chip itself and antenna resonant frequency has to match oscillator frequency.



  • @mfalkvidd Haha not really a 3.3 output I changed its input voltge to 3.3 hoping it would work.

    But nevertheless I managed to solve the issue.
    It seems to be an error in the Hardware serial.

    Refer: http://forum.arduino.cc/index.php?topic=46458.0

    The code bhagman has posted worked !



  • @mfalkvidd

    It worked yesterday now I am back to the same problem.
    What a wonder !


  • Hardware Contributor

    Hi !

    It seems that the FRM69 library set the IRQ pin as optionnal. Can someone confirm that the IRQ pin is mandatory ?


  • Admin

    @napo7 yes, it is mandatory since the driver is IRQ-dependent


  • Hardware Contributor

    Well, I had a look in RFM69 driver, and it seems that the interrupts handlers are never sets ?
    Am I wrong ?

    Edit : In facts, DIO0 is not used as an Interrupt source in RFM69 driver : it's a pin that informs the library that, either, a packet has been received, or , the frame we try to send has been sent.

    So, the code doesn't use interrupts, but this pin is more a "Data available" pin.


  • Hardware Contributor

    @napo7
    so, if data available or data sent, this can be an interrupt source for an mcu πŸ˜‰
    It's enabled in the init there https://github.com/mysensors/MySensors/blob/development/drivers/RFM69/RFM69.cpp#L123


  • Hardware Contributor

    Yes I noticed it !
    Since it didn't mention IRQ pin, I didn't seen it at first !

    What misleaded me, is that on LowPowerLab forums, some users says that you can absolutely discard this interrupt and poll the radio frequently to ask if a packet is available.



  • I had this working perfectly on my Arduino Uno. I soldered it up to my Arduino Nano and it seems to work ok, but I'm not getting any data sent. The serial says it's connected OK but never sends any motion 1s or 0s. My MQTT server shows the following: Client mosqsub/3449-raspberryp received PUBLISH (d0, q0, r0, m0, 'mygateway1-out/255/255/3/0/3', ... (0 bytes))

    Any idea what is going on? I've tested the motion sensor separately and that is sending a high value to pin 3 no worries.


  • Mod

    @adamp237
    Enable debug on the node and add some more serial prints in order to see better in detail where the code runs and where not



  • where can I find the picture for connecting NRF to arduino uno?


  • Mod

    @siddmon to my knowledge, Arduino Uno the same pins as on Arduino Nano, Arduino Pro Mini and all other atmega328-based Arduino boards.



  • @mfalkvidd Thanks and yes, they have the same pins, I didn't see Uno in the table so I google it and got incorrect instructions.
    Now that I used the same as nano my node seems work πŸ™‚


  • Mod

    @siddmon great! Thanks for reporting back.



  • Little mistake in the text, I don't think dupont cables are made of bread.
    "the antenna need to be single core inside, only one wire, not multi-wire breaded like you can find in common dupont cable (not good for antenna.)"
    should be
    "The antenna need to be single core inside, only one wire, not multi-wire braided like you can find in common dupont cable (not good for antenna)"


  • Mod

    @nitroburn thanks! I've updated the page.



  • @mfalkvidd No problem, did make me a little hungry though.


  • Mod

    🍞 🍞



  • Can anyone change the text for "Configuring MySensors for RFM69". When you want to use another pin for cs itΒ΄s not this code:

    // #define RF69_SPI_CS 15 // If using a different CS pin for the SPI bus

    but this

    // #define My_RF69_SPI_CS 15 // If using a different CS pin for the SPI bus


  • Mod

    @Grave thanks for pointing this out. From looking at the source code, it looks like it should be MY_RFM69_CS_PIN. I have updated the text. Could you check if I got it right?



  • Thanks, you are right.



  • which one is better RFM69 or NRF24L01+


  • Mod

    The problem is that nrf24 have many crappy clones that have limited range and it is difficult to find the original ones. Rfm69 is slower but have better wall penetration and modules come in 3 frequencies.


  • Hardware Contributor

    Nrf24l01+ also drains less current when sleeping vs RFM69


  • Mod

    @joseyapor neither is better. They are good at different things. See https://forum.mysensors.org/topic/3993/nordic-or-hoperf-radio/2 for an earlier discussion.



  • @mfalkvidd said in πŸ’¬ Connecting the Radio:

    @Grave thanks for pointing this out. From looking at the source code, it looks like it should be MY_RFM69_CS_PIN. I have updated the text. Could you check if I got it right?

    It looks like that MY_RFM69_CS_PIN is used only in develop branch.
    Stable brach still using MY_RF69_SPI_CS.


  • Mod



  • @mfalkvidd
    Hmm.... Is not that a reference to the development branch? πŸ™‚
    I think that right content for stable branch is: https://github.com/mysensors/MySensors/blob/master/MyConfig.h
    If you donΒ΄t believe it, try to download a stable branch, unpack and search for string "MY_RFM69_CS_PIN".


  • Mod

    @RAD-X yes, you are correct. Thanks for noticing.

    I thought that if I selected the master branch on github and used the search function, the search results would only show hits from the selected branch. But it seems like this is not the case.

    Linking to a specific line in a file doesn't work very well, because that line might move by later commits. That's why I select a specific commit to link to. But as you point out, my link points to a commit in the development branch.

    The correct link is https://github.com/mysensors/MySensors/blob/8bb3cfb2e14214ae19e8531c989d1e81c9660614/MyConfig.h#L663 and there is indeed no support for MY_RFM69_CS_PIN.

    I'll update the documentation again. The documentation is meant to reflect the current stable branch.

    EDIT: Found this in the Github documentation:

    Only the default branch is considered.

    So there is no way to search in the stable branch.



  • I have one question regarding the length of the 868MHz antenna. According to the theory, a the wavelength of a 868Mhz signal is 300/868 = 34.6 mm, so a quarter wave antenna should be 8.6mm long. The table above indicates 8.2mm. May someone confirm the correct figure, and also indicate how critical is that difference in terms of range?


  • Mod

    @manutremo the speed of electromagnetic waves is slower in metal than in vacuum, that's why the length is shorter.

    My experience is that the length doesn't need to be exact, but antenna theory is way too complicated for me to understand the details.



  • Many thanks @mfalkvidd . That explains it.

    While waiting for an answer I also found some sites which mention that the speed of electromagnetic waves is even slower if the conductor has an isolation layer around, which would further justify the difference.

    Many thanks! πŸ‘


  • Mod

    @manutremo I think that part is due to skin effect.



  • @mfalkvidd Many thanks again... I learn new things every day.



  • @manutremo said in πŸ’¬ Connecting the Radio:

    I have one question regarding the length of the 868MHz antenna. According to the theory, a the wavelength of a 868Mhz signal is 300/868 = 34.6 mm, so a quarter wave antenna should be 8.6mm long. The table above indicates 8.2mm. May someone confirm the correct figure, and also indicate how critical is that difference in terms of range?

    I tried 3 types of antennas with RFM69HCW 868mhz.

    1. Just a 8.6 cm wire

    2. helical antenna

    alt text

    1. sma antenna

    alt text

    Indoor in my appartement (one floor) it doesn't matter which one I use. All is working fine.
    I tried 2 nodes in my metal mailbox 10 meters below which has 2 tiny holes.
    One with helical antenna, one with sma antenna.

    Gateway (using sma antenna) receives no data.

    Testing two repeater nodes (1 helical, 1 sma antenna) near a window I receive data via both repeaters. Sometimes the repeater with sma antenna is not relaying messages for the node with the sma antenna.

    In my situation, the helical antenna works better for me. I just buy them on ebay.


  • Mod

    Maybe the sma antenna is for the wrong frequency and it's giving poor results.


Log in to reply
 

Suggested Topics

  • 3
  • 5
  • 109
  • 163
  • 2
  • 347

21
Online

11.2k
Users

11.1k
Topics

112.5k
Posts