💬 Building a Raspberry Pi Gateway



  • I'm a bit confused about gateway and controller. Can I use a Pi as both gateway and controller?


  • Admin

    @gvorster said:

    I'm a bit confused about gateway and controller. Can I use a Pi as both gateway and controller?

    Yes!



  • I'm using the virtual serial port option and one of the things that I notice is that the port gets created where the tty group only has write access.

    pi@raspberrypi:/dev/pts $ ls -l
    total 0
    crw--w---- 1 root tty  136, 0 Oct 10 18:49 0
    

    I can change it manually but if I reboot the raspberry pi it goes back to write access only. How do I get it to be created with 'rw' access?



  • Nevermind....When I set "--my-serial-groupname=tty" in ./configure it works.



  • Where do I put the security stuff for the signing?


  • Hardware Contributor

    @NiklasO

    Signing is not yet supported in the current Raspi Gateway.



  • @GertSanders said:

    @NiklasO

    Signing is not yet supported in the current Raspi Gateway.

    Ok, thanks.
    I now see that in this thread. Did not see the earlier discussion in the comments on the main page. Hope to see support soon.

    I have disabled signing for the time being but I want it on ofc. 😉



  • what's about RS485 transport on raspberry pi? especially from wired RS485 mysensors network to MQTT



  • Can you use the RP as gateway and also as controller?



  • @raulandresmoch
    Sure. I use this with Domoticz on my Pi.
    "MySensors Gateway with LAN interface" as hardware pointing to 127.0.0.1:5003
    Also, I can connect with other controller software like MYSController from my other computers to my Pi-IP at port 5003.


  • Code Contributor

    @b0rmann I could add support for RS485, but I'll need your help to test because I don't have the hardware.



  • The line above
    ./examples_linux/mysGatewaymsyGateway -h
    needs to be corrected to
    ./examples_linux/mysGateway -h
    Thanks for all the hard work! Awesome!


  • Mod

    @DrJeff Thanks for noticing. It should be fixed now.



  • @marceloaqno

    i am ready. after compiled and upload example node sketch i have on rs485 to usb convertor (/dev/ttyUSB0) output nice mysensors data:

    01 FF 00 58 07 02 FF FF - FF 02 03 07 FF 03 66 04
    01 FF 00 58 07 02 FF FF - FF 02 03 07 FF 03 66 04
    01 FF 00 58 07 02 FF FF - FF 02 03 07 FF 03 66 04
    01 FF 00 58 07 02 FF FF - FF 02 03 07 FF 03 66 04
    01 FF 00 58 07 02 FF FF - FF 02 03 07 FF 03 66 04
    01 FF 00 58 07 02 FF FF - FF 02 03 07 FF 03 66 04
    01 FF 00 58 07 02 FF FF - FF 02 03 07 FF 03 66 04
    01 FF 00 58 07 02 FF FF - FF 02 03 07 FF 03 66 04
    

    testing playground photo: 0_1476563966730_playground.jpg



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



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



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



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


  • Code Contributor

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


  • Code Contributor

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



  • Is it compatible with pre-2.0 versions eg 1.5?



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



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



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


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


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


  • Admin

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


  • Code Contributor

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



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



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



  • @marceloaqno

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



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



  • This post is deleted!

  • Code Contributor

    @Christian-Simonsen start the gateway with debug enabled:

    mysGateway -d
    


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



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


  • Code Contributor

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



  • @marceloaqno

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



  • @marceloaqno I have it completely working now. 😆 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() 😉


  • Code Contributor

    @ericvdb Congrats! oops, sorry about my mistake.



  • This post is deleted!


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


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


  • Code Contributor

    @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
    

  • Code Contributor

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



  • @marceloaqno said:

    cd MySensors
    ./configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyMySensorsGateway --my

    Thanks for letting me know, didn't know that not running it from the specific folder would have an impact.

    I reconfigured it as you recommended. and restarted the gateway, with the result below.

    pi@raspberrypi:~/MySensors $ sudo ./examples_linux/mysGateway -d
    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: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
    mysGateway: !TSF:MSG:LEN,0!=7
    mysGateway: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
    mysGateway: !TSF:MSG:LEN,0!=7
    mysGateway: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
    mysGateway: !TSF:MSG:LEN,0!=7
    mysGateway: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
    mysGateway: !TSF:MSG:LEN,0!=7
    mysGateway: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
    mysGateway: !TSF:MSG:LEN,0!=7
    mysGateway: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
    mysGateway: !TSF:MSG:LEN,14!=7
    mysGateway: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
    mysGateway: !TSF:MSG:LEN,0!=7
    mysGateway: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
    mysGateway: !TSF:MSG:LEN,0!=7
    mysGateway: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
    mysGateway: !TSF:MSG:LEN,14!=7
    mysGateway: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
    mysGateway: !TSF:MSG:LEN,0!=7
    

    What is the best way to test if the gateway work? What sketch should I use on the arduino? and how do I see in Terminal that the mysGateway receive the transfer successfully?



  • very interesting data...

    journalctl -u mysgateway --since 13:15 | grep MSG:READ

    Oct 21 13:16:30 pi mysGateway[30406]: TSF:MSG:READ,3-3-0,s=3,c=1,t=23,pt=2,l=2,sg=0:97
    Oct 21 13:16:30 pi mysGateway[30406]: TSF:MSG:READ,3-3-0,s=4,c=1,t=23,pt=2,l=2,sg=0:6
    Oct 21 13:16:30 pi mysGateway[30406]: TSF:MSG:READ,3-10-0,s=3,c=1,t=23,pt=2,l=2,sg=0:97
    Oct 21 13:16:30 pi mysGateway[30406]: TSF:MSG:READ,3-10-0,s=0,c=1,t=0,pt=7,l=5,sg=0:24.6
    Oct 21 13:16:30 pi mysGateway[30406]: TSF:MSG:READ,3-10-0,s=4,c=1,t=23,pt=2,l=2,sg=0:6
    Oct 21 13:16:30 pi mysGateway[30406]: TSF:MSG:READ,3-10-0,s=3,c=1,t=23,pt=2,l=2,sg=0:97
    Oct 21 13:16:30 pi mysGateway[30406]: TSF:MSG:READ,3-3-0,s=0,c=1,t=0,pt=7,l=5,sg=0:12.7
    Oct 21 13:16:31 pi mysGateway[30406]: TSF:MSG:READ,3-10-0,s=0,c=1,t=0,pt=7,l=5,sg=0:12.7
    Oct 21 13:16:31 pi mysGateway[30406]: TSF:MSG:READ,3-10-0,s=4,c=1,t=23,pt=2,l=2,sg=0:6
    Oct 21 13:17:17 pi mysGateway[30406]: TSF:MSG:READ,2-2-0,s=251,c=1,t=0,pt=7,l=5,sg=0:24.5
    Oct 21 13:17:17 pi mysGateway[30406]: TSF:MSG:READ,2-2-0,s=167,c=1,t=0,pt=7,l=5,sg=0:24.6
    Oct 21 13:17:18 pi mysGateway[30406]: TSF:MSG:READ,2-10-0,s=251,c=1,t=0,pt=7,l=5,sg=0:24.5
    Oct 21 13:17:18 pi mysGateway[30406]: TSF:MSG:READ,3-10-0,s=0,c=1,t=0,pt=7,l=5,sg=0:12.7
    Oct 21 13:17:18 pi mysGateway[30406]: TSF:MSG:READ,2-10-0,s=167,c=1,t=0,pt=7,l=5,sg=0:24.6
    Oct 21 13:17:18 pi mysGateway[30406]: TSF:MSG:READ,2-10-0,s=251,c=1,t=0,pt=7,l=5,sg=0:24.5
    Oct 21 13:17:19 pi mysGateway[30406]: TSF:MSG:READ,10-10-0,s=12,c=1,t=0,pt=7,l=5,sg=0:34
    Oct 21 13:17:19 pi mysGateway[30406]: TSF:MSG:READ,10-10-0,s=14,c=1,t=0,pt=7,l=5,sg=0:24
    

    node 2
    sensor 167 - dht18b20 indoor
    sensor 251 - dht18b20 indoor

    node 3
    sensor 0 - dht18b20 outdoor
    sensor 3 - light (0..100)
    sensor 4 - light (0..100)

    questions:
    why node 2 and node 3 send messages directly and via node 10?

    24.6 - is actual value from 2/251, but gateway receive this value from 3/0 How is it possible?

    Oct 21 13:16:30 pi mysGateway[30406]: TSF:MSG:READ,3-10-0,s=0,c=1,t=0,pt=7,l=5,sg=0:24.6
    


  • Hi,

    Is there anyone here that can give me some one-to-one support this evening to setup the Raspberry Pi + NRF24L01 as a gateway with MyController, and a Arduino Uno + NRF24L01 as Sensor node. I'm stuck after trying various things over the past week, so looks like I need some additional skills/knowledge to get the first setup working.

    Maybe we can use Skype or some other medium. I will gladly pay a bit for this support if anyone is interested. I have some free time from 18:00 CET - 23:30 CET today...



  • hi, the gateway works but how display sensors in domoticz?
    Thank you very much



  • @nico you need a sensor to send data to GW and assuming you have GW added to Domoticz, Domoticz will add up corresponding values to "Devices"



  • I have a gateway and 1 sensor ,obviously.
    I have added serial GW but anyone sensor appear, i'm sure that the sensor works, and the gateway also (see with the command mysGateway -d).
    Can you have any idea ? Thank you



  • @nico I would suggest you open up a different post in the Troubleshooting section regarding this matter
    1 post GW and sensor logs
    2. How do you know that the GW was added to Domoticz? Logs please?



  • @Christian-Simonsen

    You can pretty much test out using any of the arduino examples here:

    https://github.com/mysensors/MySensors/tree/development/examples

    Each one will present itself to the gateway when it starts up and you will see the presentation in the debug log. Make sure to run:

    https://github.com/mysensors/MySensors/tree/development/examples/ClearEepromConfig

    on the arduino first to make sure it starts with a fresh eeprom. After you select an Arduino sketch to test it with (seriously it doesn't matter which one you try) make sure to look at the sketch and add:

    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    #define MY_NODE_ID 4
    

    For MY_NODE_ID you can select any number. Just make sure that each new sensor node that you create has a different node number so like start out at MY_NODE_ID 1 and when you make another sensor node you can #define MY_NODE_ID 2 and so on.

    Next load it up to the Arduino, open the serial monitor, and see what happens. If you watch the serial monitor on the arduino you will see it present itself to the gateway and then you can confirm it in the debug log on the raspberry pi.

    I think it is pretty normal to have the problems you are having. I uninstalled and reinstalled the gateway 3 times on the Raspberry Pi before I finally got it all figured out. Once you get it running it is a glorious thing.


  • Code Contributor

    @Christian-Simonsen

    mysGateway: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
    mysGateway: !TSF:MSG:LEN,0!=7
    

    looks like a power issue with the nrf24 module.


  • Code Contributor

    @b0rmann Can you provide a full debug log of all involved nodes?



  • Can I attach one or more DallasTemp sensors on the Raspberry Pi gateway?



  • @marceloaqno said:

    @Christian-Simonsen

    mysGateway: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
    mysGateway: !TSF:MSG:LEN,0!=7
    

    looks like a power issue with the nrf24 module.

    Ok,

    I've tested with the Voltmeter and the NRF24L01 module do get a steady 3.26 V. Both the gateway module and the Arduino sensor node...

    Im now building a few extra sensor nodes, so I can test without the Raspberry pi. Hopefully I can atleast get them talking based on Arduinos first. Before testing the Raspberry Pi.


  • Mod

    @Patrik-Söderström said:

    Can I attach one or more DallasTemp sensors on the Raspberry Pi gateway?

    I haven't seen anyone doing anything similar so it might require some work. But almost anything is possible given enough work 🙂



  • Has anyone else had an issue with getting a sensor node to reconnect after a lost connection? I can see it attempting to reconnect but even though it is back within range of the gateway it won't reestablish the connection. If I reset the node it re-establishes the connection without any problem. This is the cycle that it gets stuck in:

    TSM:FPAR
    TSP:MSG:SEND 3-3-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-3 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=3)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    !TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=fail:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 3-3-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    !TSP:SEND:TNR
    !TSP:SEND:TNR
    !TSP:SEND:TNR
    !TSP:SEND:TNR
    !TSP:SEND:TNR
    !TSP:SEND:TNR
    TSM:FPAR
    TSP:MSG:SEND 3-3-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-3 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=3)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    !TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=fail:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 3-3-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    !TSP:SEND:TNR
    !TSP:SEND:TNR
    !TSP:SEND:TNR
    !TSP:SEND:TNR
    !TSP:SEND:TNR
    !TSP:SEND:TNR```


  • @Christian-Simonsen multimeter will not detect issues with the power feed (noise or unstable). It just says that you voltage under zero load is 3.3V.



  • Appears things are changing, please update wiki:
    Warning: --my-radio is deprecated, please use --my-transport



  • @mfalkvidd Alright 🙂 The thing is that I have my Raspberry Pi as a Gateway today near my server rack and would like to measure the temperatur. Maybe I just get a Nano to do the work for me. Just would have been great to use the Raspberry.


  • Mod

    @Patrik-Söderström You can probably connect a temperature sensor to the gpio pins and have your controller read the sensor (without using MySensors)


  • Code Contributor

    @carlyler Thanks for pointing that out.


  • Code Contributor



  • @marceloaqno Yes its 220 uF. It was all I had handy. I read somewhere that this may be a problem specific to the arduino nano. I may give it a try with the pro mini. Although I'm not sure what that may have to do with it.

    Edit: I tried the same sketch on an arduino pro mini and it worked fine. When I simulated a loss of connection by walking out of range of the gateway it immediately reestablished the connection when I got back within range. The only difference is that the pro mini is running at 8 mhz whereas the nano runs at 16 mhz. Not sure how that affects things.



  • Hello everyone. Is there a way to reduce the number of Heartbeat messages the gateway produces by itself? Using MYSController to analyze the data traffic, I see every 10 seconds a Heartbeat - would like to reduce this once everything is working as expected to maybe every 5 or 10 minutes...


  • Admin

    @Velo17

    Just sleep longer. It sends one heartbeat every time the node wakes up.



  • @Christian-Simonsen

    I have exactly the same error

    mysGateway: !TSF:MSG:LEN,0!=7

    Have you been able to resolve that problem yet? I have tried multiple radios with different capacitors and powersources grounded to the Raspberry Pi.

    thanks



  • @dopeeye

    Sadly not. I ended up creating an serial gateway (arduino with NRF24L01 and a USB connector) and connected this to the Raspberry Pi, rather than connecting the NRF24L01 directly to the GPIO pins. This worked perfectly straight away.



  • @Christian-Simonsen

    Too stubborn to give up, yet.
    If i find a resolution I will let you know



  • I would like to try this, but my pins19-23 are already used by other hardware. Has anyone tried using the SPI1 Pins?



  • @dopeeye I had this issue and unfortunately changed several things at once and got rid of it. However, one thing I noticed was I had different versions of mySensors in my library directory since I downloaded the examples package. Therefore the sensor was likely compiling on a different version than the Gateway. You might want to check that.

    If you could post more of your logs (sensor and gateway) it might help.



  • @marceloaqno

    When running as a service, is there a way to watch the debug log?



  • Any ETA on support for RFM69 ? Need to extend my coverage 🙂



  • Done:

    1. git clone https://github.com/mysensors/MySensors.git
    2. ./configure --my-gateway=mqtt --my-controller-ip-address=127.0.0.1 --my-mqtt-publish-topic-prefix=mysensors-out --my-mqtt-subscribe-topic-prefix=mysensors-in --my-mqtt-client-id=mygateway1
    3. make.
      Got error:
      In file included from ./MySensors.h:287:0,
      from examples_linux/mysGateway.cpp:70:
      ./drivers/RF24/RF24.cpp: In function âuint8_t RF24_spiMultiByteTransfer(uint8_t, uint8_t*, uint8_t, bool)â:
      ./drivers/RF24/RF24.cpp:65:22: error: âNOPâ was not declared in this scope
      *ptx++ = NOP ;
      ^
      Makefile:46: recipe for target 'examples_linux/mysGateway.o' failed
      make: *** [examples_linux/mysGateway.o] Error 1
      Any idea?

  • Mod

    @alesc looks like this commit in the development branch broke the code.

    Do

    git checkout master
    

    before running configure should get the code to the latest stable release.

    EDIT: Sorry, that won't work because the Raspberry Pi stuff didn't exist when MySensors 2.0 was released. You'll have to do git pull instead, to get tekka's fix.


  • Admin



  • Hi Everyone !
    Big thumb up for the amount of work supplied !!!
    After being more or less successful with openHAB1 I had a go with openHAB2 today, via a online install....
    But no success with the "mysGateway" install : should i go back to serial gateway with an arduino ?
    Thanks a lot for your help



  • @ben999 try again, because it works great. I assume by online install you mean apt-get; I too had trouble when trying this. However, I tried again following @TimO instructions here:
    wiki, then everything came up nicely. I feel it is some permission issue that I have not tried to figure out yet.


  • Code Contributor

    @ericvdb when running as a service, debug messages are masked and aren't shown in the system logs, but it would be a good idea to have a way to connect to gateway perhaps using telnet and watch the logs. I'll work on something.



  • @carlyler
    Thanks a lot for your message, hope is back on my side 🙂
    Actually I had a go with openHABian (i didn't make it clear in my previous message, sorry)
    The install itself couldn't be easier : OS+openHAB installed in one go, just by formatting SD Card with a tiny img file. One hour later and voilà !
    So that could be the source of my trouble?
    I will go with the link you supplied tonight and let you know (lookslike it is a manual install... scary!!)
    Thank you again for your support



  • @ben999 if you have not already, read through the MySensors OH2 thread. I noticed a recent post by @TimO that talks about setting some permissions and that might be the issue. Otherwise, the manual install is not bad as he gives you step-by-step; I am a new to all this and managed to get it to work...



  • @carlyler
    Smashing
    Thanks a lot for that hint... I remember reading that...
    Linux is so damn rigid 😆
    Thank you again for your help



  • Either its not stated or I cannot see it, but i was wondering... Is this version 2 voor de rPi?
    At the moment I am using MySensors version 1.5 with Pimatic as controller. And I would like to use v2.



  • @ben999 Yes, version 2



  • I feel a bit sorry to come back here for my own little troubles...

    1- So i installed openhab2 on RPi3 with a fresh SDCard
    2- I followed tobof 's excellent step-by-step howto
    3- I installed mysGateway
    4- With pi@raspberrypi:~/MySensors $ sudo ./examples_linux/mysGateway -d i can see that my motion sensor and my RPi gateway get on well... they do speak to each other, right ?

    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: TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:1
    mysGateway: TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
    mysGateway: TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:1
    mysGateway: TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:0
    

    5-in things/demo.things" I put this.

    Bridge mysensors:bridge-ser:gateway [ serialPort="/dev/pts/2", sendDelay=200 ] {  }
    

    Right away, it worked (king of the world!) and i could see that bridge in paperUI !!!
    But i got that after a reboot of RPi

    openhab> Failed to connect on port: /dev/pts/2 exception: 
    gnu.io.NoSuchPortException
            at gnu.io.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:273)
            at gnu.io.NRSerialPort.connect(NRSerialPort.java:48)
            at org.openhab.binding.mysensors.protocol.serial.MySensorsSerialConnection.<init>(MySensorsSerialConnection.java:52)
            at org.openhab.binding.mysensors.handler.MySensorsBridgeHandler.initialize(MySensorsBridgeHandler.java:63)
            at org.eclipse.smarthome.core.thing.internal.ThingManager$9$1.call(ThingManager.java:764)
            at org.eclipse.smarthome.core.thing.internal.ThingManager$9$1.call(ThingManager.java:1)
            at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:177)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:745)
    

    Wrong serial port ?

    Juste to make it clear : mysGateway bit of software is the magic that makes RPi believe that there's an arduino acting as a gateway on USB and collects the NRF24 info through GPio ?


  • Mod

    @ben999 said:

    Wrong serial port ?

    Likely 😉
    /dev/pts/x are pseudo-terminals , not serial ports.

    On my (old) Pi running Raspbian the serial port is /dev/ttyAMA0
    You could run something like

    dmesg |grep -i tty
    

    to get an idea of serial ports on your Pi.



  • @Yveaux thanks a lot for your answer. Understanding linux is a slow and painful process 😆

    Here is the output from your command : dmesg |grep -i tty

    pi@raspberrypi:~ $ dmesg |grep -i tty
    [    0.000000] Kernel command line: 8250.nr_uarts=0 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2709.boardrev=0xa02082 bcm2709.serial=0xcc3e67e3 smsc95xx.macaddr=B8:27:EB:3E:67:E3 bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  dwc_otg.lpm_enable=0 console=ttyS0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
    [    0.001337] console [tty1] enabled
    [    1.772114] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
    

    What a mess...
    ttyAMA0 is the one !!!
    Thanks @Yveaux you got me on the right path !!! Goto next step! 😄



  • I just did a fresh install of pimatic and MsGateway on the pi. But pimatic does not seem to get de messages. i started the gateway via the daemon method, is there a way to see if the sensor is reaching the gateway?



  • @b0rmann
    Do you still using the rs485 usb "dongle" to connect the rs485 nodes to the rpi? Do you attached some more nodes to your rs485 rpi Gateway?
    Is it stable?
    How do you do the configuration for it?


  • Code Contributor

    @JahFyahh To view messages being exchanged with the sensors, run the gateway in debug mode:

    mysGateway -d
    


  • @marceloaqno thank you for the reply, I tried that and I receive "mysGateway: acce[t: Bad file descriptor" Any idea what this means?


  • Code Contributor

    @JahFyahh Could you provide the full debug log?



  • Hi team,

    First of all, thanks for this amazing project and this doc.
    I'm trying to use arduino nanos with Raspberry Pi 2 as a gateway: I can get it working when I configure the Raspberry Pi using serial gateway, however, it does not work using MQTT with latest version from git.
    The error message is:
    "mysGateway: accept: Bad file descriptor"

    I followed all explanations given on this page.
    Any idea?
    Thanks again


  • Code Contributor

    @manul Which MQTT broker are you using? Did you try to update it?



  • I wanted to use the mysGateway with a USB/RS485 converter.

    Here is my config: ./configure --my-gateway=ethernet --my-port=5003 --my-transport=rs485 --my-rs485-serial-port=/dev/ttyUSB0 my-rs485-baudrate=57600

    make does it's job, but after i start the gateway it says:
    mysGateway: Starting gateway....
    mysGateway: Protocol version - 2.0.1-beta
    mysGateway: MCO:BGN:INIT GW,CP=RSNG---,VER=2.0.1-beta
    mysGateway: TSM:INIT
    mysGateway: TSM:INIT:TSP OK
    mysGateway: TSM:INIT: GW Mode
    mysGateway: TSM:READY

    after that it stopped to work.

    Whats wrong in my configuration?


  • Code Contributor

    @hausinger Have you checked if /dev/ttyUSB0 is receiving any data?


  • Code Contributor

    The RPi port has just received a new update that changes some important things related to the location and name of the gateway binary and services:

    mysGateway was renamed to mysgw
    mysgateway service was renamed to mysgw

    Now, after successfully running the make command, you will find the gateway file under ./bin/mygw

    Also, before installing the new version you need to manually remove the old one:

    If you are using systemd

    sudo systemctl disable mysgateway.service
    sudo rm /etc/systemd/system/mysgateway.service
    sudo rm /usr/local/bin/mysGateway
    

    If you are using sysvinit

    sudo update-rc.d -f mysgateway remove
    sudo rm /etc/init.d/mysgateway
    sudo rm /usr/local/bin/mysGateway
    


  • @marceloaqno said:

    @hausinger Have you checked if /dev/ttyUSB0 is receiving any data?

    Thank you for your answer. I don't know, how to check that? The wiring to my nodes is correct, the serial port is correct (dmesg says that).
    Could you confirm, that my configuration from my last post is correct?


Log in to reply
 

Suggested Topics

  • 3
  • 109
  • 2
  • 584
  • 347
  • 10

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts