Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Announcements
  3. 💬 Building a Raspberry Pi Gateway

💬 Building a Raspberry Pi Gateway

Scheduled Pinned Locked Moved Announcements
1.1k Posts 173 Posters 422.6k Views 131 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Velo17V Offline
    Velo17V Offline
    Velo17
    wrote on last edited by
    #552

    I just noticed that mysgw is constantly consuming 95-100% CPU here. This even happens when I unplug the NRF24 module so that after starting mysgw basically nothing happens. Running development branch. Hmmmm. Any idea what to check?

    mfalkviddM 1 Reply Last reply
    0
    • Velo17V Velo17

      I just noticed that mysgw is constantly consuming 95-100% CPU here. This even happens when I unplug the NRF24 module so that after starting mysgw basically nothing happens. Running development branch. Hmmmm. Any idea what to check?

      mfalkviddM Online
      mfalkviddM Online
      mfalkvidd
      Mod
      wrote on last edited by mfalkvidd
      #553

      @Velo17 strace might be able to help:

      sudo strace ./bin/mysgw -d
      

      Could you post your configure command? I'd like to try to reproduce the problem. I have a gateway with development from git as of about 2 weeks ago (a9418271) but I'm not using the nrf24. That gateway uses about 2% cpu on my Raspberry Pi 1. There have only been 6 commits since I built my gateway but I can update it and see if it starts acting up.

      On my gateway, strace outputs loads and loads of these:

      gettimeofday({1501098316, 668956}, NULL) = 0
      ioctl(6, FIONREAD, [0])                 = 0
      gettimeofday({1501098316, 671383}, NULL) = 0
      gettimeofday({1501098316, 672447}, NULL) = 0
      gettimeofday({1501098316, 673818}, NULL) = 0
      nanosleep({0, 10000000}, NULL)          = 0
      gettimeofday({1501098316, 685602}, NULL) = 0
      getsockopt(6, SOL_TCP, TCP_INFO, "\1\0\0\0\0\7g\1P4\3\0@\234\0\0\250\5\0\0\30\2\0\0\0\0\0\0\0\0\0\0"..., [104]) = 0
      getsockopt(6, SOL_TCP, TCP_INFO, "\1\0\0\0\0\7g\1P4\3\0@\234\0\0\250\5\0\0\30\2\0\0\0\0\0\0\0\0\0\0"..., [104]) = 0
      gettimeofday({1501098316, 689179}, NULL) = 0
      ioctl(6, FIONREAD, [0])                 = 0
      

      Also, which git hash are you using? (git log -1)

      Another thing to try could be to enable all the debug flags in MyConfig.h and see if they give you something interesting.

      1 Reply Last reply
      0
      • mfalkviddM Online
        mfalkviddM Online
        mfalkvidd
        Mod
        wrote on last edited by
        #554

        I updated my gateway to 10ef623 (latest from git). Still works ok.

        Velo17V 1 Reply Last reply
        0
        • mfalkviddM mfalkvidd

          I updated my gateway to 10ef623 (latest from git). Still works ok.

          Velo17V Offline
          Velo17V Offline
          Velo17
          wrote on last edited by
          #555

          @mfalkvidd I make / make install a couple of times and maybe did a git pull inbetween as well - now everything is back to normal again. Thank you for giving me some dbug tips for the next issue :-)

          My strace output looks similiar.

          My configure line is

          ./configure --my-rf24-channel=124 --my-rf24-irq-pin=29 --my-rf24-ce-pin=31 --my-rf24-cs-pin=36 --spi-driver=SPIDEV --spi-spidev-device=/dev/spidev1.0 --my-debug=disable
          
          1 Reply Last reply
          1
          • Sergio RiusS Offline
            Sergio RiusS Offline
            Sergio Rius
            wrote on last edited by
            #556

            Should be possible to connect two radio modules and run two instances at the same time?
            It could be interesting to have a hat with nrf+rfm, all in one.

            mfalkviddM 1 Reply Last reply
            0
            • Sergio RiusS Sergio Rius

              Should be possible to connect two radio modules and run two instances at the same time?
              It could be interesting to have a hat with nrf+rfm, all in one.

              mfalkviddM Online
              mfalkviddM Online
              mfalkvidd
              Mod
              wrote on last edited by mfalkvidd
              #557

              @Sergio-Rius it would be great if you could contribute to making that a reality.
              An earlier discussion on the same topic: https://forum.mysensors.org/topic/4151/nrf24l01-and-rfm69-on-one-gw/

              So far, people have found it easier to add a separate gateway for each transport.

              Sergio RiusS 1 Reply Last reply
              0
              • mfalkviddM mfalkvidd

                @Sergio-Rius it would be great if you could contribute to making that a reality.
                An earlier discussion on the same topic: https://forum.mysensors.org/topic/4151/nrf24l01-and-rfm69-on-one-gw/

                So far, people have found it easier to add a separate gateway for each transport.

                Sergio RiusS Offline
                Sergio RiusS Offline
                Sergio Rius
                wrote on last edited by Sergio Rius
                #558

                @mfalkvidd thanks for guiding me on the starting point. Perhaps the raspberry can break the doble transport limitation.
                I'll investigate in how to install two services at once. But it'll would be nice any advice on the device virtualization part.

                1 Reply Last reply
                0
                • mfalkviddM Online
                  mfalkviddM Online
                  mfalkvidd
                  Mod
                  wrote on last edited by
                  #559

                  Another thread: https://forum.mysensors.org/topic/2331/gateway-with-both-rfm69-and-nrf24l01/

                  1 Reply Last reply
                  0
                  • mfalkviddM Online
                    mfalkviddM Online
                    mfalkvidd
                    Mod
                    wrote on last edited by
                    #560

                    Maybe it could be as simple as running two instances of mysgw, using different pins for the nrf and the rfm?

                    Sergio RiusS 1 Reply Last reply
                    0
                    • mfalkviddM mfalkvidd

                      Maybe it could be as simple as running two instances of mysgw, using different pins for the nrf and the rfm?

                      Sergio RiusS Offline
                      Sergio RiusS Offline
                      Sergio Rius
                      wrote on last edited by Sergio Rius
                      #561

                      @mfalkvidd Maybe. I'm programmer, but not for Linux. My concern is the part of the service that creates the virtual device colliding between the instances.
                      I'll do a test in a virtual machine as soon as I have some time.
                      It should be something easy to test.

                      mfalkviddM 1 Reply Last reply
                      0
                      • Sergio RiusS Sergio Rius

                        @mfalkvidd Maybe. I'm programmer, but not for Linux. My concern is the part of the service that creates the virtual device colliding between the instances.
                        I'll do a test in a virtual machine as soon as I have some time.
                        It should be something easy to test.

                        mfalkviddM Online
                        mfalkviddM Online
                        mfalkvidd
                        Mod
                        wrote on last edited by
                        #562

                        @Sergio-Rius by "virtual device", do you mean the com port? If that's the caee, it can be specified with --my-serial-pty=

                        Ot let one gateway be serial and the other ethernet.

                        Sergio RiusS 1 Reply Last reply
                        0
                        • mfalkviddM mfalkvidd

                          @Sergio-Rius by "virtual device", do you mean the com port? If that's the caee, it can be specified with --my-serial-pty=

                          Ot let one gateway be serial and the other ethernet.

                          Sergio RiusS Offline
                          Sergio RiusS Offline
                          Sergio Rius
                          wrote on last edited by
                          #563

                          @mfalkvidd yes. Should work. I admit I've not taken a look at the code nor I don't know how to install the service two times.
                          I'm used to having problems with programs that use static resources allocation. But I don't know if that's the case.

                          1 Reply Last reply
                          0
                          • gohanG Offline
                            gohanG Offline
                            gohan
                            Mod
                            wrote on last edited by
                            #564

                            maybe you could also consider making 2 ethernet gateway one on port 5003 and the other on port 5004 so that you can use myscontroller to debug from remote.

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              Matt
                              wrote on last edited by
                              #565

                              Hi guys couple of questions, apologies if they have been covered elsewhere.
                              I am running latest dev branches of domoticz and MYS on a pi2.
                              At random times it seems the NRF24L01+ LNA/PA goes down, or MYS goes down and domotics stops receiving signals from all of the nodes at the same time. I have the interrupt feature enabled.
                              I have set the option under domoticz/hardware/data timeout to restart if no data received in five minutes but I dont think this is an ideal solution, and have yet to find out if this domoticz feature actually works in my scenario.
                              Any idea what causes this? I found an old thread over on the domoticz/mysensors forum but no answers there. I am using a new sd card class 10.
                              What I want to do is try out the different MYS builds on domoticz ie MQTT and SERIAL as well as ethernet which I am currently running. However I'm not sure how to stop the current MYS service and completely clean up the current build to start from scratch... I have tried just re entering the ./configure commands then 'make' but this does not seem to work.
                              Many thanks,
                              Matt

                              mfalkviddM 1 Reply Last reply
                              0
                              • M Matt

                                Hi guys couple of questions, apologies if they have been covered elsewhere.
                                I am running latest dev branches of domoticz and MYS on a pi2.
                                At random times it seems the NRF24L01+ LNA/PA goes down, or MYS goes down and domotics stops receiving signals from all of the nodes at the same time. I have the interrupt feature enabled.
                                I have set the option under domoticz/hardware/data timeout to restart if no data received in five minutes but I dont think this is an ideal solution, and have yet to find out if this domoticz feature actually works in my scenario.
                                Any idea what causes this? I found an old thread over on the domoticz/mysensors forum but no answers there. I am using a new sd card class 10.
                                What I want to do is try out the different MYS builds on domoticz ie MQTT and SERIAL as well as ethernet which I am currently running. However I'm not sure how to stop the current MYS service and completely clean up the current build to start from scratch... I have tried just re entering the ./configure commands then 'make' but this does not seem to work.
                                Many thanks,
                                Matt

                                mfalkviddM Online
                                mfalkviddM Online
                                mfalkvidd
                                Mod
                                wrote on last edited by mfalkvidd
                                #566

                                @Matt log files for the time where the problem occurred will be essential for troubleshooting.

                                make uninstall will stop the service and uninstall
                                make cleanconfig will remove previous ./configure settings
                                make clean will remove compiled code

                                M 2 Replies Last reply
                                0
                                • C ccy

                                  @Grubstake: Thanks. I have tried to follow "NRF24L01+ Radio" pin out connection. I have double / triple check my wiring is correct. But I still get the same fail message in mysgw debug mode:

                                  [root@alarmpi bin]# ./mysgw -d
                                  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
                                  mysgw: TSM:FAIL:RE-INIT
                                  mysgw: TSM:INIT
                                  mysgw: !TSM:INIT:TSP FAIL
                                  mysgw: TSM:FAIL:CNT=2
                                  mysgw: TSM:FAIL:PDT
                                  mysgw: TSM:FAIL:RE-INIT
                                  mysgw: TSM:INIT
                                  mysgw: !TSM:INIT:TSP FAIL
                                  mysgw: TSM:FAIL:CNT=3
                                  mysgw: TSM:FAIL:PDT
                                  mysgw: Received SIGINT
                                  

                                  Here is my /boot/config.txt:

                                  gpu_mem=64
                                  initramfs initramfs-linux.img followkernel
                                  dtparam=spi=on
                                  

                                  and the spi dev:

                                  # ls /dev/spidev0.*
                                  /dev/spidev0.0  /dev/spidev0.1
                                  

                                  I am using ArchLinuxARM:

                                  # uname -a
                                  Linux alarmpi 4.9.13-3-ARCH #1 SMP Fri Mar 3 18:45:16 MST 2017 armv7l GNU/Linux
                                  

                                  I only wiring 7 pins (1-7) on NRF24l01+.

                                  Raspberry Pi 2 hardware information:

                                  # cat /proc/cpuinfo
                                  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        : a21041
                                  Serial          : 00000000475d18a4
                                  
                                  # cat /sys/firmware/devicetree/base/model
                                  Raspberry Pi 2 Model B Rev 1.1
                                  

                                  Output from MySensors configure:

                                  # ./configure
                                  [SECTION] Detecting target machine.
                                  ./configure: line 111: warning: command substitution: ignored null byte in input
                                    [OK] machine detected: SoC=unknown, Type=unknown, CPU=armv7l.
                                  [SECTION] Checking GPIO Sysfs.
                                    [OK] /sys/class/gpio/export found
                                  [SECTION] Detecting SPI driver.
                                    [OK] SPI driver detected:SPIDEV.
                                  [SECTION] Detecting init system.
                                    [OK] init system detected: systemd.
                                  [SECTION] Saving configuration.
                                  [SECTION] Cleaning previous builds.
                                  [OK] Finished.
                                  

                                  I finally find out my raspberry pi board isn't detected properly in configure. I change the function detect_machine:

                                  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
                                          ;;
                                  ...
                                  

                                  make mysgw again, and I get this finally:

                                  # ./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
                                  mysgw: Listening for connections on 0.0.0.0:5003
                                  mysgw: MCO:BGN:STP
                                  mysgw: MCO:BGN:INIT OK,TSP=1
                                  
                                  enloE Offline
                                  enloE Offline
                                  enlo
                                  wrote on last edited by
                                  #567

                                  @ccy that correction to the detect_machine function was necessary on my Rpi 3 too (I took the latest version from master). I got it working with that addition.
                                  Soooo I guess that would be worth adding to the code / opening an issue on github, wouldn't it?

                                  1 Reply Last reply
                                  0
                                  • Sergio RiusS Offline
                                    Sergio RiusS Offline
                                    Sergio Rius
                                    wrote on last edited by
                                    #568

                                    I'm just now testing the two instances installation. I was going to just alter the flag --prefix but now I see in options that there's also the install dir:

                                    Installation options:
                                        --prefix=<PREFIX>           Installation prefix path. [/usr/local]
                                        --gateway-dir=<DIR>         Gateway files installation directory. [PREFIX/bin]
                                    

                                    What do you think should be the preferred way for installing two instances, only changing --gateway-dir?

                                    1 Reply Last reply
                                    0
                                    • mfalkviddM mfalkvidd

                                      @Matt log files for the time where the problem occurred will be essential for troubleshooting.

                                      make uninstall will stop the service and uninstall
                                      make cleanconfig will remove previous ./configure settings
                                      make clean will remove compiled code

                                      M Offline
                                      M Offline
                                      Matt
                                      wrote on last edited by
                                      #569

                                      @mfalkvidd OK thanks for your reply.
                                      Have set up the -d parameter in mysgw.servie and am waiting for it to fall over again.
                                      If I catch it I will post syslog.
                                      Thanks,
                                      Matt

                                      1 Reply Last reply
                                      1
                                      • Sergio RiusS Offline
                                        Sergio RiusS Offline
                                        Sergio Rius
                                        wrote on last edited by Sergio Rius
                                        #570

                                        Seems that I'll need some help for getting this properly done.
                                        I can't launch two instances of the service.

                                        What I've done is following the guide instructions with the following configuration:

                                        ./configure \
                                         --my-transport=nrf24 \
                                         --my-rf24-irq-pin=18 \
                                         --my-gateway=ethernet --my-port=5003 \
                                         --prefix=/opt/mysgw-nrf
                                        

                                        Then manually executed it, and it run ok and get one test node connected and Domoticz saw it all.

                                        Then I duplicated the MySensors folder and in there made the build with the following configuration:

                                        ./configure \
                                         --my-transport=nrf24 \
                                         --my-rf24-channel=82 \
                                         --my-rf24-ce-pin=37 \
                                         --my-rf24-cs-pin=36 \
                                         --my-rf24-irq-pin=33 \
                                         --my-gateway=ethernet --my-port=5004 \
                                         --prefix=/opt/mysgw-rfm
                                        

                                        Even when it says rfm, i connected a second NRF with the following pinout (blue=first NRF, green=second):
                                        0_1501511919817_Pinouts.png
                                        *IRQ on pin 33 as config says, and power from 1.

                                        Then I tried to make and run and I get this output:

                                        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: pinMode: invalid pin: 33
                                        mysgw: pinMode: invalid pin: 37
                                        mysgw: pinMode: invalid pin: 36
                                        mysgw: digitalWrite: invalid pin: 37
                                        mysgw: digitalWrite: invalid pin: 36
                                        mysgw: You need root privilege to use SPI.
                                        

                                        Is that I have to connect MOSI and MISO to the same pins that the first NRF?

                                        mfalkviddM 1 Reply Last reply
                                        0
                                        • Sergio RiusS Sergio Rius

                                          Seems that I'll need some help for getting this properly done.
                                          I can't launch two instances of the service.

                                          What I've done is following the guide instructions with the following configuration:

                                          ./configure \
                                           --my-transport=nrf24 \
                                           --my-rf24-irq-pin=18 \
                                           --my-gateway=ethernet --my-port=5003 \
                                           --prefix=/opt/mysgw-nrf
                                          

                                          Then manually executed it, and it run ok and get one test node connected and Domoticz saw it all.

                                          Then I duplicated the MySensors folder and in there made the build with the following configuration:

                                          ./configure \
                                           --my-transport=nrf24 \
                                           --my-rf24-channel=82 \
                                           --my-rf24-ce-pin=37 \
                                           --my-rf24-cs-pin=36 \
                                           --my-rf24-irq-pin=33 \
                                           --my-gateway=ethernet --my-port=5004 \
                                           --prefix=/opt/mysgw-rfm
                                          

                                          Even when it says rfm, i connected a second NRF with the following pinout (blue=first NRF, green=second):
                                          0_1501511919817_Pinouts.png
                                          *IRQ on pin 33 as config says, and power from 1.

                                          Then I tried to make and run and I get this output:

                                          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: pinMode: invalid pin: 33
                                          mysgw: pinMode: invalid pin: 37
                                          mysgw: pinMode: invalid pin: 36
                                          mysgw: digitalWrite: invalid pin: 37
                                          mysgw: digitalWrite: invalid pin: 36
                                          mysgw: You need root privilege to use SPI.
                                          

                                          Is that I have to connect MOSI and MISO to the same pins that the first NRF?

                                          mfalkviddM Online
                                          mfalkviddM Online
                                          mfalkvidd
                                          Mod
                                          wrote on last edited by
                                          #571

                                          @Sergio-Rius see https://forum.mysensors.org/post/72145 and https://github.com/mysensors/MySensors/issues/895

                                          Sergio RiusS 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          17

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular