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 428.3k 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.
  • T Offline
    T Offline
    Toyman
    wrote on last edited by
    #52

    I probably miss something, but why are trying to compile the arduino sketch on Raspberry Pi???

    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #53

      @ericvdb

      As @Toyman implies, we haven't ported the full Arduino environment here. This should mainly be used for running the Serial/Ethernet gateway directly on your RPi.

      You cannot just run any MySensors example without risking to make heavy adaptations/implementation on your own.

      1 Reply Last reply
      0
      • E ericvdb

        @marceloaqno

        i was able to get a bit further by replacing all "unsigned long" declarations with "uint"

        Remains unsolved:

        root@raspberrypi:/downloads/MySensors# make
        cc  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/log.o drivers/Linux/log.c
        g++ -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DMY_PORT=5003  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/noniso.o drivers/Linux/noniso.cpp
        g++ -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DMY_PORT=5003  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/Print.o drivers/Linux/Print.cpp
        g++ -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DMY_PORT=5003  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/EthernetClient.o drivers/Linux/EthernetClient.cpp
        g++ -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DMY_PORT=5003  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/SerialPort.o drivers/Linux/SerialPort.cpp
        g++ -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DMY_PORT=5003  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/Stream.o drivers/Linux/Stream.cpp
        g++ -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DMY_PORT=5003  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/IPAddress.o drivers/Linux/IPAddress.cpp
        g++ -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DMY_PORT=5003  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/compatibility.o drivers/Linux/compatibility.cpp
        g++ -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DMY_PORT=5003  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/SoftEeprom.o drivers/Linux/SoftEeprom.cpp
        g++ -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DMY_PORT=5003  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/EthernetServer.o drivers/Linux/EthernetServer.cpp
        g++ -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -DMY_PORT=5003  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o examples_linux/mysGateway.o examples_linux/mysGateway.cpp
        examples_linux/mysGateway.cpp: In function âvoid onPulse()â:
        examples_linux/mysGateway.cpp:96:28: error: âmicrosâ was not declared in this scope
             uint newBlink = micros();
                                    ^
        examples_linux/mysGateway.cpp: In function âvoid loop()â:
        examples_linux/mysGateway.cpp:180:25: error: call of overloaded âsleep(uint&)â is ambiguous
             sleep(SEND_FREQUENCY);
                                 ^
        examples_linux/mysGateway.cpp:180:25: note: candidates are:
        In file included from examples_linux/mysGateway.cpp:22:0:
        /usr/include/unistd.h:444:21: note: unsigned int sleep(unsigned int)
         extern unsigned int sleep (unsigned int __seconds);
                             ^
        In file included from ./MySensors.h:320:0,
                         from examples_linux/mysGateway.cpp:60:
        ./core/MySensorsCore.cpp:543:8: note: int8_t sleep(uint32_t, bool)
         int8_t sleep(const uint32_t sleepingMS, const bool smartSleep) {
                ^
        Makefile:46: recipe for target 'examples_linux/mysGateway.o' failed
        make: *** [examples_linux/mysGateway.o] Error 1
        
        M Offline
        M Offline
        marceloaqno
        Code Contributor
        wrote on last edited by marceloaqno
        #54

        @ericvdb micros() hasn't been ported, use:

        millis() /1000;
        

        for sleep(), replace:

        sleep(SEND_FREQUENCY);
        

        with

        sleep(SEND_FREQUENCY, false);
        

        Also, if you want to print something don't use Serial.print() or Serial.println(), use printf() or debug().

        Serial.print("l/min:");
        Serial.println(flow);
        

        should be:

        debug("l/min: %f\n", flow);
        

        as @hek said, the main focus now is to be used as a gateway, with time adding sensors will become less problematic.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          ericvdb
          wrote on last edited by
          #55

          @marceloaqno
          I have it almost working. Regarding the interrupt, I have to pull-up to 3.3V the io pin through a resistor of 10k?
          Right now the interrupt isn't firing

          1 Reply Last reply
          0
          • M marceloaqno

            @shfg There were some reports about this problem in the past, do you see any error messages in your mosquitto log?

            @ericvdb yes, you can attach a function to handle an interruption like this:

            uint8_t mode = FALLING;	// Valid options are: CHANGE, FALLING, RISING
            uint8_t physPin = 16;	// Choose a pin that fits your needs
            
            void irqHandler(void)
            {
            	// Process the interrupt
            }
            
            void setup() {
            	attachInterrupt(physPin, irqHandler, mode);
            }
            

            Support for I2C was added in the latest version.

            shfgS Offline
            shfgS Offline
            shfg
            wrote on last edited by
            #56

            @marceloaqno thanks, turned on mosquitto logging and am getting this error on mosquitto:

            1476724216: Invalid protocol "MQTT" in CONNECT from 127.0.0.1.
            1476724216: Socket read error on client (null), disconnecting.

            Tried an alternative mosquitto broker on another server too - same error.

            1 Reply Last reply
            0
            • E Offline
              E Offline
              ericvdb
              wrote on last edited by
              #57

              @marceloaqno

              I have it working :smiley: only need to play with the debounce value

              1 Reply Last reply
              1
              • M marceloaqno

                @shfg There were some reports about this problem in the past, do you see any error messages in your mosquitto log?

                @ericvdb yes, you can attach a function to handle an interruption like this:

                uint8_t mode = FALLING;	// Valid options are: CHANGE, FALLING, RISING
                uint8_t physPin = 16;	// Choose a pin that fits your needs
                
                void irqHandler(void)
                {
                	// Process the interrupt
                }
                
                void setup() {
                	attachInterrupt(physPin, irqHandler, mode);
                }
                

                Support for I2C was added in the latest version.

                shfgS Offline
                shfgS Offline
                shfg
                wrote on last edited by
                #58

                @marceloaqno I finally have the MQTT gateway working after upgrading mosquitto to the latest build... I had installed mosquitto with apt-get under Wheezy which apparently pulled an older version. In retrospect probably should have just upgraded to Jessie from the outset! Working perfectly now (still under wheezy though FWIW)... thanks!

                1 Reply Last reply
                0
                • b0rmannB Offline
                  b0rmannB Offline
                  b0rmann
                  wrote on last edited by
                  #59
                  This post is deleted!
                  M 1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    marceloaqno
                    Code Contributor
                    wrote on last edited by
                    #60

                    @Christian-Simonsen start the gateway with debug enabled:

                    mysGateway -d
                    
                    1 Reply Last reply
                    0
                    • Christian SimonsenC Christian Simonsen

                      Hi,

                      Background: I have a raspberry Pi 2 that I've installed MyController on. This works fine, I can access it via the browser. I have also wired up an NRF24L01+ module to the GPIO pins on the Raspberry Pi. I have also set up the raspberry pi as a gateway in the MyController Gateway setup page in Safari. It found it and it seem to work.

                      However to my question. How do I know if the Raspberry Pi gateway with NRF24L01 work? How can I monitor what the Raspberry Pi gateway receive? Is there a similar way as the "Serial Monitor" that I use in the Arduino application, when accessing Arduino Uno via USB?

                      If there is I need to monitor this via OSX Terminal.

                      jerseyguy1996J Offline
                      jerseyguy1996J Offline
                      jerseyguy1996
                      wrote on last edited by
                      #61

                      @Christian-Simonsen If you don't have debug enabled you could also just use:

                      tail -f /dev/ttyUSB20
                      

                      My port is named ttyUSB20. You should substitute whatever you have named your port.

                      Christian SimonsenC 1 Reply Last reply
                      0
                      • jerseyguy1996J jerseyguy1996

                        @Christian-Simonsen If you don't have debug enabled you could also just use:

                        tail -f /dev/ttyUSB20
                        

                        My port is named ttyUSB20. You should substitute whatever you have named your port.

                        Christian SimonsenC Offline
                        Christian SimonsenC Offline
                        Christian Simonsen
                        wrote on last edited by
                        #62

                        @jerseyguy1996

                        Thanks I'll test it. But it seems like I've jumped over a step or two. Or something isn't working. Nothing happened when I wrote "Make" in Terminal, so I jumped over this step. I guess that might be the problem.

                        Do I have to configure (./configure -help) or can I use the default values when I connect the NRF24L01 to the GPIO pins?

                        1 Reply Last reply
                        0
                        • b0rmannB b0rmann

                          This post is deleted!

                          M Offline
                          M Offline
                          marceloaqno
                          Code Contributor
                          wrote on last edited by
                          #63

                          @b0rmann what happened? Did you fixed the problem you described in your last message?

                          b0rmannB 1 Reply Last reply
                          0
                          • M marceloaqno

                            @b0rmann what happened? Did you fixed the problem you described in your last message?

                            b0rmannB Offline
                            b0rmannB Offline
                            b0rmann
                            wrote on last edited by
                            #64

                            @marceloaqno

                            it's my problem. accidentally disconnected power from nrf24 on running gw

                            1 Reply Last reply
                            0
                            • E Offline
                              E Offline
                              ericvdb
                              wrote on last edited by
                              #65

                              @marceloaqno I have it completely working now. :satisfied: A Raspberry Pi PulseCounter for water/gas/electricity consumption measurements with ethernet/mqtt. I can post my code here if you want.

                              Minor detail:

                              millis() / 1000;
                              

                              should be

                              millis() * 1000;
                              

                              to get micros() ;)

                              M 1 Reply Last reply
                              0
                              • E ericvdb

                                @marceloaqno I have it completely working now. :satisfied: A Raspberry Pi PulseCounter for water/gas/electricity consumption measurements with ethernet/mqtt. I can post my code here if you want.

                                Minor detail:

                                millis() / 1000;
                                

                                should be

                                millis() * 1000;
                                

                                to get micros() ;)

                                M Offline
                                M Offline
                                marceloaqno
                                Code Contributor
                                wrote on last edited by
                                #66

                                @ericvdb Congrats! oops, sorry about my mistake.

                                1 Reply Last reply
                                0
                                • Christian SimonsenC Offline
                                  Christian SimonsenC Offline
                                  Christian Simonsen
                                  wrote on last edited by
                                  #67
                                  This post is deleted!
                                  1 Reply Last reply
                                  0
                                  • Christian SimonsenC Offline
                                    Christian SimonsenC Offline
                                    Christian Simonsen
                                    wrote on last edited by
                                    #68

                                    Seems I'm closing in to working solution. I didn't understand how to use the ./configure element before now. However I ended up with these configurations

                                    pi@raspberrypi:~ $ ./MySensors/configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway --my-radio=nrf24 --my-rf24-irq-pin=15
                                    [SECTION] Detecting target machine.
                                    [OK] machine detected: SoC=BCM2836, Type=Rpi2, CPU=armv7l, REV=a01041.
                                    [OK] init system detected: systemd
                                    [SECTION] Saving configuration.
                                    [SECTION] Cleaning previous builds.
                                    make: *** No rule to make target 'clean'.  Stop.
                                    [OK] Finished.
                                    pi@raspberrypi:~ $ sudo ./MySensors/examples_linux/mysGateway -d
                                    mysGateway: Starting gateway...
                                    mysGateway: Protocol version - 2.0.1-beta
                                    mysGateway: MCO:BGN:INIT GW,CP=RNNG--Q,VER=2.0.1-beta
                                    mysGateway: TSF:LRT:OK
                                    mysGateway: TSM:INIT
                                    mysGateway: TSM:INIT:TSP OK
                                    mysGateway: TSM:INIT:GW MODE
                                    mysGateway: TSM:READY
                                    mysGateway: MCO:REG:NOT NEEDED
                                    mysGateway: MCO:BGN:STP
                                    mysGateway: MCO:BGN:INIT OK,ID=0,PAR=0,DIS=0,REG=1
                                    mysGateway: TSM:READY:NWD REQ
                                    mysGateway: TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
                                    mysGateway: TSF:SRT:OK
                                    
                                    

                                    Based on this it seem to all be ok on the Raspberry Pi side.. So I uploaded the "MockMySensors" sketch to my Arduino Uno with NRF24 connected. Below is the code and failure message I get from the Arduino. Do I need to set a gateway address or something?

                                    Starting sensor (RNNNA-, 2.0.0)
                                    TSM:INIT
                                    TSM:RADIO:OK
                                    TSP:ASSIGNID:OK (ID=254)
                                    TSM:FPAR
                                    TSP:MSG:SEND 254-254-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                    TSM:FPAR
                                    TSP:MSG:SEND 254-254-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                    TSM:FPAR
                                    TSP:MSG:SEND 254-254-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                    TSM:FPAR
                                    TSP:MSG:SEND 254-254-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                    !TSM:FPAR:FAIL
                                    !TSM:FAILURE
                                    TSM:PDT```
                                    M 1 Reply Last reply
                                    0
                                    • NiklasON Offline
                                      NiklasON Offline
                                      NiklasO
                                      wrote on last edited by
                                      #69

                                      Thanks for adding signing.

                                      I want to use my rPi to generate random soft serials for my sensors.
                                      Could all three "gen" commands output the line to put in SecurityPersonalizer.ino like it does when using the "set" commands?

                                      M 1 Reply Last reply
                                      0
                                      • Christian SimonsenC Christian Simonsen

                                        Seems I'm closing in to working solution. I didn't understand how to use the ./configure element before now. However I ended up with these configurations

                                        pi@raspberrypi:~ $ ./MySensors/configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway --my-radio=nrf24 --my-rf24-irq-pin=15
                                        [SECTION] Detecting target machine.
                                        [OK] machine detected: SoC=BCM2836, Type=Rpi2, CPU=armv7l, REV=a01041.
                                        [OK] init system detected: systemd
                                        [SECTION] Saving configuration.
                                        [SECTION] Cleaning previous builds.
                                        make: *** No rule to make target 'clean'.  Stop.
                                        [OK] Finished.
                                        pi@raspberrypi:~ $ sudo ./MySensors/examples_linux/mysGateway -d
                                        mysGateway: Starting gateway...
                                        mysGateway: Protocol version - 2.0.1-beta
                                        mysGateway: MCO:BGN:INIT GW,CP=RNNG--Q,VER=2.0.1-beta
                                        mysGateway: TSF:LRT:OK
                                        mysGateway: TSM:INIT
                                        mysGateway: TSM:INIT:TSP OK
                                        mysGateway: TSM:INIT:GW MODE
                                        mysGateway: TSM:READY
                                        mysGateway: MCO:REG:NOT NEEDED
                                        mysGateway: MCO:BGN:STP
                                        mysGateway: MCO:BGN:INIT OK,ID=0,PAR=0,DIS=0,REG=1
                                        mysGateway: TSM:READY:NWD REQ
                                        mysGateway: TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
                                        mysGateway: TSF:SRT:OK
                                        
                                        

                                        Based on this it seem to all be ok on the Raspberry Pi side.. So I uploaded the "MockMySensors" sketch to my Arduino Uno with NRF24 connected. Below is the code and failure message I get from the Arduino. Do I need to set a gateway address or something?

                                        Starting sensor (RNNNA-, 2.0.0)
                                        TSM:INIT
                                        TSM:RADIO:OK
                                        TSP:ASSIGNID:OK (ID=254)
                                        TSM:FPAR
                                        TSP:MSG:SEND 254-254-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                        TSM:FPAR
                                        TSP:MSG:SEND 254-254-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                        TSM:FPAR
                                        TSP:MSG:SEND 254-254-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                        TSM:FPAR
                                        TSP:MSG:SEND 254-254-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                        !TSM:FPAR:FAIL
                                        !TSM:FAILURE
                                        TSM:PDT```
                                        M Offline
                                        M Offline
                                        marceloaqno
                                        Code Contributor
                                        wrote on last edited by marceloaqno
                                        #70

                                        @Christian-Simonsen you need to be within the MySensors folders to execute commands configure and make.
                                        I recommend you to test that everything is working before using the option --my-rf24-irq-pin=15

                                        Like this:

                                        cd MySensors
                                        ./configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway --my-radio=nrf24
                                        make
                                        sudo ./examples_linux/mysGateway -d
                                        
                                        Christian SimonsenC 1 Reply Last reply
                                        0
                                        • NiklasON NiklasO

                                          Thanks for adding signing.

                                          I want to use my rPi to generate random soft serials for my sensors.
                                          Could all three "gen" commands output the line to put in SecurityPersonalizer.ino like it does when using the "set" commands?

                                          M Offline
                                          M Offline
                                          marceloaqno
                                          Code Contributor
                                          wrote on last edited by
                                          #71

                                          @NiklasO Done (#622). Thanks for the sugestion.

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


                                          15

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 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