πŸ’¬ Building a Raspberry Pi Gateway


  • Mod

    After updating domoticz to beta version I finally have the MQTT working with controller and I can see the sensor node seding in data: my question now is how to I debug the gateway if it is running as a service on the RPI without messing things up?



  • @marceloaqno I am trying to get a Pi 3 working with MySensors 2.1.1 and nrf24l01 and using your updated wire guide, but all I get as output is the following:
    mysgw: Starting gateway...
    mysgw: Protocol version - 2.1.1
    mysgw: MCO:BGN:INIT GW,CP=RNNG--Q,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
    [The output repeats itself, increasing the CNT every time, while at the same time one of the cores on the Pi 3 is running at full CPU utilization.]

    By reading earlier comments I assume this is a wiring problem. One possible cause is inconsistency between
    0_1488723559852_upload-e3165792-1f42-4663-8e68-efd96bd275f8

    and

    0_1488723638471_upload-d7048ef8-8a33-4214-9935-0356cf9291c2

    where the first picture indicates that pin 24 and pin 26 should be used, while the second indicates pins 22 and 24 should be used. However, I have tried both options but I still get the same output (I used different nrf24's for the different setups, in case the nrf24 got burned from the first setup).

    I have VCC from nrf24 connected to pin 17 on the Pi 3 and GND connect to pin 25.

    Any suggestions on what to try next?
    [The Pi 3 is running Raspbian with Pixel. For information, I already have a running Arduino with MySensors MQTT GW and a simple node with MySensors and DHT22. From this I know that by nrf24 chips works when being fed with 3.3V.]


  • Mod

    I have connected my nrf24 like the secon table you posted and it is working but I am using an "adapter" for nrf24 with a socket and has voltage regulator + capacitors, so if you don't have any cap on the radio module, I'd suggest you put one on (try from a 4.7 uF up to 47 and see if anything changes)



  • @gohan Thanks! You were correct. I also had one of those "adapters" lying around which I did not need for my Arduino nodes with MySensors, though it came into use for the Rp3.



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

    After updating domoticz to beta version I finally have the MQTT working with controller and I can see the sensor node seding in data: my question now is how to I debug the gateway if it is running as a service on the RPI without messing things up?

    I have my gateway on a headless pi 3, no monitor, GUI or keyboard. (I don't care for the nest of wires connection to the pi.) I also use MQTT which is very reliable.

    An easy way to see the full MQTT traffic is to not start (or kill if it starts on boot) the MQTT server in the background, and start it in the console you can monitor. This won't impact Domotics one bit. In my case I do this by invoking "mosquitto -d" in the terminal

    A simple way to monitor MQTT once its up and running is to look at the Domotics Log on the Setup menu.

    Another way to watch it is to, in a terminal window such as running ssh from your computer, use MQTT "sub" in your terminal to see the MQTT traffic both ways to and from Domotics. If this isn't familiar, you need to learn it, (read the MQTT docs) and it's quite simple. Example might be "ssh pi@rpi.local" or "ssh <IP address>" from a computer on the local network, assuming the user is named pi and the pi is named "rpi"

    Your MQTT topic must match what is in the sensor node sketch, the gateway sketch, and the domotics MQTT config. In my case I use "mosquitto_sub -d -v -t domoticz" and everything starts showing in real time in the terminal window.

    MQTT is a bit more fiddly to set up but it's nice that different environments can push sensor data into the same MQTT server, in my case MySensors and ESP Easy.

    Tim



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

    where the first picture indicates that pin 24 and pin 26 should be used, while the second indicates pins 22 and 24 should be used.

    Be careful because the wiring page shows two pinout diagrams, one for the Pi 1, another for the Pi 2&3, but which is which is not inside the graphic itself. Please don't ask how I know. πŸ˜‰

    Tim


  • Mod

    @Grubstake
    I am using mqtt fx from pc and subscribing to topic # so I get the full traffic of what is going on, but I haven't had time lately to compare if you get same log details as the myscontroller connected to ethernet gateway or starting the gateway on rpi with debug flag



  • @marlin Got the same issue, Did you solve yours and if so how?



  • @keldandorin Yes. See the response by @gohan. I used a "adapter" with a voltage regulator on it etc. Though, at the moment I don't recall the model number.


  • Mod

    @keldandorin just add a capacitor between vcc and gnd on the radio module as I suggested above.



  • I am trying to connect NRF24L01+ and Raspberry Pi 2 (Model B+). I am confuse about pin 22/24 too. In the diagram it shows "SPI0 CS0" and "SPI0 CS1" but these two pins aren't exist in NRF24L01+. How should I connect the pin? I connect Pi2 pin 24 to CS and Pi2 pin 26 to CE (Not sure it is correct)? Here is the message from mysgw:

    [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
    


  • @ccy Look at the chart below "NRF24L01+ Radio". That shows the PIN numbers on the Pi and the pin labels on the radio to interconnect. Pay no attention to the labels on the RPi generic pinout diagram except the PIN numbers. The RPi SPIO labels are not what you are looking for. And be sure to use the chart for the correct RPi model.


  • Mod

    Exactly, I was about to write pretty much the same πŸ˜€



  • @gohan I beat you to it! πŸ˜ƒ



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


  • I can run mysgw. But what can I use it for? I want to make it control my light with 2.4G RF. But I don't know what to do next. Please advice Thank you.


  • Mod

    @ccy
    You need to provide some more details about your hw and general setup, what have you done so far, log messages, etc.



  • @gohan Sorry for my typo mistake. I can now run mysgw. But what can I use it for? I am trying to control my light with 2.4G RF.


  • Mod

    Do you mean your light has already 2.4G RF or do you need to make a relay node with NRF24 that can switch on and of that light? But this is going a little OT in this thread.



  • @gohan Yes. I want to do that. I am sure my LED controller is 2.4G RF. But I can't detect any signal yet from my nrf24l01+ on raspberry pi. I am not sure what's wrong. Still trying now...


  • Mod

    @ccy
    Being 2.4G RF doesn't mean it is NRF24L01 compatible also without knowing what channel is using will make it even more difficult. So, unless you want to make a Mysensors LED Controller, I think you are out of luck if you want to directly control your existing one with a RPI and the mysensors gateway. Either way this is OT.



  • @gohan Is there a way to know the channel by doing some sort of scan? If the channel is known, what are the setting to fix the channel for mysgw?



  • Hello everyone!

    I'm using a Rasp2 (with the 40 pins GPIO header)

    Has anyone experience with using the NRF module on different pins than default? I'm asking because I wonder if I can connect a GPIO-connected touch TFT (which would use the 2 CE lines for the touch and display interfaces) together with the NRF - by hooking the MISO/MOSI/SCLK to the default pins (and thus sharing them between the TFT and NRF) and defining free pins for the CE and CS lines in the ./configure script when compiling the gateway code...?!

    Or maybe using the SPI1 by first enabling it as laid out in this blog post - but how to proceed from there? (How to tell the gateway code to use SPI1?)


  • Code Contributor

    @Velo17

    ./configure --spi-driver=SPIDEV --spi-spidev-device=/dev/spidev1.0
    

    (replace the /dev/spidev1.0 with the one you enabled in /boot/config.txt)



  • Hello Masters,

    Could you please help me with setting up virtual serial port?

    I can't see the interface created under /dev.
    I'm using the instructions and finish with the setup with the following command:

    pi@raspberrypi:/tmp/MySensors $ ./configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway
    [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: systemd.
    [SECTION] Saving configuration.
    [SECTION] Cleaning previous builds.
    [OK] Finished.
    
    pi@raspberrypi:/ $ sudo /usr/local/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
    mysgw: Listening for connections on 0.0.0.0:5003
    mysgw: MCO:BGN:STP
    mysgw: MCO:BGN:INIT OK,TSP=1
    
    

    Everything seems to be OK. However, when I check /dev directory, the interface is not created.

    What could be an issue?
    Thank you in advacne!


  • Mod

    Why don't you compile it as ethernet gateway?



  • @gohan Etherner Gareway is not supported by OpenHab MySensors binding.


  • Mod

    Mqtt? πŸ˜€



  • @gohan I'm sorry, MQTT is not supported by OpenHab MySensors binding. Ethernet Gateway is not supported on Raspberry PI.


  • Code Contributor

    @engy OpenHab2 supports mysensors serial and ethernet gateways:
    https://github.com/tobof/openhab2-addons/wiki

    Maybe the build guide may have given you that impression, but ethernet Gateway is supported on Raspberry PI:

    ./configure --my-gateway=ethernet
    


  • @gohan Solved the problem with radio...Thx



  • Thank you guys for prompt reaction. Indeed, Ethernet GW works flawlessly!



  • Hi
    Is anyone else having this same problem on Rpi3?: Gateway works ok after "sudo make install" with openHAB. With "sudo ./bin/mysgw -d" I can get debug log visible and log works ok.
    But if I run "sudo systemctl enable mysgw.service" after "sudo make install", debug log start showing endlessly "mysgw: accept: Bad file descriptor". So debug log function gets destroyed and it can't be used anymore. I have made several clean installations and every time this same happens.
    Br
    Tommi


  • Code Contributor

    @TommiP What I think is happening is that you are running two instances of the gateway.
    If you need to get the debug logs, first stop the mysgw service:

    sudo systemctl stop mysgw.service
    


  • @marceloaqno
    Ok, now I understand what happened, thanks.



  • Re: πŸ’¬ Building a Raspberry Pi Gateway

    Silly questions, I'm a little bit confuse.
    I have a serial Gateway running with arduino nano + nrf24 and a raspberry pi with domoticz on board. The link between domoticz & Gateway is done via USB <=> serial port (/dev/ttyUSB0). This setup runs like a charm.

    Now, I would like to access to my Gateway via the network because I would like to use "Over The Air " functionnality with MYSController.

    Can I install MySensors Gateway on the raspberry and keep the arduino + nrf24 connected via usb ?? For the moment, I can not use GPIO port.

    If for some reason you can't use the GPIO pins of the Raspberry Pi, you could connect the radio to a arduino with the GatewaySerial sketch and feed the pi through a serial port:

    ./configure --my-gateway=serial --my-serial-port=/dev/ttyUSB0 --my-serial-baudrate=115200
    

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

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

    Where is my mistake ??
    Again, Can I install MySensors Gateway on the raspberry and keep the arduino + nrf24 connected via usb or I must connected the nrf24 directly with GPIO on the Rasp ??

    Thanks in advance for your reply.
    Romeo


  • Mod

    @romeo01 I think that connecting nrf24 directly to arduino and compile mysgw as ethernet gateway is the cleanest solution (I have it as MQTT and it is working fine, but ethernet is the same). Keep in mind that you'd better use one of those adapters 5v-3.3v for nrf24 chips + capacitor because the 3v output of raspberry isn't very suited for the task.



  • Thanks gohan for fast answer.

    Arduino nano + nrf24 are already connected together. Hardware is already built.

    How access to the gatway installed on the raspberry via the network and use my arduino + nrf24 connected via usb/serial to the raspberry ??

    Sorry but I do not understand what you mean
    ...compile mysgw as ethernet gateway is the cleanest solution...

    If I configure on this way
    ./configure --my-gateway=ethernet --my-port=5003

    I could access to my Gateway via network an the Gateway will use the arduino + nrf24l via usb/serial ??

    That's why I say I'm confuse.

    --my-gateway=serial 
    

    What is this option ? The link between gateway and nrf24 or the way to access to the Gateway ??



  • In summary,

    Is the Gateway (software) installed on the raspberry, is able to manage the nrf24 connected on arduino via USB/Serial port ??


  • Mod

    no, I don't think so. If you want to manage nodes over network you need to make an ethernet gateway (could be a UNO with w5100 shield, an esp8266 or mysgw compiled on raspberry)



  • nrf24 connected to a arduino nano and plugged to the raspberry over the usb/serial cable is not considered as a serial device ?

    What is this option ?

    --my-gateway=serial
    

    If for some reason you can't use the GPIO pins of the Raspberry Pi, you could connect the radio to a arduino with the GatewaySerial sketch and feed the pi through a serial port:

    That's exactly what I need, but how to do ??

    ./configure --my-gateway=serial --my-serial-port=/dev/ttyUSB0 --my-serial-baudrate=115200
    

    Serial port /dev/ttyUSB0 is ok, because I use this with domoticz and it'running good.

    My initial question is how to use my old gatway (arduino + nrf24) with the gateway compiled on the raspberry over the usb/serial cable ?
    I can not use GPIO port.


  • Mod

    The serial gateway on the raspberry does what your nano is doing and you can't have gateways talking to each other. Maybe you could look at mycontroller and see if can manage nodes the way you want.



  • When talking about this Raspberry Pi Gateway, I suppose, that its just connecting the NFR24L01+ to the Raspberry Pi GPIO and run

    ./bin/mysgw -d
    

    right? On my Pi it does not work this way, maybe the NFR24L01+ is not ok. Instead I am running an external esp-wifi-gateway, but a direct gateway seems the better solution to me.
    So did I get it right, that I can use a NFR24L01+ connected to the Raspberry PI GPIO without any external gateway? If so, what are the parameters for building the mysgw daemon? I tried this one:

    ./configure --spi-driver=SPIDEV --spi-spidev-device=/dev/spidev0.0
    

    update: as in https://www.mysensors.org/view/180#wiring
    22 – CE
    24 – CSN/CS
    23 – SCK
    19 – MOSI
    21 – MISO

    SPI is activated:

    $ls /dev/spidev*
    /dev/spidev0.0  /dev/spidev0.1
    

    And this is the result, when building it with the settings mentioned above. (Raspberry Pi 3, jessie 4.9.13-v7+)

    $ 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
    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: TSM:FAIL:RE-INIT
    mysgw: TSM:INIT
    mysgw: !TSM:INIT:TSP FAIL
    mysgw: TSM:FAIL:CNT=4
    mysgw: TSM:FAIL:PDT
    

    And can someone show how to bind this gateway into FHEM? As said, today I am running an esp-wifi-gateay.

    Thanks in advance for any support...



  • @gohan
    With the serial Gateway on the raspberry; how is connected the nfr24 ??
    If usb/serial port is no possible, which serial port to use ?



  • @gohan Been trying to find my old post to tell you all how it got with my rpi and nodes that did not register. I bougt some voltage regulators LM350. used the 5v output insted of 3.3 V but still no luck to get node to register. when messauring volatage when GW send awnser it drops way below 3.3v. I think voltage output from rpi just is to bad. So I bought a nodemcu for GW instead and it works like a sharm πŸ™‚


  • Code Contributor

    @romeo01 You have to connect the nrf24 to the GPIO if you want to use it with the RPi, the information on the wiki was wrong, sorry about that.


  • Mod

    @marceloaqno he said he can't connect nrf24 chip on the rpi, so that's why he is struggling


  • Code Contributor

    @dirkc Try to connect your module to the SPI0 (https://www.mysensors.org/view/180#wiring).
    You only need to enable the SPIDEV if you want to use the SPI1.


  • Mod

    @dirkc I don't know where you got those pin numbers but they don't look like the ones on the guide. In addition you don't have to use spi driver. The PA version of nrf24 are quite a pain to get them working, so I suggest you first test with regular modules and then upgrade to PA



  • @gohan, @marceloaqno : sorry, I corrected the "typo", the NRF was already connected as shown in https://www.mysensors.org/view/180#wiring. I double checked that again.
    What is the correct setup for ./configure ?



  • @marceloaqno

    Thanks marceloagno, the answer is clear.

    Keep up the great work !


  • Code Contributor

    @dirkc The default settings for ./configure is to use the nrf24 module connected in the same way as shown in the guide and as an ethernet gateway.



  • I'm having issues with the LED setup as shown on the page. The LEDs are just constantly on even though everything looks like it's setup just like the picture. I'm new at this so I could be doing something stupid.



  • @marceloaqno ok, thanks, I will change the radio.


  • Code Contributor

    Support for RFM69 was added to the development branch (finally!).



  • @marceloaqno

    IΒ΄m really happy ear that !

    RFM69 is one of best RF transceivers in these days for IoT.
    So good news I believe for Mysensors community.

    You know if are any hope that RFM69 will be added too to OPI boards support mysgw development ?

    Congratulations for that great work !


  • Code Contributor

    @jirm Support for RFM69 also applies to the OrangePi πŸ˜‰



  • @marceloaqno

    Awesome !!!
    Thank you so much.

    Best regards



  • When I configure "MY_RFM69_MAX_POWER_LEVEL_DBM" in MyConfig.h, compiling fails.
    Perhaps you should change the code in ./drivers/RFM69/new/RFM69_new.h from:

    #define RFM69_MAX_POWER_LEVEL_DBM MY_RFM69_MAX_POWER_LEVEL_DBM //!< MY_RFM69_MAX_POWER_LEVEL_DBM

    to:

    #define RFM69_MAX_POWER_LEVEL_DBM ((rfm69_powerlevel_t)MY_RFM69_MAX_POWER_LEVEL_DBM) //!< MY_RFM69_MAX_POWER_LEVEL_DBM



  • I cannot get the RFM69(HW) working. When I start myswg in debug mode (-d), I see:

    mysgw: Starting gateway...
    mysgw: Protocol version - 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: RFM69:INIT
    mysgw: RFM69:INIT:PIN,CS=24,IQP=22,IQN=22
    mysgw: RFM69:PTX:LEVEL=5 dBm
    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
    

    But I can see ('hear' with a radio on 868.000 MHz) no transmission of the RFM69. When I power up a node, the node does not connect to the gateway: "NO REPLY"πŸ‘

    0 MCO:BGN:INIT NODE,CP=RRNNA--,VER=2.1.1
    4 TSM:INIT
    4 TSF:WUR:MS=0
    8 TSM:INIT:TSP OK
    10 TSM:INIT:STATID=4
    12 TSF:SID:OK,ID=4
    14 TSM:FPAR
    274 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    2281 !TSM:FPAR:NO REPLY
    2283 TSM:FPAR
    2562 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4569 !TSM:FPAR:NO REPLY
    4571 TSM:FPAR
    4831 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6838 !TSM:FPAR:NO REPLY
    6840 TSM:FPAR
    7100 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    9107 !TSM:FPAR:FAIL
    9109 TSM:FAIL:CNT=1
    9111 TSM:FAIL:PDT
    

    Is there any 'check' I can do to perform basic RFM69HW testing on my RPI?


  • Mod

    Was it working before on a normal Arduino gateway? How did you wire everything up?



  • I'm pretty sure I wired up the RFM69 correctly.
    However, I'm debugging. It seems we are stuck in "core/MyGatewayTransport.cpp":

    inline void gatewayTransportProcess(void)
    {
    
      if (gatewayTransportAvailable()) {
        // NEVER REACHED
    

    I never seem to get pass gatewayTransportAvailable. I will continue debugging.
    Disclaimer: I'm relatively new to MySensors and not really 'up to speed' with the source code :-).



  • @ftw64 Ok, this has to do with connecting an Ethernet client. When a client connects, this code works...
    Any idea where to start debugging for incoming RFM69 messages?


  • Mod

    Download myscontroller and connect it to the gateway, you can now see all messages from ethernet controller



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

    myscontroller

    I just did. When I also have a Domoticz controller connected to the gateway:

    2017-04-23 11:18:33	INFO	Connected to 192.168.10.24:5003
    2017-04-23 11:18:33	CHILD	New child discovered, node id=0, child id=internal
    2017-04-23 11:18:33	RX	0;255;3;0;14;Gateway startup complete.
    2017-04-23 11:18:33	DEBUG	Update child id=255, type=ARDUINO_RELAY
    2017-04-23 11:18:33	RX	0;255;0;0;18;2.2.0-beta
    2017-04-23 11:18:33	RX	0;255;3;0;22;208103
    2017-04-23 11:18:33	RX	0;255;3;0;2;2.2.0-beta
    2017-04-23 11:18:43	RX	0;255;3;0;22;218106
    2017-04-23 11:18:53	RX	0;255;3;0;22;228110
    2017-04-23 11:19:03	RX	0;255;3;0;22;238101
    2017-04-23 11:19:13	RX	0;255;3;0;22;248104
    2017-04-23 11:19:23	RX	0;255;3;0;22;258110
    2017-04-23 11:19:33	RX	0;255;3;0;22;268107
    2017-04-23 11:19:43	RX	0;255;3;0;22;278106
    2017-04-23 11:19:53	RX	0;255;3;0;22;288110
    2017-04-23 11:20:03	RX	0;255;3;0;22;298116
    

    However, I found out that the DI00 (=IRQ) on the RFM69 never gives a rising edge...
    I'm suspecting that the RFM69 is not being initialised properly... I added some debugging in the RFM69 code to see what registers are being written and read:

    mysgw: Starting gateway...
    mysgw: Protocol version - 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: RFM69:INIT
    mysgw: RFM69:INIT:PIN,CS=24,IQP=22,IQN=22
    mysgw: FtW:RFM69:write register, reg=0x01, value=4
    mysgw: FtW:RFM69:write register, reg=0x02, value=0
    mysgw: FtW:RFM69:write register, reg=0x03, value=2
    mysgw: FtW:RFM69:write register, reg=0x04, value=64
    mysgw: FtW:RFM69:write register, reg=0x05, value=3
    mysgw: FtW:RFM69:write register, reg=0x06, value=51
    mysgw: FtW:RFM69:write register, reg=0x18, value=136
    mysgw: FtW:RFM69:write register, reg=0x19, value=66
    mysgw: FtW:RFM69:write register, reg=0x26, value=7
    mysgw: FtW:RFM69:write register, reg=0x28, value=16
    mysgw: FtW:RFM69:write register, reg=0x29, value=220
    mysgw: FtW:RFM69:write register, reg=0x2c, value=0
    mysgw: FtW:RFM69:write register, reg=0x2d, value=3
    mysgw: FtW:RFM69:write register, reg=0x2e, value=136
    mysgw: FtW:RFM69:write register, reg=0x2f, value=45
    mysgw: FtW:RFM69:write register, reg=0x30, value=101
    mysgw: FtW:RFM69:write register, reg=0x37, value=212
    mysgw: FtW:RFM69:write register, reg=0x38, value=66
    mysgw: FtW:RFM69:write register, reg=0x39, value=255
    mysgw: FtW:RFM69:write register, reg=0x3a, value=255
    mysgw: FtW:RFM69:write register, reg=0x3c, value=5
    mysgw: FtW:RFM69:write register, reg=0x3d, value=16
    mysgw: FtW:RFM69:write register, reg=0x6f, value=48
    mysgw: FtW:RFM69:write register, reg=0x07, value=217
    mysgw: FtW:RFM69:write register, reg=0x08, value=0
    mysgw: FtW:RFM69:write register, reg=0x09, value=0
    mysgw: FtW:RFM69:write register, reg=0x01, value=4
    mysgw: FtW:RFM69:read register, reg=0x27, value=128
    mysgw: FtW:RFM69:read register, reg=0x3d, value=16
    mysgw: FtW:RFM69:write register, reg=0x3d, value=16
    mysgw: FtW:RFM69:write register, reg=0x11, value=87
    mysgw: RFM69:PTX:LEVEL=5 dBm
    mysgw: FtW:RFM69:read register, reg=0x02, value=0
    mysgw: FtW:RFM69:read register, reg=0x03, value=2
    mysgw: FtW:RFM69:read register, reg=0x04, value=64
    mysgw: FtW:RFM69:read register, reg=0x05, value=3
    mysgw: FtW:RFM69:read register, reg=0x06, value=51
    mysgw: FtW:RFM69:read register, reg=0x30, value=101
    mysgw: FTW attachInterrupt: gpioPin=25 mode=3
    mysgw: TSM:INIT:TSP OK
    mysgw: TSM:INIT:GW MODE
    mysgw: FtW:RFM69:write register, reg=0x39, value=0
    mysgw: TSM:READY:ID=0,PAR=0,DIS=0
    mysgw: MCO:REG:NOT NEEDED
    mysgw: FtW:RFM69:write register, reg=0x25, value=64
    mysgw: FtW:RFM69:write register, reg=0x13, value=26
    mysgw: FtW:RFM69:write register, reg=0x5a, value=85
    mysgw: FtW:RFM69:write register, reg=0x5c, value=112
    mysgw: FtW:RFM69:read register, reg=0x3d, value=16
    mysgw: FtW:RFM69:write register, reg=0x3d, value=20
    mysgw: FtW:RFM69:write register, reg=0x01, value=16
    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: gatewayTransportAvailable
    mysgw: Client 0: 0;0;3;0;2;Get Version
    mysgw: gatewayTransportAvailable
    mysgw: Client 0: 0;0;3;0;18;PING
    mysgw: gatewayTransportAvailable
    mysgw: Client 0: 0;0;3;0;18;PING
    mysgw: gatewayTransportAvailable
    mysgw: Client 0: 0;0;3;0;18;PING
    


  • Can't get the RFM69HW to work on RPI. I tried the following:

    1. I installed on an old RPI1 (clean Rasbian install). Same results as on my Domoticz RPI-3.
    2. Setup the original RPI3 as a node, using the 2.2.0-beta code. I verified that in this case the RFM69HW actually transmits (I can hear it burst on 868.000 MHz). However, it is unable to connect to an existing Arduino 2.1.1 gateway.
    3. I built an Arduino 2.2.0-beta serial gateway. Even then, the RPI as a node fails to connect to the 2.2.0-beta serial gateway.
    4. I built an Arduino 2.2.0-beta node. This node is able to connect to the above gateway.

    There seems to be something different in the radio network between the RFM69HW on the RPI and the RFM69HW on the Arduino. But I'm unable to find out what the difference is :-(.

    The RPI RFM69HW will not communicate with the Arduino RFM69HW. When the RPI is a gateway, the RFM69HW will not physically interrupt when another node is trying to connect. When the RPI is a node, the RFM69HW on the ARduino does not interrupt either.

    Did anyone get the RFM69HW working on the RPI? I'd really like to get this beautiful piece of code working!


  • Mod

    I have to ask a stupid question : did you use a logic converter between rpi and rfm69 radio?



  • @gohan There are no stupid questions, right :-)? But perhaps a stupid answer: no, I did not use any logic convertors. The RFM69 is 3.3V and as far as I know, so are the GPIO pins on the RPI. But I might be mistaken, of course... Should I use logic convertors?

    At the moment I have no idea where it fails. Perhaps I need to give it a rest for a couple of days to think it over...

    I followed the steps as given on the web site (git branch development). Connected the RFM radio (7 wires: Vcc, GND, MOSI, MISO, SCK, NSS, DI00). Only modified MyConfig.h with regard to the NETWORKID (100 --> 101; my 'production' MySensors runs at 100) and enabling "MY_DEBUG_VERBOSE_RFM69". I configured with:

    % ./configure --my-debug=enable --my-config-file=/usr/local/etc/mysensors.dat --my-gateway=ethernet --my-transport=rfm69 --my-rfm69-frequency=868 --my-is-rfm69hw
    % make -j 4
    % sudo bin/mysgw -d
    

  • Mod


  • Mod

    @ftw64 that configure command looks like an ethernet gateway. Could you post the configure command for your "RPI as a node" as well?


  • 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


Log in to reply
 

Suggested Topics

  • 3
  • 5
  • 109
  • 164
  • 109
  • 584

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts