πŸ’¬ Building a Raspberry Pi Gateway



  • @mfalkvidd That was the culprit. Thanks.
    But now... seems that the radio that is using channel 76 also get connections from nodes on channel 83, and the second radio, the 83 one doesn't pick anything.

    Is there a way to confirm that gw and nodes are using one channel or other during the bootup?


  • Mod

    @Sergio-Rius try increasing the distance between channels to at least 10 or more



  • @gohan Done. I've just burnt the node with channel 125 and it seems to have no effect. It registers on the 76 radio.

    Does the #define MY_RF24_CHANNEL 125 has to be before or after the include of mysensors.h? I have it before.



  • Well, I've changed the channel for the 1st radio to 83 and left the second at 125.
    If I burn the testing node for ch125 it doesn't receives reply from the gw. If I then burn it on ch83, it registers and comunicates with the first radio.

    So I think the second radio does not work on the Raspberry Pi. The service communicates with the controller but does nothing for the network side.
    Also on the second radio:

    mysgw: Client 0: 0;0;3;0;18;PING
    mysgw: Client 0: 0;0;3;0;18;PING
    mysgw: Client 0: 0;0;3;0;18;PING
    mysgw: !TSF:SAN:FAIL
    mysgw: TSM:FAIL:CNT=1
    mysgw: TSM:FAIL:DIS
    mysgw: TSF:TDI:TSL
    mysgw: Client 0: 0;0;3;0;18;PING
    mysgw: TSM:FAIL:RE-INIT
    mysgw: TSM:INIT
    mysgw: TSM:INIT:TSP OK
    mysgw: TSM:INIT:GW MODE
    mysgw: TSM:READY:ID=0,PAR=0,DIS=0
    mysgw: Client 0: 0;0;3;0;18;PING
    mysgw: Client 0: 0;0;3;0;18;PING
    

  • Mod

    @Sergio-Rius if you shut down mysgw for the first radio and restart mysgw for the second radio, does the second radio start to work?
    And do you get the same debug output? The SPI message looks bad. Maybe the two gateways are conflicting.



  • @mfalkvidd Nope, the service seems to have stopped the SAN errors but still no communication:

    pi@domo_testing:~/MySGW_RFM $ sudo ./bin/mysgw -d
    mysgw: Starting gateway...
    mysgw: Protocol version - 2.2.0-beta
     __  __       ____
    |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.2.0-beta
    
    mysgw: MCO:BGN:INIT CP=RNNG--Q-
    mysgw: TSF:LRT:OK
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: TSM:INIT:TSP OK
    mysgw: TSM:INIT:GW MODE
    mysgw: TSM:READY:ID=0,PAR=0,DIS=0
    mysgw: MCO:REG:NOT NEEDED
    mysgw: Listening for connections on 0.0.0.0:5004
    mysgw: MCO:BGN:STP
    mysgw: MCO:BGN:INIT OK,TSP=1
    mysgw: New connection from 127.0.0.1
    mysgw: Client 0 connected
    mysgw: Client 0: 0;0;3;0;2;
    mysgw: Client 0: 0;0;3;0;2;Get Version
    mysgw: Client 0: 0;0;3;0;18;PING
    mysgw: Client 0: 0;0;3;0;18;PING
    mysgw: Client 0: 0;0;3;0;18;PING
    mysgw: Client 0: 0;0;3;0;18;PING
    mysgw: Client 0: 0;0;3;0;18;PING
    
    0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
    4 TSM:INIT
    4 TSF:WUR:MS=0
    12 TSM:INIT:TSP OK
    14 TSF:SID:OK,ID=1
    16 TSM:FPAR
    51 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    2060 !TSM:FPAR:NO REPLY
    2062 TSM:FPAR
    2099 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4106 !TSM:FPAR:NO REPLY
    4108 TSM:FPAR
    4145 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6152 !TSM:FPAR:NO REPLY
    6154 TSM:FPAR
    6191 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    8198 !TSM:FPAR:FAIL
    8200 TSM:FAIL:CNT=1
    8202 TSM:FAIL:PDT
    18206 TSM:FAIL:RE-INIT
    18208 TSM:INIT
    18214 TSM:INIT:TSP OK
    18219 TSF:SID:OK,ID=1
    18221 TSM:FPAR
    18257 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    20267 !TSM:FPAR:NO REPLY
    20269 TSM:FPAR
    20305 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    22315 !TSM:FPAR:NO REPLY
    22317 TSM:FPAR
    22353 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    24363 !TSM:FPAR:NO REPLY
    24365 TSM:FPAR
    24401 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    26411 !TSM:FPAR:FAIL
    26413 TSM:FAIL:CNT=2
    26415 TSM:FAIL:PDT
    36419 TSM:FAIL:RE-INIT
    36421 TSM:INIT
    36427 TSM:INIT:TSP OK
    36431 TSF:SID:OK,ID=1
    36433 TSM:FPAR
    36470 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    38479 !TSM:FPAR:NO REPLY
    38481 TSM:FPAR
    38518 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    40527 !TSM:FPAR:NO REPLY
    40529 TSM:FPAR
    40566 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    42575 !TSM:FPAR:NO REPLY
    42577 TSM:FPAR
    42614 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    44623 !TSM:FPAR:FAIL
    44625 TSM:FAIL:CNT=3
    

    You find the pinouts I send before are right to you?


  • Mod

    MY_* defines need to be before #include MySensors.h so you're doing the right thing.
    I don't know about the pins, have never used anything but the default wiring myself. But if the pins were wrong you should get TSM:INIT:TSP FAIL instead of TSM:INIT:TSP OK.

    If you reconfigure the first mysgw (the one with the default pins) to use channel 83, does communication with the node on channel 83 work?



  • @mfalkvidd yeah, look three posts before.
    I'll try to get mosi and miso from the default pin out sharing with the first radio. Now I'm using the ones marked as 1, when the default ones are marked 0.


  • Mod

    @Sergio-Rius I see. Sorry. Then we know the channel parameter works. Good testing.
    Strange problem. It looks from the threads I linked earlier that using the second SPI does indeed work (if the pin definition fix is applied). When the first mysgw is stopped, your second mysgw should behave just as it did for Velo17 and wergeld. Can you think of any difference in your setup?



  • @mfalkvidd I have the impression that if I stop the first service, the second picks the first radio.
    I disconnected the power from the first radio and left the second all connected and I only got TSM errors and fails. As soon as I attached power to the first NRF it worked.
    Perhaps the other users only used the configurable pins (CS/CE/IRQ) on the extended bank...



  • That's it. It doesn't use MOSI, MISO and SCLK from the SPI1. I removed the NRF1 and only connected those tree pins of NRF2 into SPI0 and service2 works with NRF2 at channel 125.

    I've tried to share those pins (MOSI, MISO, SCLK) between both radios but as soon as I connect NRF1, 2 stops communicating. Same effect than connecting NRF2 to SPI1.

    What a pity... #@%&!!! πŸ˜€

    Edit: I finally tried a more "standard" configuration. Using only the first SPI bank and also doesn't work.



  • Hi!
    I have a problem with the pseudo port. Node-serialport (v4.0.7) on the command serialport.list produces the result of the undefined.

    Rpi3 and DietPi, nodejs 4.8.4



  • @mfalkvidd OK have attached the logfiles below.
    No clues that I can see. At 1502 the NRF goes quiet. I have tried a different pi2, different NRF (PA/LNA) and am currently running the NRF off of 5V from the PI through one of those $1.00 regulator adapter things with built in caps and such. Have also tried different PSUs including a 2A one.
    Only thing I can think left to try is reducing the power output in case the high output of the radio module is inducing transients in the cables...
    Am kinda stumped here. I have an arduino NRF gateway that I will try via USB if low power does not work. I have tried setting up MYSGW as LAN and USB via ./configure but the same thing happens each time.
    One thought just came to me, I AM using the pin15 IRQ option on the NRF now that is still experimental?
    So next time will try without IRQ and low power...

    Any help/suggestions greatly appreciated.
    FYI I have had domoticz running on a lubuntu netbook with USB arduino NRF gateway that has been rock solid. Am trying the get a workable PI solution though, for myself and my father in law but not workable as yet sadly...

    At 15:02:34 you can see the last incoming node message after that the only MYSGW activity is the PING thing... which seems to happen every 10S or so. This goes on for an hour after that with no more incomings. I have ~12 sensors around the place including a power meter one which reports every minute.

    15:02:29 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613
    Aug  5 15:02:33 raspberrypi mysgw: TSF:MSG:READ,23-23-0,s=1,c=1,t=0,pt=7,l=5,sg=0:18.0
    Aug  5 15:02:33 raspberrypi mysgw: TSF:MSG:READ,23-23-0,s=0,c=1,t=1,pt=7,l=5,sg=0:21.0
    Aug  5 15:02:34 raspberrypi mysgw: TSF:MSG:READ,23-23-0,s=255,c=3,t=0,pt=1,l=1,sg=0:68
    Aug  5 15:02:34 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613
    Aug  5 15:02:36 raspberrypi mysgw: Client 0: 0;0;3;0;18;PING
    Aug  5 15:02:37 raspberrypi mysgw: TSF:MSG:READ,41-7-0,s=0,c=1,t=0,pt=7,l=5,sg=0:11.6
    Aug  5 15:02:41 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613
    Aug  5 15:02:46 raspberrypi mysgw: Client 0: 0;0;3;0;18;PING
    Aug  5 15:02:50 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613
    Aug  5 15:02:56 raspberrypi mysgw: Client 0: 0;0;3;0;18;PING
    Aug  5 15:02:57 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613
    Aug  5 15:03:06 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613
    Aug  5 15:03:06 raspberrypi mysgw: Client 0: 0;0;3;0;18;PING
    Aug  5 15:03:13 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613
    Aug  5 15:03:16 raspberrypi mysgw: Client 0: 0;0;3;0;18;PING
    

    Also FWIW to log from domoticz below. Ignore FANFLAG thats just a blockly flag I use...

    2017-08-05 15:01:18.936 (GW) General/Voltage (FanIntakeV)
    2017-08-05 15:02:04.935 (GW) General/kWh (Meter)
    2017-08-05 15:02:33.940 (GW) Temp + Humidity (Mitch2)
    2017-08-05 15:02:33.945 (GW) Temp + Humidity (Mitch2)
    2017-08-05 15:02:37.941 (GW) Temp (MBR Fan)
    2017-08-05 15:50:02.678 Set UserVariable FanFlag = 1
    2017-08-05 15:51:02.693 Set UserVariable FanFlag = 1
    2017-08-05 15:52:02.703 Set UserVariable FanFlag = 1
    2017-08-05 15:53:02.710 Set UserVariable FanFlag = 1
    2017-08-05 15:54:00.037 Set UserVariable FanFlag = 1
    

    Thanks,
    Matt


  • Mod

    @Matt I agree that power is the most likely cause. The nrf24 is very sensitive.

    Before you recompile, add --extra-cxxflags=-DMY_DEBUG_VERBOSE_RF24 to the configure command and you'll get extra details on the radio status in the gateway's debug log.



  • @mfalkvidd Thankyou. Stable for now. Not sure if they are even genuine modules so... Can reach outside to my glasshouse even on low power setting.
    If it starts playing up again I'll add verbose logging and have another look.



  • Anyone having issues with compilation of latest stable?

    Looks like missing libraries... fatal error: SPI.h: No such file or directory



  • Yesterday I've tried compiling it also (first time for me) and I had same error.


  • Mod

    @niehoff80 and/or @Oliviakrk can you run

    sudo raspi-config
    

    (install it using sudo apt-get install raspi-config if it isn't already installed)
    Select

    8 Advanced Options
    

    and

    A6 SPI
    

    and

    Yes
    

    to all questions. Reboot the raspberry pi and try running make again. If that works I'll add it to the documentation.



  • @mfalkvidd

    I was able to compile it after doing what you're suggesting. It's still have error message during communication with the gateway but that is probably a noobs-error in my config. so I have to investigate a bit more.



  • Hi

    I enabled SPI. For Rasberry PI B it was under 5. Interfacing options. The build completed successfully. Thanks!

    But there is a problem...When I run mysqgw -d I get:
    mysgw: Starting gateway...
    mysgw: Protocol version - 2.1.1
    mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.1
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: !TSM:INIT:TSP FAIL
    mysgw: TSM:FAIL:CNT=1
    mysgw: TSM:FAIL:PDT

    I also tried development release. Works perfectly. Looks like there is problem with stable.



  • Have the same problem with the stable branch as @Oliviakrk using the NRF24 transport on an Raspberry PI B, it might be a driver issue, is see that the make for the development branche builds the BCM drivers while the master branche does not.



  • Ok, I had same error as Oliviakrk & syotos on my Raspberry Pi 3 and I also tried the development release and that one works perfectly!



  • Hi I followed the instructions, but I can't get it to work, I have a Raspberry Pi 1 Rev1 with NRF24 connected following the instructions.
    First I configured it just using ./configure --spi-driver=SPIDEV --spi-spidev-device=/dev/spidev0.0 --soc=BCM2835 --my-transport=nrf24 --my-rf24-ce-pin=22 --my-rf24-cs-pin=24 --my-gateway=ethernet --my-port=5003
    I also tried with almost every combination but I always get the same errors.
    The idea is for it to be used as a standalone GW running from RPI with RF directly attached to it (SPI is enabled and I don't get any errors when compiling)
    I can send the logs if needed, any help will be welcome, thanks!
    pi@raspberrypi:~/MySensors $ sudo ./bin/mysgw -d
    mysgw: Starting gateway...
    mysgw: Protocol version - 2.1.1
    mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.1
    mysgw: TSF:LRT:OK
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: !TSM:INIT:TSP FAIL
    mysgw: TSM:FAIL:CNT=1
    mysgw: TSM:FAIL:PDT
    mysgw: TSM:FAIL:RE-INIT
    mysgw: TSM:INIT
    mysgw: !TSM:INIT:TSP FAIL
    mysgw: TSM:FAIL:CNT=2
    mysgw: TSM:FAIL:PDT


  • Mod

    Try latest mysensors version from development branch



  • Tried it and got the same output, I also tried with a different NRF24 just in case and doublechecked the connections. are the options I am using ok?
    ./configure --spi-driver=SPIDEV --spi-spidev-device=/dev/spidev0.0 --soc=BCM2835 --my-debug=enable --my-transport=nrf24 --my-rf24-ce-pin=22 --my-rf24-cs-pin=24 --my-gateway=ethernet --my-port=5003



  • @gohan, Thank you! I got it to work. First I tried with the development branch and it didn't work either, then I used the following instructions https://forum.mysensors.org/topic/1151/tutorial-raspberry-pi-nrf24l01-direct-connection
    And when that didn't work either I rechecked the wiring which ended up being the reason for it to fail previously, "faulty wires".
    I got it to work with the master branch.

    pi@raspberrypi:~/MySensors $ sudo ./bin/mysgw -d
    mysgw: Starting gateway...
    mysgw: Protocol version - 2.1.1
    mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.1
    mysgw: TSF:LRT:OK
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: TSM:INIT:TSP OK
    mysgw: TSM:INIT:GW MODE
    mysgw: TSM:READY:ID=0,PAR=0,DIS=0
    mysgw: MCO:REG:NOT NEEDED



  • Sorry, just want to ask does anyone have the output of this gateway?


  • Mod

    @Zuhairi the previous post?



  • Hi.
    I have a Raspberry Pi already configured as gateway, but I don't know how to interact with. I means, how can I read incoming data from? I tried open /dev/ttyMySensorsGateway as a common serial port but I got a message error:
    cu: open (/dev/ttyMySensorsGateway): Permission denied
    cu: /dev/ttyMySensorsGateway: Line in use
    With 'ps ax' command I can see only '/usr/local/sbin/PiGatewaySerial -d' running as a deamon.
    Could someone explain me what's ne next step for?


  • Mod

    I'd compile it as ethernet gateway, follow the guide on how to configure the parameters, then you can use MySController (search the forum, there is a topic with download link) and use that to connect to it


  • Mod

    Welcome to the MySensors community @Djames-Suhanko

    It looks like you are using the Raspberry Pi gateway for MySensors 1.5. If you are just starting out, I suggest you use the gateway for the current version instead. Documentation: https://www.mysensors.org/build/raspberry

    That version of the gateway has a debug mode where you can see the messages in the console.

    The next step would be to select a controller. Information about this is available at https://www.mysensors.org/about/network



  • @gohan Thank you to answer! Good tip, I will do that!



  • @mfalkvidd Yes, I'm using 1.5. Thank you for suggest me the newer version. I will update it today!



  • Hello, all!
    I read a lot of comments to find a solution to my problem, but seems it's something that I couldn't understand yet.

    The old version was working in my Raspberry Pi using Raspbian Wheeze, so, to install the new version i updated my system until the latest version (Raspbian Stetch). I could compile MySensors, but I'm getting the common error when testing with mysgw -d:
    "MYSGW: MCD:BGN INIT GW, CP=RNNG---,VER-2.1.1" and so on.

    I used this parameters in configure:
    ./configure --my-transport=nrf24 --my-gateway=ethernet
    --my-port=5003 --my-controlle-ip-address=192.168.1.2
    --my-gateway=mqtt --my-mqtt-publish-topic-prefix=mysensors-out
    --my-mqtt-subscribe-topic-prefix=mysensors-in
    --my-mqtt-client-id=mygateway1

    I couldn't find a solution yet. Can someone help me?


  • Mod

    @Djames-Suhanko MYSGW: MCD:BGN INIT GW, CP=RNNG---,VER-2.1.1 means that the gateway is starting up. It is not an error.

    "controller" is misspelled in your configure command though.


  • Mod

    @Djames-Suhanko I think you have to decide wether you want to make an ethernet or mqtt gateway, you can't specify both



  • wow, it's was really fast! Thanks to answer. I'm use an ethernet interface. It's up but have no cable on their. I didn't install a controller yet, so, is there no problem yet, right?
    Sorry that, I'm really a newbie using MySensors.

    [updating]
    ysgw: Starting gateway...
    mysgw: Protocol version - 2.1.1
    mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.1
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: !TSM:INIT:TSP FAIL
    mysgw: TSM:FAIL:CNT=1
    mysgw: TSM:FAIL:PDT
    mysgw: TSM:FAIL:RE-INIT
    mysgw: TSM:INIT
    mysgw: !TSM:INIT:TSP FAIL
    mysgw: TSM:FAIL:CNT=2
    mysgw: TSM:FAIL:PDT


  • Mod

    @Djames-Suhanko said in πŸ’¬ Building a Raspberry Pi Gateway:

    --my-controlle-ip-address

    this also is not necessary. Also for now remove all these --my-gateway=mqtt --my-mqtt-publish-topic-prefix=mysensors-out
    --my-mqtt-subscribe-topic-prefix=mysensors-in
    --my-mqtt-client-id=mygateway1
    and use it as ethernet gateway to keep it simple



  • Ok, I will try it right now!



  • Hello folks,
    my past experience is using nrf24 library at https://github.com/Blavery/lib_nrf24, and i was able to send/receive "text" data (or "string" data) in between Raspi3 (master node) and Arduino (slave). And this is a big issue, because what i need is numerical data (float or integer), not text data, so Raspi 3 can process the numerical data (such as to do the plotting), and based on the processed data to make some decisions. My raspi 3 is controlling a moving robot. Can you advise appropriate nrf24 library for raspberry pi and Arduino, and sample codes for this kind of applicaitons? Thanks


  • Mod

    Welcome to the MySensors community @erobot !

    Not sure how you found us, but the library we use here is...MySensors. It certanly does what you describe. The best way to start is to read how MySensors works at https://www.mysensors.org/about and then go on to the many build examples and build your first node.



  • hi there, somehow my gateway seems to stop receiving data after a day or so from my sensors,
    restarting the service seems to solve it for a time, how can i troubleshoot this issue ?



  • @Richard-van-der-Plas

    Same trouble for me. I use mySensors since 2 years and I have no problem with my Arduino Gateway. But from now 2 weeks, I try to use a pi gateway. It's working well but sometime, don't no why, my nrf24 stop to receive messages. Just restarting mygw service and re-work again. I don't see nothing anormal in my log, stop randomlly after 1 or 2 days.

    Maybe a power issue to nrf24, I will try to add capacitor just for testing if can resolve this problem.



  • Same here too. With Rpi3 gateway. Would stop for hours, maybe start agian for a hour or two and then stop.
    Have been running debug mode for last day, no idea what happened, but been stable so perhaps something in the update/upgrade made a problem and has now been fixed.
    Will keep an eye on here and let you know if I find anything.



  • Looks as if it happened after updating Home Assistant, but that should be 2 different things right ?


  • Mod

    @Richard-van-der-Plas what version are you using?



  • @gohan for me version dev (2.2)



  • dev 2.2.0 beta


  • Mod

    Have you tried both ethernet or mqtt?



  • @gohan the latest stable version i guess. Where can i check?


  • Mod

    @Richard-van-der-Plas try the 2.2 beta, it usually works better



  • @gohan just checked it's 2.1.1, is it easy to upgrade?


  • Mod

    @Richard-van-der-Plas just clone the 2.2 dev instead of the stable, the rest is the same



  • @gohan fatal: destination path 'MySensors' already exists and is not an empty directory. It goes wrong with the first command, could you please give me some pointers ?


  • Mod

    you need to either delete or rename the Mysensors folder πŸ™‚



  • Hello,
    I designed a PCB for rfm or nrf -> raspberry pi
    https://www.openhardware.io/view/470/MySensors-Gateway-for-Raspberry-PI


  • Mod

    I am trying to get the gateway to run the RFM69W radio but when I issue the "make" command I get this

    In file included from ./MySensors.h:318:0,
                     from examples_linux/mysgw.cpp:83:
    ./drivers/RFM69/new/RFM69_new.cpp:658:12: warning: β€˜void RFM69_ATCmode(bool, int16_t)’ defined but not used [-Wunused-function]
     LOCAL void RFM69_ATCmode(const bool onOff, const int16_t targetRSSI)
                ^
    

    It is latest beta.


  • Mod

    @gohan what configure command did you use? Knowing that would make it easier to reproduce the problem...
    Does this warning cause any problem?


  • Mod

    Just simple rfm69w 433 with default options. It compiles but I get no communication with nodes and 100% processor, but maybe I did a bad wiring


  • Mod

    @gohan debug output could be useful πŸ˜‰


  • Mod

    I would have posted it but it just shows as no nodes are trying to connect and nodes are unable to find a parent of course. I'm using the rfm2nrf pcb in order to have the pins to connect to the raspberry.

    PS here is the log of the startup

     __  __       ____
    |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.2.0-beta
    
    mysgw: MCO:BGN:INIT GW,CP=RPNG----,VER=2.2.0-beta
    mysgw: TSF:LRT:OK
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: TSM:INIT:TSP OK
    mysgw: TSM:INIT:GW MODE
    mysgw: TSM:READY:ID=0,PAR=0,DIS=0
    mysgw: MCO:REG:NOT NEEDED
    mysgw: Listening for connections on 0.0.0.0:5003
    mysgw: MCO:BGN:STP
    mysgw: MCO:BGN:INIT OK,TSP=1
    mysgw: New connection from 127.0.0.1
    mysgw: Client 0 connected
    mysgw: Client 0: 0;0;3;0;2;
    mysgw: Client 0: 0;0;3;0;2;Get Version
    mysgw: Client 0: 0;0;3;0;18;PING
    mysgw: Client 0: 0;0;3;0;18;PING
    

  • Mod

    On my test RPI3 it is working.... I have to double check the other one.



  • @gohan Hi there updated to the latest dev, but i still have to restart the service after a few days, this is the message in the log:

    Sep 17 20:31:51 raspberrypi hass[17999]: #033[32m2017-09-17 20:31:51 INFO (Thread-13) [mysensors.gateway_tcp] Closing socket at ('192.168.1.115', 5003).#033[0m
    Sep 17 20:31:51 raspberrypi hass[17999]: #033[32m2017-09-17 20:31:51 INFO (Thread-13) [mysensors.gateway_tcp] Socket closed at ('192.168.1.115', 5003).#033[0m
    Sep 17 20:31:51 raspberrypi hass[17999]: #033[32m2017-09-17 20:31:51 INFO (Thread-13) [mysensors.gateway_tcp] No response. Disconnected.#033[0m
    Sep 17 20:31:51 raspberrypi hass[17999]: #033[32m2017-09-17 20:31:51 INFO (Thread-13) [mysensors.gateway_tcp] Trying to connect to ('192.168.1.115', 5003)#033[0m
    

    checking with top, i see high CPU utilization:

    20921 root      20   0   20036    872    784 R  CPU ->99,5  0,1 682:53.59 mysgw
    
    


  • @ccy

    Hello, I'm also have issue with this question. My Raspberry Pi 2 type is a01041, but by the original "configure" file it is not recognized:

    [SECTION] Detecting target machine.
      [OK] machine detected: SoC=unknown, Type=unknown, CPU=armv7l.
    

    Maybe someone could explain why it is not recognized?

    "Configure" file lines:

    function detect_machine {
    ...
        case $hardware in
    ...
        BCM2835)
            soc="BCM2835"
            if [[ $machine == "Raspberry"* ]]; then
                local rev=($(detect_rpi_revision))
                if [[ $rev == "a02082" || $rev == "a22082" ]]; then
                    tp="RPi3"
                else
                    tp="Rpi2"
                fi
            fi
            ;;
    ...
    
    My Raspberry Pi 2 info:
    processor       : 0
    model name      : ARMv7 Processor rev 5 (v7l)
    BogoMIPS        : 38.40
    Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant     : 0x0
    CPU part        : 0xc07
    CPU revision    : 5
    
    processor       : 1
    model name      : ARMv7 Processor rev 5 (v7l)
    BogoMIPS        : 38.40
    Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant     : 0x0
    CPU part        : 0xc07
    CPU revision    : 5
    
    processor       : 2
    model name      : ARMv7 Processor rev 5 (v7l)
    BogoMIPS        : 38.40
    Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant     : 0x0
    CPU part        : 0xc07
    CPU revision    : 5
    
    processor       : 3
    model name      : ARMv7 Processor rev 5 (v7l)
    BogoMIPS        : 38.40
    Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant     : 0x0
    CPU part        : 0xc07
    CPU revision    : 5
    
    Hardware        : BCM2835
    Revision        : a01041
    Serial          : 0000000049a14619




  • I followed the instructions carefully. However I get an error. Can someone help?

    git clone https://github.com/mysensors/MySensors.git --branch master
    cd MySensors
    ./configure --my-transport=nrf24 --my-gateway=ethernet
    

    This results in a warning:

    [SECTION] Detecting SPI driver.
      [WARNING] No supported SPI driver detected.
    

    When I run make I get the follwing error:

    In file included from examples_linux/mysgw.cpp:74:0:
    ./MySensors.h:254:2: error: #error No support for nRF24 radio on this platform
     #error No support for nRF24 radio on this platform
      ^
    In file included from ./drivers/RF24/RF24.cpp:23:0,
                     from ./MySensors.h:290,
                     from examples_linux/mysgw.cpp:74:
    ./drivers/RF24/RF24.h:52:17: fatal error: SPI.h: No such file or directory
     #include <SPI.h>
                     ^
    compilation terminated.
    Makefile:114: recipe for target 'build/examples_linux/mysgw.o' failed
    make: *** [build/examples_linux/mysgw.o] Error 1
    

    Hope someone can help. Thanks.



  • Maybe you didn't enable SPI on the pi.

    From command prompt type 'sudo raspi-config', then select option 5 from the menu. This takes you to where you can enable the SPI bus on the pi. Then try again.

    S>



  • @skywatch Thank you! That solved my problem.



  • Hello friends,

    Reading the instructions for building a RaspberryPi Gateway using RFM69, it states that one should use the development branch and not master, since the Pi is using a different version of the driver.

    Anyone knows when this will be merged to master branch?

    Also, since this forces all nodes to use development branch as well to be able to communicate with the gateway, assuming I use the development branch now and it is later on merged into master, is there an easy way to upgrade nodes remotely to the new code?

    I am planning to use Wall Switch Insertable Node, and Mini Relay Mode - Both support OTA updates, am I correct to assume this will allow upgrading without taking the nodes out of where they are located?

    Thanks!
    Sefi


  • Mod

    Like all nodes, you need to change the bootloader in order to enable ota.



  • hello, is there a inclusion mode planned for the raspberry pi gateway ?



  • Hi,
    This seems a great job, but despite I had a look at many posts (yes, many out of the dozens of pages.. πŸ˜‰ ), I still can't figure out some questions..

    • Beyond the obvious advantage of saving an arduino (and power supply, space..), is there an advantage for having the gateway hosted by the raspberry PI hosting my Domoticz ? (like more CPU available for handling communications or for signing ? or on the opposite more risks to overload the PI CPU -despite only a couple persons have complained about high CPU load))
    • the default setup is Ethernet. What are the pros and cons of ethernet vs serial setup ? (speed? reliability ? possibility to move to other gateway?..)
    • Is signing now implemented in this setup ? I didn't see it explicitely described, but some posts seem related to signing.
    • if I want to use an external antenna and the high power NRF24, should I use an aother power source than raspberry PI ? (or maybe sharing the same USB charger, but diverting the power in parallel of the PI ?)
    • is there a tutorial somewhere detailing how to uninstall and migrate to an external gateway ? During such migration, would I need to "touch" again my sensors and would I lose history logs of these sensors in Domoticz ?

    Sorry for all these questions..

    br,
    Ricorico94


  • Mod

    @ricorico94 said in πŸ’¬ Building a Raspberry Pi Gateway:

    Hi,
    This seems a great job, but despite I had a look at many posts (yes, many out of the dozens of pages.. πŸ˜‰ ), I still can't figure out some questions..

    • Beyond the obvious advantage of saving an arduino (and power supply, space..), is there an advantage for having the gateway hosted by the raspberry PI hosting my Domoticz ? (like more CPU available for handling communications or for signing ? or on the opposite more risks to overload the PI CPU -despite only a couple persons have complained about high CPU load))

    Not really. Cpu usage is normally 0-2% so it doesn't affect either way.

    Switching between different gateway types (serial, ethernet, mqtt) can be easier since there is no need to re-wire anything, just reconfigure and recompile. But that could be done with a all-in-one Arduino setup as well.

    Remote debug might be a benefit, since logging in to the raspberry pi to view log files can be done remotely. Remote debug for Arduino is possible, but usually requires additional hardware.

    The raspberry pi has room for more logging, which can help troubleshooting.

    The biggest downside is that a raspberry pi environment is infinitely more complex than an Arduino, which could affect reliability and make troubleshooting harder. On the other hand, there are more debugging tools available which might make troubleshooting easier.

    • the default setup is Ethernet. What are the pros and cons of ethernet vs serial setup ? (speed? reliability ? possibility to move to other gateway?..)

    No difference in speed. No difference in reliability.

    Ethernet can easily be made accessible over the network. Doing that with serial can be done but is a bit tricky.

    Some controllers don't have support for all gateway types. See https://www.mysensors.org/controller for details.

    • Is signing now implemented in this setup ? I didn't see it explicitely described, but some posts seem related to signing.

    Yes. See the help text produced by running ./configure --help

    • if I want to use an external antenna and the high power NRF24, should I use an aother power source than raspberry PI ? (or maybe sharing the same USB charger, but diverting the power in parallel of the PI ?)

    Yes. See the note on https://www.mysensors.org/build/raspberry#wiring

    • is there a tutorial somewhere detailing how to uninstall and migrate to an external gateway ? During such migration, would I need to "touch" again my sensors and would I lose history logs of these sensors in Domoticz ?

    See my answer in the question you posted yesterday.

    Sorry for all these questions..

    No worries. Except for posting one of the questions again (which wastes people's time and confuses people when they read only one of the places), you are very welcome to post as many questions as you like. Asking questions is usually the next best way to learn.



  • Thanks a lot for your clear explanations ! Very useful !
    and.. bravo ! for all your work



  • Hi,
    I'm trying to install the gateway on a Raspberry Pi 2 hosting Domoticz already (I had used the standard Domoticz image).
    I receive an error message on the make step, but maybe I've not properly understood instructions (not very friendly with raspberry and linux environment).
    First, I wired the NRF24 with PA (meaning I used an adapter and the 5V physical PIN#4) and the IRQ (wired on physical pin #15)
    Then I logged into my raspberry and staid in initial directory (pi@raspberrypi )
    I then typed:

    pi@raspberrypi ~ $ git clone https://github.com/mysensors/MySensors.git --branch master
    Cloning into 'MySensors'...
    remote: Counting objects: 14895, done.
    remote: Compressing objects: 100% (8/8), done.
    remote: Total 14895 (delta 0), reused 5 (delta 0), pack-reused 14887
    Receiving objects: 100% (14895/14895), 12.17 MiB | 1.68 MiB/s, done.
    Resolving deltas: 100% (9022/9022), done.
    pi@raspberrypi ~ $ cd MySensors
    pi@raspberrypi ~/MySensors $ ./configure --help
    

    Hopefully I did it in adequate folder ? (now I see a Mysensors folder in my /home/pi folder).
    Then I typed:

    pi@raspberrypi ~/MySensors $ --my-transport=nrf24
    -bash: --my-transport=nrf24 : commande introuvable
    pi@raspberrypi ~/MySensors $ ./configure --my-transport=nrf24
    [SECTION] Detecting target machine.
      [OK] machine detected: SoC=BCM2836, Type=Rpi2, CPU=armv7l.
    [SECTION] Detecting SPI driver.
      [OK] SPI driver detected:BCM.
    [SECTION] Detecting init system.
      [OK] init system detected: sysvinit.
    [SECTION] Saving configuration.
    [SECTION] Cleaning previous builds.
    [OK] Finished.
    
    

    So far, no error.. but should I have typed "./configure --my-transport=nrf24 --my-rf24-irq-pin=15" to implement the IRQ ? If yes, can I retype that command with new settings without issue ?

    Then I understaood I had to run make command:

    pi@raspberrypi ~/MySensors $ make
    gcc -MT build/drivers/Linux/log.o -MMD -MP -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/RPi -I./drivers/BCM -c drivers/Linux/log.c -o build/drivers/Linux/log.o
    cc1: error: bad value (cortex-a7) for -mtune switch
    Makefile:118: recipe for target 'build/drivers/Linux/log.o' failed
    make: *** [build/drivers/Linux/log.o] Error 1
    
    

    But errors... 😧
    I tried to search on forum, and saw someone else meniotning a smilar error, but people were answering about OrangePI, whereas I use a Rasp PI 2.
    I probably misunderstood some steps.. Could someone help me ?

    Note: in instructions, there's a statement I don't understand for ethernet gateway: "To set the gateway as a client that connects to a controller, use:--my-gateway=ethernet --my-controller-url-address=YOUR-CONTROLLER-ADDRES" . IN which case do we need that ? (as said, I plan to simply use this gateway on My dodmoticz rasp PI).

    br,
    Ricorico94


  • Mod

    @ricorico94 said in πŸ’¬ Building a Raspberry Pi Gateway:

    ./configure --my-transport=nrf24 --my-rf24-irq-pin=15

    That is fine, no need to add extra parameters as by defaults it will configure as ethernet gateway. Also try using the development branch as it has lots of bugs fixed.



  • @ricorico94 Yesterday I managed to make a working rpi gateway. I am on rpi3, use a socket adapter board for the radio and use domoticz. I posted all the details here: https://forum.mysensors.org/topic/7793/nrf24l01-problems-in-2-1-1-and-2-2-0-beta/24



  • Hi,
    @arraWX : I looked at your post. Unfortunately, the error I face is before the start, as it's during the make, so it appears I follow the first steps you describe (config & make), but I still don't know how to solve the make errors.

    In case it can help understanding what's going on or what to do, I ran the command:

    gcc -v 
    

    which displayed: gcc version 4.6.3 (Debian 4.6.3-14+rpi1)
    Could it be an issue this "+rpi1" whreas I've a PI 2 ?



  • Do not know if it is of any help, but mine says: gcc version 4.9.2 (Raspbian 4.9.2-10)



  • Hi,
    I tried to update gcc, just in case.. though I'm not sure of what I do.πŸ˜•
    I ran:

    pi@raspberrypi ~/MySensors $ sudo apt-get upgrade gcc
    

    and after a little while, it ended without obvious mistake.
    but if I do gcc -v again, I still get
    gcc version 4.6.3 (Debian 4.6.3-14+rpi1)
    (even after reboot)
    Is there another step to be done, or am I using wrong command ?


  • Mod

    try running first sudo apt-get update and then sudo apt-get upgrade , it should update all packages



  • @gohan : JUst tried it, but same result.. no change on version number.
    is there something like apt-get install to be done also ?


  • Mod

    I don't know really... I am using dietpi on a RPI3 and there is a convenient tool that you can check what to install and installs for you and among the others I have chosen the "Build-Essentials" that contains all the common packages for compile, so I don't know what packages are included.


  • Code Contributor

    @ricorico94 Do you see gcc-4.9 in the list returned by the command below?

    sudo apt-cache search gcc
    

    If it's listed, try installing it by specifying the version:

    sudo apt-get install gcc-4.9
    


  • Hi, wouldn't be proper to include in the guide also the command "--my-rfm69-irq-pin=22" during the configure procedure in order to improve the throughput for the rfm69 radios?



  • Hi,
    Thanks to @marceloaqno and @Gohan and @arraWX , I could progress somewhow.. but still not working.

    When listing the versions as per Marceloagno advice, I could see gcc-4.6 and -4.7 and 4.8 but nothing else (no 4.9).
    I then decided to take the risk of installing the 4.8.. The commands from Marcelagno did not work (well, I mean gcc - v was still showing 4.6).
    Then I followed this tutorial on upgrade step by step to upgrade to gcc-4.8 and then the make command apparently succeeded (well, plenty messages, some warnings.. but no error apparently, as ar as I could see. I dd not find the folders desribed in website, but the commands were still ok.. weird, but I'm too rookie..)

    I then followed again the Mysensors tutorial with
    sudo ./bin/mysgw -h
    sudo ./bin/mysgw -d (and no error message. great!)
    sudo make install
    but then I ran
    sudo systemctl enable mysgw.service
    and I got error message

    sudo: systemctl: command not found
    

    After some search, I saw that it's a Jessie command whereas I discovered that my good old version of Rasp Pi, which was built from the standard Domoticz image in 2015 is still Wheezy

    pi@raspberrypi ~/MySensors $ cat /etc/os-release
    PRETTY_NAME="Raspbian GNU/Linux 7 (wheezy)"
    NAME="Raspbian GNU/Linux"
    VERSION_ID="7"
    VERSION="7 (wheezy)"
    ID=raspbian
    ID_LIKE=debian
    ANSI_COLOR="1;31"
    HOME_URL="http://www.raspbian.org/"
    SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
    BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
    

    Any idea of what I should do now?..
    another commande equivalent to the systemctl ?
    an upgrade to Jessie (any risk ? and how to do it safely ?)

    br,
    Ricorico94


  • Admin

    I am new to Linux and hopefully have an easy question...
    I have followed the build instructions and everything seems to be working well so far. One issue I'm having is getting node-red to see the usb port (/dev/ttyUSB020). I did some searching online and found that if I run the following command node-red will see the port and things start working.

    sudo chmod 666 /dev/ttyUSB020
    

    The problem is that each time I reboot the Pi the command needs to be run again. Does anyone have any ideas on how I can resolve this so I don't need to run the command each time the system is booted? Thanks in advance.


  • Mod

    @petewill you can put the chmod command in /etc/rc.local
    That will execute it on every boot.
    https://www.raspberrypi.org/documentation/linux/usage/rc-local.md


  • Mod

    @petewill or you can compile the gateway as ethernet or mqtt that are both supported by node-red, making life a little easier


  • Admin

    @mfalkvidd Thanks. I thought about doing something like that but I wasn't sure that was the best process or if something should be modified during the install. I'll give it a shot this way though. Thanks again.


  • Admin

    @gohan Sorry, I did not see your reply earlier. I tried an ethernet gateway in node-red a while ago and could never get it to work with Vera. There was some port conflicts or something. I have never played with mqtt. I need to learn it at some point but I am hoping to finish this project so I can move on to some others. πŸ™‚ Do you think I will gain significant advantages by using that over a serial/usb gateway?


  • Mod

    From a node-red perspective, IMHO, mqtt is easier to handle even without specific mysensors nodes, but it all depends what you need to do. I played with it some months ago but I got stuck when I had to start using javascript as I still don't know that language, but it was quite easy to link mysensors values to the dashboard without actually touching any code.


  • Admin

    @gohan Thanks! I seem to have the serial stuff working well (but haven't yet put it into production) so I think I'll go that way for now. I definitely need to look into mqtt at some point though.


  • Mod

    Ofc it has its PROs and CONs but I believe it is the way to go for the future.



  • I compiled the gateway for spi1 because I have a display using spi0. Two problems I came across:

    1. the master branch doesn't work. It compiles, it seems to work but it never receives anything.
    2. the development branch works but I needed to define the right cs-pin even if I redirected the pin in config.txt (with dtoverlay=spi1-1cs,cs0_pin=16)
      The following configure worked for me:
    ./configure --spi-driver=SPIDEV --spi-spidev-device=/dev/spidev1.0 --my-rf24-cs-pin=36 --my-rf24-ce-pin=33 --my-rf24-irq-pin=31
    


  • For the ones having problems with the stable build (Version 2.1.1), always getting "mysgw: !TSM:INIT:TSP FAIL":
    Seems there is a bug, you have to install "development" (Version 2.2.0)
    Maybe someone adds an note on top of the tutorial, so others wonΒ΄t also spend hours in searching for the problem on their Pi/Hardware.


  • Mod

    So far it looks to me it is something related to the latest versions of Linux since it was working on older releases



  • @gohan ah okay wasnΒ΄t aware of it, as the dev channel worked I assumed the bug at MySensors.
    However, would be awesome if there were a little hint in the tutorial. Took plenty of time to find out it was an software incompability πŸ˜‰



  • A little hint in the tutorial would have saved me a lot of time too.


  • Mod

    I added a comment; I hope my English is sufficiently clear πŸ˜„


Log in to reply
 

Suggested Topics

  • 3
  • 2
  • 110
  • 109
  • 584
  • 109

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts