Skip to content
  • 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
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

💬 Building a Raspberry Pi Gateway

Scheduled Pinned Locked Moved Announcements
1.1k Posts 173 Posters 422.5k 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.
  • M Offline
    M Offline
    mvader
    wrote on last edited by mvader
    #41

    I noticed the "improve rf24" section was added. and it mentioned high cpu.
    i set mine up a few weeks ago and am not using an interrupt on my radio.
    my cpu is only 2-3%
    I'm curious if the high cpu problem is seen by many?

    also a 2nd question.
    if i were to add an interrupt. how can i "re-configure" my setup to include that new -switch
    or do i have to remove everything and re-clone from git hub and start over?

    1 Reply Last reply
    0
    • shfgS Offline
      shfgS Offline
      shfg
      wrote on last edited by
      #42

      Thanks for this excellent port. I'm having an issue running it as an MQTT gateway on the RPi (Model A). It compiles without hassles, but cant make a successful MQTT connection. I get the following:

      mysGateway: Starting gateway...
      mysGateway: Protocol version - 2.0.1-beta
      mysGateway: MCO:BGN:INIT GW,CP=RNNG---,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: Attempting MQTT connection...
      mysGateway: connected to 127.0.0.1
      mysGateway: Attempting MQTT connection...
      mysGateway: connected to 127.0.0.1
      mysGateway: Attempting MQTT connection...
      mysGateway: connected to 127.0.0.1

      ... those attempts recurring every 15 seconds or so, and in that time, no other activity is processed.
      From the code, I would have expected 'MQTT connected' rather than 'connected to 127.0.0.1'?

      I have mosquitto running on the pi in this case - which is working perfectly in other tests. Both serial and ethernet gateway modes compile and run perfectly, only the mqtt mode not working.
      Has anyone else had a similar issue?

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

        @marceloaqno what about gpio interrupts, is that supported?

        I'm thinking to use a RPi as a pulse counter for water, electricity and gas with no radio, just ethernet or mqtt.
        In combination with a I2C display, this could be a nice project ;)

        Greetz,
        Eric

        1 Reply Last reply
        0
        • Christian SimonsenC Offline
          Christian SimonsenC Offline
          Christian Simonsen
          wrote on last edited by
          #44

          Hi,

          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. And I have followed the steps under "install and build", which seem to have worked fine. I didn't make any changes to the conf file. However now Im stuck. How do I setup the Raspberry Pi with the NRF24L01+ as a gateway in the MyController Gateway setup page in Safari?

          M 1 Reply Last reply
          0
          • shfgS shfg

            Thanks for this excellent port. I'm having an issue running it as an MQTT gateway on the RPi (Model A). It compiles without hassles, but cant make a successful MQTT connection. I get the following:

            mysGateway: Starting gateway...
            mysGateway: Protocol version - 2.0.1-beta
            mysGateway: MCO:BGN:INIT GW,CP=RNNG---,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: Attempting MQTT connection...
            mysGateway: connected to 127.0.0.1
            mysGateway: Attempting MQTT connection...
            mysGateway: connected to 127.0.0.1
            mysGateway: Attempting MQTT connection...
            mysGateway: connected to 127.0.0.1

            ... those attempts recurring every 15 seconds or so, and in that time, no other activity is processed.
            From the code, I would have expected 'MQTT connected' rather than 'connected to 127.0.0.1'?

            I have mosquitto running on the pi in this case - which is working perfectly in other tests. Both serial and ethernet gateway modes compile and run perfectly, only the mqtt mode not working.
            Has anyone else had a similar issue?

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

            @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 2 Replies Last reply
            0
            • Christian SimonsenC Christian Simonsen

              Hi,

              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. And I have followed the steps under "install and build", which seem to have worked fine. I didn't make any changes to the conf file. However now Im stuck. How do I setup the Raspberry Pi with the NRF24L01+ as a gateway in the MyController Gateway setup page in Safari?

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

              @Christian-Simonsen If you are using the default build options for the RPi gateway, in MyController (Resources -> Add gateway) choose Ethernet for the type and enter your RPi ip address in the Host name field.

              Christian SimonsenC 1 Reply Last reply
              0
              • T Offline
                T Offline
                Toyman
                wrote on last edited by
                #47

                Is it compatible with pre-2.0 versions eg 1.5?

                1 Reply Last reply
                0
                • M marceloaqno

                  @Christian-Simonsen If you are using the default build options for the RPi gateway, in MyController (Resources -> Add gateway) choose Ethernet for the type and enter your RPi ip address in the Host name field.

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

                  @Christian-Simonsen said:

                  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. And I have followed the steps under "install and build", which seem to have worked fine. I didn't make any changes to the conf file. However now Im stuck. How do I setup the Raspberry Pi with the NRF24L01+ as a gateway in the MyController Gateway setup page in Safari?

                  Thanks that did the trick

                  1 Reply Last reply
                  0
                  • Christian SimonsenC Offline
                    Christian SimonsenC Offline
                    Christian Simonsen
                    wrote on last edited by Christian Simonsen
                    #49

                    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 1 Reply Last reply
                    0
                    • E Offline
                      E Offline
                      ericvdb
                      wrote on last edited by
                      #50

                      @marceloaqno

                      Today i tried to use the sketch Water Meter Pulse Sensor in mysGateway.cpp but i run into alot of errors, you have any idea?

                      mysGateway.cpp:

                      /**
                       * The MySensors Arduino library handles the wireless radio link and protocol
                       * between your home built sensors/actuators and HA controller of choice.
                       * The sensors forms a self healing radio network with optional repeaters. Each
                       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                       * network topology allowing messages to be routed to nodes.
                       *
                       * Created by Marcelo Aquino <marceloaqno@gmail.org>
                       * Copyleft (c) 2016, Marcelo Aquino
                       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                       *
                       * Documentation: http://www.mysensors.org
                       * Support Forum: http://forum.mysensors.org
                       *
                       * This program is free software; you can redistribute it and/or
                       * modify it under the terms of the GNU General Public License
                       * version 2 as published by the Free Software Foundation.
                       */
                       
                      #include <iostream>
                      #include <cstdio>
                      #include <unistd.h>
                      
                      // For more options run ./configure --help
                      
                      // Config file
                      //#define MY_LINUX_CONFIG_FILE "/etc/mysensors.dat"
                      
                      // How many clients should be able to connect to this gateway (default 1)
                      #define MY_GATEWAY_MAX_CLIENTS 10
                      
                      // Serial config
                      // Enable this if you are using an Arduino connected to the USB
                      //#define MY_LINUX_SERIAL_PORT "/dev/ttyACM0"
                      // Enable this if you need to connect to a controller running on the same device
                      //#define MY_IS_SERIAL_PTY
                      // Choose a symlink name for the PTY device
                      //#define MY_LINUX_SERIAL_PTY "/dev/ttyMySensorsGateway"
                      // Grant access to the specified system group for the serial device
                      //#define MY_LINUX_SERIAL_GROUPNAME "tty"
                      
                      // MQTT options
                      //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68
                      //#define MY_PORT 1883
                      //#define MY_MQTT_CLIENT_ID "mysensors-1"
                      //#define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
                      //#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
                      
                      // Enable these if your MQTT broker requires usenrame/password
                      //#define MY_MQTT_USER "username"
                      //#define MY_MQTT_PASSWORD "password"
                      
                      // Flash leds on rx/tx/err
                      //#define MY_DEFAULT_ERR_LED_PIN 12  // Error LED pin
                      //#define MY_DEFAULT_RX_LED_PIN  16  // Receive LED pin
                      //#define MY_DEFAULT_TX_LED_PIN  18  // Transmit LED pin
                      // Inverse the blinking feature
                      //#define MY_WITH_LEDS_BLINKING_INVERSE
                      
                      #include <MySensors.h>
                      
                      #define DIGITAL_INPUT_SENSOR 26                  // The digital input you attached your sensor.  (Only 2 and 3 generates interrupt!)
                      
                      #define PULSE_FACTOR 1000                       // Nummber of blinks per m3 of your meter (One rotation/liter)
                      
                      #define SLEEP_MODE false                        // flowvalue can only be reported when sleep mode is false.
                      
                      #define MAX_FLOW 40                             // Max flow (l/min) value to report. This filters outliers.
                      
                      #define CHILD_ID 1                              // Id of the sensor child
                      
                      unsigned long SEND_FREQUENCY = 30000;           // Minimum time between send (in milliseconds). We don't want to spam the gateway.
                      
                      MyMessage flowMsg(CHILD_ID,V_FLOW);
                      MyMessage volumeMsg(CHILD_ID,V_VOLUME);
                      MyMessage lastCounterMsg(CHILD_ID,V_VAR1);
                      
                      double ppl = ((double)PULSE_FACTOR)/1000;        // Pulses per liter
                      
                      volatile unsigned long pulseCount = 0;   
                      volatile unsigned long lastBlink = 0;
                      volatile double flow = 0;  
                      bool pcReceived = false;
                      unsigned long oldPulseCount = 0;
                      unsigned long newBlink = 0;   
                      double oldflow = 0;
                      double volume =0;                     
                      double oldvolume =0;
                      unsigned long lastSend =0;
                      unsigned long lastPulse =0;
                      
                      void onPulse()     
                      {
                        if (!SLEEP_MODE)
                        {
                          unsigned long newBlink = micros();   
                          unsigned long interval = newBlink-lastBlink;
                      
                          if (interval!=0)
                          {
                            lastPulse = millis();
                            if (interval<500000L) {
                              // Sometimes we get interrupt on RISING,  500000 = 0.5sek debounce ( max 120 l/min)
                              return;   
                            }
                            flow = (60000000.0 /interval) / ppl;
                          }
                          lastBlink = newBlink;
                        }
                        pulseCount++; 
                      }
                      
                      void setup() {
                        attachInterrupt(DIGITAL_INPUT_SENSOR, onPulse, FALLING); 
                      }
                      
                      void presentation() {
                        // Present locally attached sensors here  
                        // Send the sketch version information to the gateway and Controller
                        sendSketchInfo("Water Meter", "1.1");
                      
                        // Register this device as Waterflow sensor
                        present(CHILD_ID, S_WATER);  
                      }
                      
                      void loop() {
                        // Send locally attached sensors data here
                        unsigned long currentTime = millis();
                      
                          // Only send values at a maximum frequency or woken up from sleep
                        if (SLEEP_MODE || (currentTime - lastSend > SEND_FREQUENCY))
                        {
                          lastSend=currentTime;
                      
                          if (!pcReceived) {
                            //Last Pulsecount not yet received from controller, request it again
                            request(CHILD_ID, V_VAR1);
                            return;
                          }
                      
                          if (!SLEEP_MODE && flow != oldflow) {
                            oldflow = flow;
                      
                            Serial.print("l/min:");
                            Serial.println(flow);
                      
                            // Check that we dont get unresonable large flow value. 
                            // could hapen when long wraps or false interrupt triggered
                            if (flow<((unsigned long)MAX_FLOW)) {
                              send(flowMsg.set(flow, 2));                   // Send flow value to gw
                            }  
                          }
                      
                          // No Pulse count received in 2min 
                          if(currentTime - lastPulse > 120000){
                            flow = 0;
                          } 
                      
                          // Pulse count has changed
                          if ((pulseCount != oldPulseCount)||(!SLEEP_MODE)) {
                            oldPulseCount = pulseCount;
                      
                            Serial.print("pulsecount:");
                            Serial.println(pulseCount);
                      
                            send(lastCounterMsg.set(pulseCount));                  // Send  pulsecount value to gw in VAR1
                      
                            double volume = ((double)pulseCount/((double)PULSE_FACTOR));     
                            if ((volume != oldvolume)||(!SLEEP_MODE)) {
                              oldvolume = volume;
                      
                              Serial.print("volume:");
                              Serial.println(volume, 3);
                      
                              send(volumeMsg.set(volume, 3));               // Send volume value to gw
                            } 
                          }
                        }
                        if (SLEEP_MODE) {
                          sleep(SEND_FREQUENCY);
                        }
                      }
                      

                      ./configure --my-debug=enable --my-gateway=ethernet --my-radio=none --my-port=5003

                      [SECTION] Detecting target machine.
                      [OK] machine detected: SoC=BCM2835, Type=RPi, CPU=armv6l, REV=000e.
                      [OK] init system detected: systemd
                      [SECTION] Saving configuration.
                      [SECTION] Cleaning previous builds.
                      [OK] Finished.
                      

                      make:

                      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:37: error: âmicrosâ was not declared in this scope
                           unsigned long newBlink = micros();
                                                           ^
                      examples_linux/mysGateway.cpp: In function âvoid loop()â:
                      examples_linux/mysGateway.cpp:166:41: error: call of overloaded âset(volatile long unsigned int&)â is ambiguous
                             send(lastCounterMsg.set(pulseCount));                  // Send  pulsecount value to gw in VAR1
                                                               ^
                      examples_linux/mysGateway.cpp:166:41: note: candidates are:
                      In file included from ./MySensors.h:319:0,
                                       from examples_linux/mysGateway.cpp:60:
                      ./core/MyMessage.cpp:222:12: note: MyMessage& MyMessage::set(const char*) <near match>
                       MyMessage& MyMessage::set(const char* value) {
                                  ^
                      ./core/MyMessage.cpp:222:12: note:   no known conversion for argument 1 from âvolatile long unsigned intâ to âconst char*â
                      ./core/MyMessage.cpp:234:12: note: MyMessage& MyMessage::set(bool)
                       MyMessage& MyMessage::set(bool value) {
                                  ^
                      ./core/MyMessage.cpp:241:12: note: MyMessage& MyMessage::set(uint8_t)
                       MyMessage& MyMessage::set(uint8_t value) {
                                  ^
                      ./core/MyMessage.cpp:256:12: note: MyMessage& MyMessage::set(uint32_t)
                       MyMessage& MyMessage::set(uint32_t value) {
                                  ^
                      ./core/MyMessage.cpp:263:12: note: MyMessage& MyMessage::set(int32_t)
                       MyMessage& MyMessage::set(int32_t value) {
                                  ^
                      ./core/MyMessage.cpp:270:12: note: MyMessage& MyMessage::set(uint16_t)
                       MyMessage& MyMessage::set(uint16_t value) {
                                  ^
                      ./core/MyMessage.cpp:277:12: note: MyMessage& MyMessage::set(int16_t)
                       MyMessage& MyMessage::set(int16_t value) {
                                  ^
                      examples_linux/mysGateway.cpp:180:25: error: call of overloaded âsleep(long unsigned int&)â 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
                      
                      1 Reply Last reply
                      0
                      • E Offline
                        E Offline
                        ericvdb
                        wrote on last edited by
                        #51

                        @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 1 Reply Last reply
                        0
                        • 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
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          8

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


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

                                          • Don't have an account? Register

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