💬 Building a Raspberry Pi Gateway


  • Code Contributor

    I forgot to mention in the guide:
    To communicate with the RPi using the RFM69 radio, all of your nodes need to use the new RFM69 driver available in the development branch.
    To make the change, add the following line to the node sketch:

    #define MY_RFM69_NEW_DRIVER
    

  • Mod

    @marceloaqno you forgot just a little little insignificant detail 😂


  • Code Contributor

    @gohan @ftw64 sorry for all the trouble


  • Mod

    It's OK, don't worry. We need to update the guide with the new instructions 😀


  • Code Contributor

    @gohan Done!



  • @marceloaqno Thanks! That indeed does the trick! And no worries, it is my own decision to play with beta(!) code (and it was a fun weekend troubleshooting it - I learned a lot about the structure of the MySensors code)!

    Only 'bad' thing is that 2.2.0 is not compatible with my existing nodes :-).

    I appreciate all the work that has been put into MySensors.



  • This is really stupid. 😄 RFM69 radio need powered separately ?


  • Mod

    They shouldn't, but it's always a matter trying 😀



  • This post is deleted!


  • How will this work with HASS running on the same pi ?


  • Mod

    It's the same as it was running on separate hw, you will only set ip address of the gateway in hass



  • so i can attach the NRF24L01+ to the pi running HA, make it a Ethernet Gateway and point to his own ip adress ?, will this be a long job with converting from a USB connected GW (Arduino with local sensors ? )


  • Mod

    That's pretty much it. I don't know what is your current setup and what sensors you have, but is should not be a long job. Anyway you can install the ethernet gateway and when you are done you take care of the sensors



  • excellent, will the cpu utilisation be much higher that with a usb connected gw ?


  • Mod

    No, it uses very few cpu



  • @Richard van der Plas: I strongly recommend to use MQTT instead of Ethernet gateway, as it is a standard way for 2 processes to communicate, and platform-agnostic.
    HASS comes with an embed MQTT broker taht works out of the box.
    Plus:

    • you can easily mock either your sensors network or your controller
    • it does support secure communication
    • you can add other clients to observe the event, e.g. to log what is coming from/what is sent to the gateway

  • Mod

    I suggested ethernet because it's easier to setup and configure, mqtt is the next step.



  • Hi
    I also have problem to get the NRF24L01+ chip to work with the RPi3.

    I find that the masterbranch don't recognize the board as RPi3 and sets SoC and Type as unknown.
    But if i take development branch it´s detecting RPi3 and seems to work correct.

    This is result from development Branch configure:
    [SECTION] Detecting target machine.
    [OK] machine detected: SoC=BCM2837, Type=rpi3, CPU=armv7l.
    [SECTION] Detecting SPI driver.
    [OK] SPI driver detected:BCM.
    [SECTION] Detecting init system.
    [OK] init system detected: systemd.
    [SECTION] Saving configuration.
    [SECTION] Cleaning previous builds.
    [OK] Finished.

    This is result from Master Branch configure:
    [SECTION] Detecting target machine.
    [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.

    This is the result from cat /proc/cpuinfo:

    Hardware : BCM2835
    Revision : a02082

    //Peter


  • Mod

    That's odd, I have the 2.1.1 compiled on mine rpi 3


  • Code Contributor

    @pettib @gohan There have been some changes in /proc/cpuinfo in newer versions of kernels which leads to a wrong detection.
    The problem was fix in #827 and will be available in the master branch in the next mysensor release.


  • Mod

    I'm using dietpi and I compiled it like 2 weeks ago..



  • @Richard-van-der-Plas what is this: HASS ?



  • Ok, i am standig on a crossroad it seems, i have to build a new gateway but i am also interested in the MQTT option, this is between mysensors & HomeASSistant i presume? i have some ESP's lying around unused, but i have 0 knowledge of mqtt (i dont think my hass has it running by default)


  • Mod

    Just go with ethernet first that is easier, get used to it then take your time to learn MQTT. Of course MQTT is more advanced has authentication and encryption but it adds complexity to initial setup.



  • Damn, just connected as in manual, but gives an error : mysgw: !TSM:INIT:TSP FAIL
    Double checked the GPIO pins (except 15 cannot find that one) but seems ok



  • NM, used GPIO numbers instead of Pin numbers RTFM 🙂



  • I always have a mysgw: accept: Bad file descriptor error when I launch a new ./bin/mysgw -d Exact problem is the following:

    mysgw: bind: Address already in use
    mysgw: Failed to bind!
    

    And I always need to kill the process first. Is this normal ? (I'm in LAN GW)

    Thanks!


  • Mod

    If you already installed mysgw as service to start at boot, it is normal that you can not run another process in debug mode and it conflicts



  • @gohan said in 💬 Building a Raspberry Pi Gateway:

    lready installed mysgw as service to start at boot, it is normal that you can not run another process in debug mode and it conflicts

    Oh, Ok. Thanks.
    Another thing is that when i close PuTTY, the gateway doesn't retrieve anymore the data...


  • Mod

    You need to install it as service so it always runs in background



  • Is it this process :

    1421 ?        Rs    40:25 /usr/local/bin/mysgw
    

    Seems it runs for 40 minutes, but no the gateway sees no data...


  • Mod

    what gateway did you compile? What option in ./configure did you use?



  • First of all : thanks for helping !

    I compiled an Ethernet gateway
    The options are the following:

    ./configure --my-gateway=ethernet --my-port=5003 --my-rf24-irq-pin=15 --my-transport=nrf24
    

    The only way I make the GW working is through the debug mode (by switching off the service process)



  • Hello, it seems I found the problem: Complete newbie thing: 🔰
    sudo ./bin/mysgw -h worked, but /usr/local/bin/mysgw didn't
    I just gave the right to the folder, and now it's working.
    Thanks for taking time to help beginners !



  • @Richard van der Plas : i was have the same error with my raspberry zero. I have succed with the devellopement branch version...



  • Trying to setup a Rpi1, as i got one lying around here.

    All work untill i want to 'make'

    Generates an error:

    pi@mysgw:~/MySensors $ ./configure --my-gateway=ethernet --my-port=5003 --my-transport=nrf24 --my-rf24-irq-pin=15
    [SECTION] Detecting target machine.
      [OK] machine detected: SoC=BCM2835, Type=rpi1, CPU=armv6l.
    [SECTION] Detecting SPI driver.
      [OK] SPI driver detected:BCM.
    [SECTION] Detecting init system.
      [OK] init system detected: systemd.
    [SECTION] Saving configuration.
    [SECTION] Cleaning previous builds.
    [OK] Finished.
    pi@mysgw:~/MySensors $ make
    gcc -MT build/drivers/Linux/log.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/log.c -o build/drivers/Linux/log.o
    g++ -MT build/drivers/Linux/noniso.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/noniso.cpp -o build/drivers/Linux/noniso.o
    g++ -MT build/drivers/Linux/GPIO.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/GPIO.cpp -o build/drivers/Linux/GPIO.o
    g++ -MT build/drivers/Linux/SPIDEV.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/SPIDEV.cpp -o build/drivers/Linux/SPIDEV.o
    g++ -MT build/drivers/Linux/Print.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/Print.cpp -o build/drivers/Linux/Print.o
    g++ -MT build/drivers/Linux/EthernetClient.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/EthernetClient.cpp -o build/drivers/Linux/EthernetClient.o
    g++ -MT build/drivers/Linux/compatibility.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/compatibility.cpp -o build/drivers/Linux/compatibility.o
    g++ -MT build/drivers/Linux/SerialPort.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/SerialPort.cpp -o build/drivers/Linux/SerialPort.o
    g++ -MT build/drivers/Linux/Stream.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/Stream.cpp -o build/drivers/Linux/Stream.o
    g++ -MT build/drivers/Linux/IPAddress.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/IPAddress.cpp -o build/drivers/Linux/IPAddress.o
    g++ -MT build/drivers/Linux/interrupt.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/interrupt.cpp -o build/drivers/Linux/interrupt.o
    g++ -MT build/drivers/Linux/SerialSimulator.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/SerialSimulator.cpp -o build/drivers/Linux/SerialSimulator.o
    g++ -MT build/drivers/Linux/SoftEeprom.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/SoftEeprom.cpp -o build/drivers/Linux/SoftEeprom.o
    g++ -MT build/drivers/Linux/EthernetServer.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/Linux/EthernetServer.cpp -o build/drivers/Linux/EthernetServer.o
    g++ -MT build/examples_linux/mysgw.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DRPI_TYPE=\"rpi1\" -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15 -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c examples_linux/mysgw.cpp -o build/examples_linux/mysgw.o
    In file included from ./MySensors.h:109:0,
                     from examples_linux/mysgw.cpp:83:
    ./hal/architecture/MyHwLinuxGeneric.cpp: In function ‘ssize_t hwGetentropy(void*, size_t)’:
    ./hal/architecture/MyHwLinuxGeneric.cpp:79:17: error: ‘SYS_getrandom’ was not declared in this scope
      return syscall(SYS_getrandom, __buffer, __length, GRND_NONBLOCK);
                     ^
    ./hal/architecture/MyHwLinuxGeneric.cpp:79:52: error: ‘GRND_NONBLOCK’ was not declared in this scope
      return syscall(SYS_getrandom, __buffer, __length, GRND_NONBLOCK);
                                                        ^
    ./hal/architecture/MyHwLinuxGeneric.cpp:80:1: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
    Makefile:98: recipe for target 'build/examples_linux/mysgw.o' failed
    make: *** [build/examples_linux/mysgw.o] Error 1
    pi@mysgw:~/MySensors $
    

    Has this to do with a limitation of Rpi being v1?

    Regards

    Gerwin


  • Code Contributor

    @gdekeijzer There was a recent update on the random number generator for the RPi port, but unfortunately not all linux versions support the new method. @d00616 is working on a solution to this problem #856. Please use the master branch for the time being.



  • Ah great. Thanx for the response. I'll go try that for now.



  • Installed master branche. That did the job. Thanx.



  • Hello, did anyone tried gateway on pi with RS485 wired network ? It looks like node with ID set is looking for parrent and gateway does not respond to the node and therefore there is no succesfull presentation.
    example from GW mysgw:

    TSF:MSG:SEND,0-0-5-5,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    mysgw: TSF:MSG:READ,5-5-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    mysgw: TSF:MSG:BC
    mysgw: TSF:MSG:FPAR REQ,ID=5
    mysgw: TSF:PNG:SEND,TO=0
    mysgw: TSF:CKU:OK
    mysgw: TSF:MSG:GWL OK
    mysgw: TSF:MSG:SEND,0-0-5-5,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    mysgw: TSF:MSG:READ,5-5-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    mysgw: TSF:MSG:BC
    mysgw: TSF:MSG:FPAR REQ,ID=5
    mysgw: TSF:CKU:OK,FCTRL
    mysgw: TSF:MSG:GWL OK
    mysgw: TSF:MSG:SEND,0-0-5-5,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    mysgw: TSF:MSG:READ,5-5-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    mysgw: TSF:MSG:BC
    mysgw: TSF:MSG:FPAR REQ,ID=5
    mysgw: TSF:CKU:OK,FCTRL
    mysgw: TSF:MSG:GWL OK
    mysgw: TSF:MSG:SEND,0-0-5-5,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    mysgw: TSF:MSG:READ,5-5-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    mysgw: TSF:MSG:BC
    mysgw: TSF:MSG:FPAR REQ,ID=5
    mysgw: TSF:CKU:OK,FCTRL
    mysgw: TSF:MSG:GWL OK
    mysgw: TSF:MSG:SEND,0-0-5-5,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    

    and from node :

    0 MCO:BGN:INIT NODE,CP=RSNNA--,VER=2.1.1
    3 TSM:INIT
    4 TSF:WUR:MS=0
    5 TSM:INIT:TSP OK
    7 TSM:INIT:STATID=5
    9 TSF:SID:OK,ID=5
    10 TSM:FPAR
    27 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    2035 !TSM:FPAR:NO REPLY
    2037 TSM:FPAR
    2055 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4063 !TSM:FPAR:NO REPLY
    4065 TSM:FPAR
    4082 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6090 !TSM:FPAR:NO REPLY
    6092 TSM:FPAR
    6110 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    8118 !TSM:FPAR:FAIL
    8119 TSM:FAIL:CNT=1
    


  • @Luc3as Okay, Again I found answer while after asking, I used dev branch of mysensors and it is working like a charm.



  • I am a novice, trying to get the raspberry pi gateway to work. I did get it to work on one pi, but while installing it on the second, it produces the following 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>

    I can see that the SPI.h library is among the files downloaded.

    Any ideas?

    Paul


  • Mod

    what raspberry version is that? What library version did you download?



  • do you have SPI enabled through raspi-config ?



  • @gohan Thanks for the response. I downloaded the MySensors Library 2.1.1. Sorting through it I can see that SPI.h is included.

    I installed a complete system in FL (I'm retired and a snowbird). Included are a Bunch of Arduino sensors, a Foscam Camera and Wemo switches. So I used a lot of material from MySensors to get the Arduino sensors up and running (great stuff: thanks to all those folks who created it). I then created a Raspberry Wireless (RF24) Gateway and installed Mosquitto to communicate with HomeAssistant. Took a while to configure HA, and I'm still learning.

    I do not recall having a problem with the SPI library when assembling all this stuff. Upon return to Boston, I have made a number of improvements talking to the Raspberry in FL through TeamViewer (a great app). However, along the way, I corrupted the system in FL. It now limps. So, I started recreating the stuff in FL on a new SD card, encountering the SPI problem.

    Since sending out my request for help, I found a backup version of my FL system on an SD card. Looking at it, the system seems to be whole and boots with no issues. mysgw works fine on it. So, I've added all my new stuff to this SD card and have tested it to make sure its working. Things are looking good and so, my immediate problem is solved (circumvented).

    I still want to know what I am doing wrong with the gateway. I've learned a little bit of Python along the way. There, one installs a library. I know effectively nothing about C++. So, I've done nothing to install the library, only followed the instructions on the MySensors Raspberry Pi Gateway page.

    BTW, this stuff is great.

    Paul



  • @Luc3as Thanks for your response. No, in fact it was not enabled. Please read my reply to gohan. As you see, I've cheated my way out of this problem. In the process, I've lost track of the SD card on which I encountered this problem. Nonetheless, I will circle back to test your suggestion.


  • Mod

    Try to enable the SPI first. Then you could also try different linux distributions and see which one you like better ( I personally like dietpi more than the others ). You may also want to try to use Mysensors library from development branch that is now 2.2.0.
    I now have a dietpi + mysensors 2.2.0 + nrf24 and all running fine



  • @marceloaqno said in 💬 Building a Raspberry Pi Gateway:

    @Roberto-Mo-Ca If you are using the nrf24 PA/LNA version you need to use a 5V->3.3V regulator otherwise you can connect to the 3.3v pin.

    But why do we need to convert down from 5v to 3.3v? The pi does supply 3.3 on some pins.. Is this because the PA/LNA uses more mA?


  • Mod

    yes, the 3.3v can't supply enough current. I am using some small adapters that have the AMS1117 and some capacitors that allow for a quick swap of radio modules when you need test them



  • @gohan said in 💬 Building a Raspberry Pi Gateway:

    yes, the 3.3v can't supply enough current. I am using some small adapters that have the AMS1117 and some capacitors that allow for a quick swap of radio modules when you need test them

    Ok. Maybe this should be mentioned in the documentation page.


  • Mod

    @subutux could you explain where you would expect to find that note?


  • Mod

    (obviously not here)
    0_1496838882911_image.png


  • Mod

    @subutux it is mentioned as stated above that you need it, it is just skipping all the info that are in datasheets and are not stricly necessary to make the gateway



  • @gohan said in 💬 Building a Raspberry Pi Gateway:

    @subutux it is mentioned as stated above that you need it, it is just skipping all the info that are in datasheets and are not stricly necessary to make the gateway

    Well, I for one would like to know why we need to step-down from 5v to 3.3v. Just a simple statement that the LNA version requires more power that only the 5v can deliver on the pi.
    @mfalkvidd Yeah I would mention it there. It mentions to use a regulator but not why.. I've read that line & was like, why? That's when I've started a search in the forums here.


  • Mod

    @subutux I've updated the text. Do you think it is ok?



  • @mfalkvidd said in 💬 Building a Raspberry Pi Gateway:

    @subutux I've updated the text. Do you think it is ok?

    yup! thanks!



  • Hi,
    I'm having trouble setting up mysensor with this configuration.
    Controler : Home assistant on a debian server. ip : 192.168.0.50
    Gateway : rpi3, connected to the server trought ethernet. ip : 192.168.0.21
    Sensor : simple door switch from the example scripts.

    On both sensor and gateway the transport is a nrf24l01+ module. I bought 4 of them and they all worked in simpler projects (on both arduino and rpi).

    The main problem is I can't get the rf24l01+ to work with mysensor. I checked the wiring multiple times a changed the module. Nothing changes.
    I also tried to change the configuration settings but it has no effect :

    I configured as :
    ./configure --my-transport=nrf24 --my-gateway=ethernet --my-controller-ip-address=192.168.0.50 --my-port=5003

    Here is what I got every time i launch mysgw :

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

    I used the wiring described in the script but without a voltage regulator. so I also checked the voltage received by the nrf24l01+ and it's a steady 3.3v.

    What's wrong here ? Any help would be greatly appreciated.

    --

    On another topic, home assistant doesn't seem to provide support for mysensor 2.1 protocol. Should I downgrade to 2.0 ?
    Obviously the controler can't connect to the gateway presently since the gateway isn't launching properly.
    Home assistant is constantly whining about it :

    Here is what I get from home automation console :

    Error (Thread-13) [mysensors.gateway_tcp] Failed to connect to socket at ('192.168.0.21', 5003).

    and here is my configuration.yaml extract :

    mysensors:
    gateways:
    - device: '192.168.0.21'
    optimistic: false
    persistence: true
    retain: true
    version: 2.0,



  • I just checked the wiring again and tested it with a voltage shifter I used for a grove RGB LCD and I got the same results


  • Mod

    @qkzk said in 💬 Building a Raspberry Pi Gateway:

    --my-controller-ip-address=192.168.0.50

    I think you can ignore that parameter. Did you try making a USB gateway or ethernet gateway with an arduino? Why the voltage shifter? Did you add a capacitor on the 3.3v supply of the nrf24? You could also try with the 2.2.0 version from development branch that has some fixes



  • I tried the voltage shifter since I read : (*): If you are using the nrf24 PA/LNA version you need to use a 5V->3.3V regulator because the Raspberry Pi 3.3V can't supply enough power.
    Since I don't know the version...

    I had no success with an arduino USB gateway but I'll try again.

    I thought the controller-ip-adress=192.168.0.50 parameter was usefull otherwise the gateway would have to look guess where the controler is. I may have got everything wrong about who is initiating the dialogue. From what I read in home automation logs it's the controller who is looking for the gateway...

    I'll try the 2.2.0 version.



  • I managed to connect everything but not the way I would have prefered.
    Controler : Home assistant on debian server
    Gateway : arduino Uno connected to debian server trough usb serial
    Sensor : binary sensor (reed switch) on arduino mini.

    I'm still trying to figure what's wrong with what I posted earlier.



  • WOW ! It works 🙂 thanks @gohan 🙂
    I removed the voltage shifter, added an 1µF capacitor and downloaded developpement libraries.
    Also, I cleaned the configuration parameters : ./configure --my-transport=nrf24 --my-gateway=ethernet
    It finally works as expected (sensor, gw on rpi3, controler on debian server) and I can ditch the uno (well, I'll find him another use).
    Thanks again for the wonderfull work, it's been fun 🙂


  • Mod

    Voltage regulator is strongly suggested when you are going to have the gw sending out messages and also a bigger capacitor will help



  • I'm trying to understand the need for a separate Gateway if the Ras Pi is the host of the controller. Is it possible to use OpenHab on the Pi AND have the RF transceiver connected to that same Pi and skip the ethernet adapter w/ Arduinos? Or, if you have to use ethernet, could you use localhost as the IP? Or is there a technical reason why that wouldn't work (or would work, but in a totally different way)? Thank you.


  • Mod

    Did you read the article?



  • @Andy-Pethan there is no need, where You read that ? I have a raspi with openhab and mqtt gw on single board. works very well.



  • @gohan @rozpruwacz After reading a couple times it still wasn't clear that everything could run on one device (single Ras Pi), though that seemed like the intuitive answer. Thank you for confirming as I buy up parts.



  • I figured out my problem -- I had the image and concept of this tutorial (http://www.instructables.com/id/Uber-Home-Automation-w-Arduino-Pi/) one tab over and never noticed at 3am that I mentally blended the articles. Sorry, everyone.


  • Mod

    In fact I was wondering what in the article wasn't clear.


  • Hardware Contributor

    Going crazy here.
    I did get success with MySensors and first Arduino node on a fresh Raspbian (last image) and branch development. All ok!

    Now I want re-do on other SD (same Pi, same WIring, same Radio). I did put "old" sd on a secure location and re-start from scratch.

    I did compile with:

    ./configure --my-transport=nrf24 --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyUSB020
    

    and answer is:

    [SECTION] Detecting target machine.
      [OK] machine detected: SoC=BCM2835, Type=rpi1, CPU=armv6l.
    [SECTION] Detecting SPI driver.
      [OK] SPI driver detected:BCM.
    [SECTION] Detecting init system.
      [OK] init system detected: systemd.
    [SECTION] Saving configuration.
    [SECTION] Cleaning previous builds.
    [OK] Finished.
    

    Make ends with no error.

    The debug

    sudo ./bin/mysgw –d
    

    locks here:

    mysgw: Starting gateway...
    mysgw: Protocol version - 2.2.0-beta
    

    And no other lines.

    I Repeat, same PI, same Radio, same wiring. If I try other SD, all goes ok and I can use it on domoticz.

    Thank you


  • Hardware Contributor

    @sineverba

    @sineverba said in 💬 Building a Raspberry Pi Gateway:

    Going crazy here.
    I did get success with MySensors and first Arduino node on a fresh Raspbian (last image) and branch development. All ok!

    Now I want re-do on other SD (same Pi, same WIring, same Radio). I did put "old" sd on a secure location and re-start from scratch.

    I did compile with:

    ./configure --my-transport=nrf24 --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyUSB020
    

    and answer is:

    [SECTION] Detecting target machine.
      [OK] machine detected: SoC=BCM2835, Type=rpi1, CPU=armv6l.
    [SECTION] Detecting SPI driver.
      [OK] SPI driver detected:BCM.
    [SECTION] Detecting init system.
      [OK] init system detected: systemd.
    [SECTION] Saving configuration.
    [SECTION] Cleaning previous builds.
    [OK] Finished.
    

    Make ends with no error.

    The debug

    sudo ./bin/mysgw –d
    

    locks here:

    mysgw: Starting gateway...
    mysgw: Protocol version - 2.2.0-beta
    

    And no other lines.

    I Repeat, same PI, same Radio, same wiring. If I try other SD, all goes ok and I can use it on domoticz.

    Thank you

    OK, re-re-done on fresh install and all went ok.

    I think that problem was when I deleted the PI default user and created another one.

    I did follow the gordon guide: https://gordonlesti.com/change-default-users-on-raspberry-pi/

    Probably a permission issues changing or not changing root?

    Thank you



  • Hi all

    Hope someone can help MySensors noob 🙂 I try to do Raspberry pi 3 gateway with nrf24 module.

    Hardware:
    Raspberry pi 3
    nrf24 module
    3.3v 0.5A regulator.
    status leds (3pcs)
    Domoticz Beta

    I start with this instructions:
    https://www.mysensors.org/build/raspberry#improving-throughput-for-nrf24

    commands what i use:
    git clone https://github.com/mysensors/MySensors.git --branch master
    cd MySensors
    ./configure --my-transport=nrf24
    ./configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway (try ttyUSBMySensorsGateway too, but now help)
    ./configure --my-transport=nrf24 --my-rf24-irq-pin=15
    ./configure --my-leds-err-pin=12 --my-leds-rx-pin=16 --my-leds-tx-pin=18

    make
    sudo ./bin/mysgw -d

    After that i get error what is same to that instruction site:
    http://i.imgur.com/jpiaMdC.png

    I douple check wiring that seems to be all right. I think Linux console tell wrong wiring, if wiring is problem? But anyway i douple checked that wiring.

    Hope someone can help me with this problem.

    I try many times different settings, dont know do i need delete some old files or can i try again and again do configure and give "make" command.


  • Mod

    @lassivv please don't post the same question in multiple places. Posting in multiple places will result in people trying to help you in one place, even after the problem has been solved in the other place. That is a waste of people's time.

    Anyone trying to help @lassivv please post in https://forum.mysensors.org/topic/7050/multi-node-project-mysensors-noob-raspberry-gateway-problem



  • Sorry see this topic after i post my own topic, thinks this is better topic to my problems. But i continue my own topic.


  • Hardware Contributor

    I have a couple of nodes + PI working without issues from a couple of days.
    Now, I would add encryption / signing / security etc to protect traffic between Arduinos and PI.
    Could you please help me posting right configuration to add to the

    ./configure

    command?

    Thank you very much!



  • Why do Tx and Rx Leds blink every 5 to 6 seconds?

    Is it about communication between RPi and Gateway?

    Is there a way to disable it and keep blinks only with nodes communication?


  • Hardware Contributor

    @sineverba said in 💬 Building a Raspberry Pi Gateway:

    I have a couple of nodes + PI working without issues from a couple of days.
    Now, I would add encryption / signing / security etc to protect traffic between Arduinos and PI.
    Could you please help me posting right configuration to add to the

    ./configure

    command?

    Thank you very much!

    Sorry..... I would UP! this 🙂


  • Contest Winner

    @sineverba is there not a --help argument to get a list of settings?


  • Hardware Contributor

    @Anticimex sure... Bit I did read also the guide and .... I did noto understand very well whats I need to activate (if need) on gateway and on Arduinos to block, for example, the persone that live on third floor to play with my heater ..... 🙂 thank you in advance

    PS security only software, no other hardware implied / want use

    Thank you!


  • Contest Winner

    @sineverba I am not sure I understand what you want. You want to enable signing? There is extensive documentation on how to enable that. As for what to pass to the configure command on a rPi I am unsure of the exact naming but I am pretty sure the names are very similar to the #define:s the signing documentation describes.


  • Hardware Contributor

    @Anticimex Yes, the doc is ... maybe ... too extensive 🙂

    By the way, I would signing. So I need to do on both? Gateway/Raspberry and Arduino?

    Thank you


  • Contest Winner

    @sineverba I am not sure I understand how it can be too excessive? It sounds like it is inadequate since you still have questions. 🙂
    Of course you have to enable signing on both node and gateway. You also need to personalize the services with a hmac key. This is described. Please read the docs carefully. And if they are unclear, please provide a link to the documentation you have read, so I can verify you read the correct one.


  • Hardware Contributor

    @Anticimex
    I'm talking about this: https://www.mysensors.org/about/signing

    Seems to me that probably need to be more clear your hint: you have to enable signing on both node and gateway.

    I hope that soon I will can test on my network 🙂

    Thank you for the moment 🙂


  • Contest Winner

    @sineverba yes, well that is for the official release so so far so good. I assume you also run the official version of the library and not the beta version, right?
    For details on rPi configuration, perhaps @marceloaqno can provide some assistance but you will find all information needed on that page for configuring signing on your nodes.


  • Hardware Contributor

    @Anticimex On Raspberry PI V1 I can work only with branch development. With master the radio / serial doesn't work


  • Contest Winner

    @sineverba then please use this documentation instead.


  • Hardware Contributor

    @Anticimex thank you but... it is not the same?


  • Contest Winner

    @sineverba no, it isn't. There are newer features on beta branch. A third simplified option for signing exist (and if you have a hard time figuring out signing I highly recommend you use it).


  • Hardware Contributor

    Raspberry PI V1 Model B (2 USB ports, no wifi, 26 GPIO).

    RASPBIAN JESSIE LITE v 2017-04-10-raspbian-jessie-lite.

    Some day ago I did compile the gateway only with development branch, using this:

    ./configure --my-transport=nrf24 --my-rf24-irq-pin=15 --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyUSB020
    

    And all works fantastic.

    Today I did try a new fresh installation for a friend, same PI, and same commands and routine from zero:

    1. Logged with PI
    2. Changed Password
    3. Activate SSH
    4. Activate SPI
    5. Expand Filesystem
    6. Changed timezone

    launched

    ./configure --my-transport=nrf24 --my-rf24-irq-pin=15 --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyUSB020
    

    No error on output, rebooted many times, gateways locked. See the screen:

    alt text

    With current setup (that works perfect), if I reconfigure to use Led TX/RX/Err, I get same lock.

    I have SD and a copy of it, but I would setup another one from zero.... and I cannot.

    Thank you


  • Hardware Contributor

    I don't want give up!

    I did download last RASPBIAN version (2017-06-21).
    Gitted from development branch...

    alt text

    My question is.... is it a problem of my PI? Too old? Need to buy the V3?

    I don't understand why some time ./configure works (and entire system with domoticz works without problem!!!) and other time no!

    @sineverba said in 💬 Building a Raspberry Pi Gateway:

    Raspberry PI V1 Model B (2 USB ports, no wifi, 26 GPIO).

    RASPBIAN JESSIE LITE v 2017-04-10-raspbian-jessie-lite.

    Some day ago I did compile the gateway only with development branch, using this:

    ./configure --my-transport=nrf24 --my-rf24-irq-pin=15 --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyUSB020
    

    And all works fantastic.

    Today I did try a new fresh installation for a friend, same PI, and same commands and routine from zero:

    1. Logged with PI
    2. Changed Password
    3. Activate SSH
    4. Activate SPI
    5. Expand Filesystem
    6. Changed timezone

    launched

    ./configure --my-transport=nrf24 --my-rf24-irq-pin=15 --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyUSB020
    

    No error on output, rebooted many times, gateways locked. See the screen:

    alt text

    With current setup (that works perfect), if I reconfigure to use Led TX/RX/Err, I get same lock.

    I have SD and a copy of it, but I would setup another one from zero.... and I cannot.

    Thank you


  • Hardware Contributor

    Hi to all!
    I did another test, on a new SD with Raspbian Lite 2017-06-21.

    It doesn't work. Hangs on protocol version.

    But... I did note this, after ./configure

    Master branch

    [SECTION] Detecting target machine.
      [OK] machine detected: SoC=unknown, Type=unknown, CPU=armv6l.
    [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.
    

    Development branch

    [SECTION] Detecting target machine.
      [OK] machine detected: SoC=BCM2835, Type=rpi1, CPU=armv6l.
    [SECTION] Detecting SPI driver.
      [OK] SPI driver detected:BCM.
    [SECTION] Detecting init system.
      [OK] init system detected: systemd.
    [SECTION] Saving configuration.
    [SECTION] Cleaning previous builds.
    [OK] Finished.
    

    I'm going crazy 😞

    @sineverba said in 💬 Building a Raspberry Pi Gateway:

    I don't want give up!

    I did download last RASPBIAN version (2017-06-21).
    Gitted from development branch...

    alt text

    My question is.... is it a problem of my PI? Too old? Need to buy the V3?

    I don't understand why some time ./configure works (and entire system with domoticz works without problem!!!) and other time no!

    @sineverba said in 💬 Building a Raspberry Pi Gateway:

    Raspberry PI V1 Model B (2 USB ports, no wifi, 26 GPIO).

    RASPBIAN JESSIE LITE v 2017-04-10-raspbian-jessie-lite.

    Some day ago I did compile the gateway only with development branch, using this:

    ./configure --my-transport=nrf24 --my-rf24-irq-pin=15 --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyUSB020
    

    And all works fantastic.

    Today I did try a new fresh installation for a friend, same PI, and same commands and routine from zero:

    1. Logged with PI
    2. Changed Password
    3. Activate SSH
    4. Activate SPI
    5. Expand Filesystem
    6. Changed timezone

    launched

    ./configure --my-transport=nrf24 --my-rf24-irq-pin=15 --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyUSB020
    

    No error on output, rebooted many times, gateways locked. See the screen:

    alt text

    With current setup (that works perfect), if I reconfigure to use Led TX/RX/Err, I get same lock.

    I have SD and a copy of it, but I would setup another one from zero.... and I cannot.

    Thank you


  • Mod

    Try DIETPI instead of raspian and see if it changes


  • Hardware Contributor

    @gohan
    I can and I will try, of sure. But, why do you think that something will change? My hardware is too old?



  • Can you look and see what power supply you are using and also tell us what you have connected to the pi?
    Do you have a volt meter and know how to use it?


  • Hardware Contributor

    @skywatch
    For a moment, I did hope that your was final solution.

    By the way, I have HDMI attached (but TV is off) and a hub usb (with nothing attached).

    I did try 7 sd cards.

    I did try also Samsung charger (ETA U90EWE) and a powerbank, both 5v/2a

    I have a cheap multimeter and I have basic knolewdge. What do you want I measure?

    The radio is firmed soldered on an header array and linked with jumpers:

    alt text

    No caps 'cause the nodes and gw can transmit without problem on over 15 meters on my home 🙂

    Exact configuration with a 7-days-old installation works very well. If I try to replicate, with every combination (last raspi/previous raspi/master/development) sometimes works, I re-flash and doesn't work anymore.

    I'm not crazy, I would to be sure that in every moment I can replicate totally the configuration from scratch and... I want understand whats the problem!

    PS The config that works very well, If I try to reconfigure to use the LEDS, after configure hangs on same, same step of debug. Luckily, I use rpi-clone before every single edit on my so-precious configuration.

    PPS If someone wants, I could torrent my SD configured.... 😞



  • OK! - Now I am not saying I have the solution to your problem, but I think it is worth ruling out a few things.

    If nothing is attached to the USB hub, disconnect it.
    With your voltmeter set to DC Volts, measure between TP1 and TP2 on the pi. You should see 5V DC. Up to about 5.5V is OK, but less than 4.8V can affect some things. Many time I have seen power issues be the problem.

    Why not wire the NRF24L01 direct to the pi?

    If all is well, then seems it is software problem after all 😉


  • Hardware Contributor

    @skywatch

    Thank you for your support.
    So, I did disconnect everything.
    I did try and I have 4.95 - 4.98v on every moment, also during the "make" of ./configure.

    alt text

    A bit low, but I think no so low. The mysgw -d lock / hangs with every power supply...

    PS Radio between headers because I want learn skill solders and more easy swap to test others radio, and, last but not last, with headers dupont/wires are more firmly than directly on the radio.



  • That all seems to be OK - Always worth checking though if you ever get issues.
    That means that I am lost for any ideas on why you have problems with ./configure>make>make install. It seems odd. Do you have another pi to try it on? That's the only thing I can think of now....even a cheap pi zero would be OK for a test.

    I would still disconnect the USB hub and all the gpio wiring at the pi and see how it goes.

    Good Luck! 🙂


  • Hardware Contributor

    @skywatch Unfortuntately not, it's only pi that I have.
    No problem, better to check everything. I don't know if open in github, leave here, pass to arduino connected via USB.....

    And.. for Arduino connected via USB, I need to abilitate something with raspi-config or the only thing to do is to connect and domoticz will read it? (of course with sketch gateway loaded on arduino!)



  • @OliverDog said in 💬 Building a Raspberry Pi Gateway:

    Why do Tx and Rx Leds blink every 5 to 6 seconds?
    Is it about communication between RPi and Gateway?
    Is there a way to disable it and keep blinks only with nodes communication?

    Is there an answer for that?
    Thanks again


Log in to reply
 

Suggested Topics

  • 3
  • 109
  • 164
  • 347
  • 10
  • 5

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts