Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Announcements
  3. 💬 Building a Raspberry Pi Gateway

💬 Building a Raspberry Pi Gateway

Scheduled Pinned Locked Moved Announcements
1.1k Posts 173 Posters 422.6k 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 marceloaqno

    @frencho I hope to write something this weekend, at least a draft.

    GertSandersG Offline
    GertSandersG Offline
    GertSanders
    Hardware Contributor
    wrote on last edited by
    #12

    @marceloaqno
    looking forward to upgrading my gateway to v2 :-)

    1 Reply Last reply
    0
    • M marceloaqno

      @frencho I hope to write something this weekend, at least a draft.

      frenchoF Offline
      frenchoF Offline
      frencho
      wrote on last edited by
      #13

      @marceloaqno just wondering because I could figure it out looking at your code : does it work with nrf24 And rfm69 or just nrf24?!

      Regardless of your answer you did a great job, that awesome thanks

      Your second life begins when you understand you only have one !

      M 1 Reply Last reply
      0
      • frenchoF frencho

        @marceloaqno just wondering because I could figure it out looking at your code : does it work with nrf24 And rfm69 or just nrf24?!

        Regardless of your answer you did a great job, that awesome thanks

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

        @frencho thanks. Sorry no support for rfm69 yet. I order some rfm69 modules from ebay to play with but they haven't arrived. So I'm waiting to finish some tests.

        H 1 Reply Last reply
        0
        • M marceloaqno

          @frencho thanks. Sorry no support for rfm69 yet. I order some rfm69 modules from ebay to play with but they haven't arrived. So I'm waiting to finish some tests.

          H Offline
          H Offline
          hawk_2050
          wrote on last edited by
          #15

          @marceloaqno I second @frencho's comment, excellent job on getting mainline support for the Raspberry Pi into the MySensors codebase. Thank you for your efforts.

          1 Reply Last reply
          0
          • jerseyguy1996J Offline
            jerseyguy1996J Offline
            jerseyguy1996
            wrote on last edited by
            #16

            Hello, I just installed @marceloaqno wonderful port of the mySensors 2.0 to the raspberry pi MyGatewaySerial. Thank you very much for that! I'm very glad to be using my boards that connect my radio directly to my Raspi! The installation went very smoothly.

            I am having an issue with a few of my messages from my sensor node. My sensor node sends 6 messages. 3 are V-STATUS, 1 is V-TEMP, 1 is V-VAR1, and one is the battery voltage level. The V-TEMP and the 3 V-STATUS messages go through perfectly but the V-VAR1 and the Battery voltage are not reaching the Raspi. This is the output of the node:

            Starting sensor (RNNNA-, 2.0.0)
            TSM:INIT
            TSM:RADIO:OK
            TSP:ASSIGNID:OK (ID=3)
            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=ok:1
            TSP:MSG:READ 0-0-3 s=255,c=3,t=25,pt=1,l=1,sg=0:1
            TSP:MSG:PONG RECV (hops=1)
            TSP:CHKUPL:OK
            TSM:UPL:OK
            TSM:READY
            TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
            TSP:MSG:SEND 3-3-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0
            TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:0
            TSP:MSG:READ 0-0-3 s=255,c=3,t=15,pt=6,l=2,sg=0:0100
            TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=11,pt=0,l=11,sg=0,ft=0,st=ok:Sensor Node
            TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=ok:1.0
            TSP:MSG:SEND 3-3-0-0 s=1,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=ok:
            TSP:MSG:SEND 3-3-0-0 s=2,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=ok:
            TSP:MSG:SEND 3-3-0-0 s=3,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
            TSP:MSG:SEND 3-3-0-0 s=4,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
            TSP:MSG:SEND 3-3-0-0 s=5,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
            Request registration...
            TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2
            TSP:MSG:READ 0-0-3 s=255,c=3,t=27,pt=1,l=1,sg=0:1
            Node registration=1
            Init complete, id=3, parent=0, distance=1, registration=1
              Data = 0 0 0 0 0 0 0 0 0 0  CRC=0
              Temperature = 0.00 Celsius, 32.00 Fahrenheit
            TSP:MSG:SEND 3-3-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:32.00
            !TSP:MSG:SEND 3-3-0-0 s=2,c=1,t=24,pt=3,l=2,sg=0,ft=0,st=fail:0
            TSP:MSG:SEND 3-3-0-0 s=3,c=1,t=2,pt=1,l=1,sg=0,ft=1,st=ok:1
            TSP:MSG:SEND 3-3-0-0 s=4,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=ok:1
            TSP:MSG:SEND 3-3-0-0 s=5,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=ok:1
            !TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=fail:44
            No SensorTSP:MSG:SEND 3-3-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,ft=1,st=ok:0.00
            !TSP:MSG:SEND 3-3-0-0 s=2,c=1,t=24,pt=3,l=2,sg=0,ft=0,st=fail:0
            TSP:MSG:SEND 3-3-0-0 s=3,c=1,t=2,pt=1,l=1,sg=0,ft=1,st=ok:1
            TSP:MSG:SEND 3-3-0-0 s=4,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=ok:1
            TSP:MSG:SEND 3-3-0-0 s=5,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=ok:1
            !TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=fail:60
            

            Notice the failed messages on the "s=2" and "s=255" lines.

            This is what the Raspi receives:

            mysGateway: TSF:MSG:BC
            mysGateway: TSF:MSG:FPAR REQ,ID=3
            mysGateway: TSF:PNG:SEND,TO=0
            mysGateway: TSF:CKU:OK
            mysGateway: TSF:MSG:GWL OK
            mysGateway: TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
            mysGateway: TSF:MSG:READ,3-3-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
            mysGateway: TSF:MSG:PINGED,ID=3,HP=1
            mysGateway: TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1
            mysGateway: TSF:MSG:READ,3-3-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
            mysGateway: TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
            mysGateway: TSF:MSG:READ,3-3-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.0.0
            mysGateway: TSF:MSG:READ,3-3-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0
            mysGateway: TSF:MSG:READ,3-3-0,s=255,c=3,t=11,pt=0,l=11,sg=0:Sensor Node
            mysGateway: TSF:MSG:READ,3-3-0,s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
            mysGateway: TSF:MSG:READ,3-3-0,s=1,c=0,t=6,pt=0,l=0,sg=0:
            mysGateway: TSF:MSG:READ,3-3-0,s=2,c=0,t=6,pt=0,l=0,sg=0:
            mysGateway: TSF:MSG:READ,3-3-0,s=3,c=0,t=3,pt=0,l=0,sg=0:
            mysGateway: TSF:MSG:READ,3-3-0,s=4,c=0,t=3,pt=0,l=0,sg=0:
            mysGateway: TSF:MSG:READ,3-3-0,s=5,c=0,t=3,pt=0,l=0,sg=0:
            mysGateway: TSF:MSG:READ,3-3-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
            mysGateway: TSF:MSG:SEND,0-0-3-3,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
            mysGateway: TSF:MSG:READ,3-3-0,s=1,c=1,t=0,pt=7,l=5,sg=0:32.00
            mysGateway: TSF:MSG:READ,3-3-0,s=3,c=1,t=2,pt=1,l=1,sg=0:1
            mysGateway: TSF:MSG:READ,3-3-0,s=4,c=1,t=2,pt=1,l=1,sg=0:1
            mysGateway: TSF:MSG:READ,3-3-0,s=5,c=1,t=2,pt=1,l=1,sg=0:1
            mysGateway: TSF:MSG:READ,3-3-0,s=1,c=1,t=0,pt=7,l=5,sg=0:0.00
            mysGateway: TSF:MSG:READ,3-3-0,s=3,c=1,t=2,pt=1,l=1,sg=0:1
            mysGateway: TSF:MSG:READ,3-3-0,s=4,c=1,t=2,pt=1,l=1,sg=0:1
            mysGateway: TSF:MSG:READ,3-3-0,s=5,c=1,t=2,pt=1,l=1,sg=0:1
            

            This is the code running on the sensor node:

            // Enable debug prints to serial monitor
            #define MY_DEBUG 
            
            // Enable and select radio type attached
            #define MY_RADIO_NRF24
            #define MY_NODE_ID 3
            #define MY_RF24_CE_PIN 9
            #define MY_RF24_PA_LEVEL RF24_PA_HIGH
            
            
            #include <SPI.h>
            #include <MySensors.h>
            #include <prescaler.h>
            #include <OneWire.h>
            
            #define SKETCH_NAME "Sensor Node"
            #define SKETCH_MAJOR_VER "1"
            #define SKETCH_MINOR_VER "0"
            
            #define TEMPERATURE_SENSOR 1
            #define STATUS 2
            #define HIGH_SWITCH 3
            #define FILL_SWITCH 4
            #define LOW_SWITCH 5
            
            const byte EN = 17; //turns on the boost converter to get 3.3v
            const byte PER = 14; //peripherals (DS18B20, nRF24L01)
            const byte High_sw = 5;
            const byte Fill_sw = 6;
            const byte Low_sw = 7;
            const byte Wake_pin = 2;  //wake from sleep mode powerdown
            OneWire  ds(9);  // on pin 10 (a 4.7K resistor is necessary)
            unsigned int node_status = 0;
            // Change to V_LIGHT if you use S_LIGHT in presentation below
            MyMessage msg(TEMPERATURE_SENSOR, V_TEMP);
            MyMessage msg2(STATUS, V_VAR1);
            MyMessage msg3(HIGH_SWITCH, V_STATUS);
            MyMessage msg4(FILL_SWITCH, V_STATUS);
            MyMessage msg5(LOW_SWITCH, V_STATUS);
            
            
            void before(){
            
              pinMode(EN,OUTPUT);
              digitalWrite(EN,LOW);  //give us 3.3v
              
              pinMode(PER, OUTPUT);   //for turning on peripherals
              digitalWrite(PER,LOW);  //peripherals on - P Chan FET
              
              digitalWrite (Wake_pin, HIGH);  //will wake with falling edge
              
            }
            void setup()  
            {  
              
            }
            
            void presentation() {
              // Send the sketch version information to the gateway and Controller
              sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);
            
              // Register binary input sensor to sensor_node (they will be created as child devices)
              // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
              // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
              present(TEMPERATURE_SENSOR, S_TEMP);
              present(STATUS, S_TEMP);
              present(HIGH_SWITCH, S_BINARY);
              present(FILL_SWITCH, S_BINARY);
              present(LOW_SWITCH, S_BINARY);  
             
            }
            
            // Loop will iterate on changes on the BUTTON_PINs
            void loop() 
            {     
                  send(msg.set(get_temperature(),2));
                  send(msg2.set(node_status));
                  send(msg3.set(switch_status(High_sw)));
                  send(msg4.set(switch_status(Fill_sw)));
                  send(msg5.set(switch_status(Low_sw)));
                  sendBatteryLevel(get_battery());
                  
                  //this worked when I was using the SerialGateway on the Raspi but 
                  //isn't working using the MySerialGateway (mysgateway)
                  if(isTransportOK()){
                    sleep(30000);  // transport is OK, node can sleep
                  } 
                  else {
                    Serial.println("Fixing Transport Layer");
                    node_status+=1;
                    wait(5000); // transport is not operational, allow the transport layer to fix this
                  }
                  //sleep(60000);  //interrupt on pin 2
                
            
            
            } 
            
            bool switch_status(int digitalPin){
              bool stat = 1;
              pinMode(digitalPin,INPUT);
              digitalWrite(digitalPin,HIGH);  //enable pullup
              sleep(5); //not sure if we need to wait for the line to settle
              stat = digitalRead(digitalPin);
              digitalWrite(digitalPin,LOW);  //save power when off
              return stat;
            }
            
            float get_temperature(){
            
              byte i;
              byte ds_present = 0;
              byte type_s = 0;
              byte data[12];
              byte addr[8];
              float celsius, fahrenheit;
              
              
              if (!ds.reset())
              {
                Serial.print("No Sensor");
                return (0);
                }
              ds.skip();
              ds.write(0x44, 1);        // start conversion, with parasite power on at the end
              
              sleep(1000);     // maybe 750ms is enough, maybe not
              // we might do a ds.depower() here, but the reset will take care of it.
              
              ds_present = ds.reset();
              ds.skip();    
              ds.write(0xBE);         // Read Scratchpad
            
              Serial.print("  Data = ");
              Serial.print(ds_present, HEX);
              Serial.print(" ");
              for ( i = 0; i < 9; i++) {           // we need 9 bytes
                data[i] = ds.read();
                Serial.print(data[i], HEX);
                Serial.print(" ");
              }
              Serial.print(" CRC=");
              Serial.print(OneWire::crc8(data, 8), HEX);
              Serial.println();
            
              // Convert the data to actual temperature
              // because the result is a 16 bit signed integer, it should
              // be stored to an "int16_t" type, which is always 16 bits
              // even when compiled on a 32 bit processor.
              int16_t raw = (data[1] << 8) | data[0];
              if (type_s) {
                raw = raw << 3; // 9 bit resolution default
                if (data[7] == 0x10) {
                  // "count remain" gives full 12 bit resolution
                  raw = (raw & 0xFFF0) + 12 - data[6];
                }
              } else {
                byte cfg = (data[4] & 0x60);
                // at lower res, the low bits are undefined, so let's zero them
                if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
                else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
                else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
                //// default is 12 bit resolution, 750 ms conversion time
              }
              celsius = (float)raw / 16.0;
              fahrenheit = celsius * 1.8 + 32.0;
              Serial.print("  Temperature = ");
              Serial.print(celsius);
              Serial.print(" Celsius, ");
              Serial.print(fahrenheit);
              Serial.println(" Fahrenheit");
              return(fahrenheit);
            }
            //battery empty at .8v so 1.5 - .8 = .7
            //(465-battery)/248
            //.0032226562
            float get_battery(){
              unsigned int battery = analogRead(A1);
              //float volts = 3.3/1024.0*(float)battery;
              float percent = (217.0-(465.0-(float)battery))/217.0;
              return(max(0,min(100,(percent * 100))));
            }
            

            Can you see anything that may be causing my issue?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              annegerben
              wrote on last edited by
              #17

              I've connected the radio using gpio pinnumbers to my rpi using this schema:
              alt text
              but when I run it gives the following errors:

              what did I do wrong?

              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 FAIL
              mysGateway: TSM:FAIL:CNT=1
              mysGateway: TSM:FAIL:PDT
              mysGateway: TSM:FAIL:RE-INIT
              mysGateway: TSM:INIT
              mysGateway: !TSM:INIT:TSP FAIL
              mysGateway: TSM:FAIL:CNT=2
              mysGateway: TSM:FAIL:PDT
              mysGateway: TSM:FAIL:RE-INIT
              mysGateway: TSM:INIT
              mysGateway: !TSM:INIT:TSP FAIL
              mysGateway: TSM:FAIL:CNT=3
              mysGateway: TSM:FAIL:PDT
              mysGateway: TSM:FAIL:RE-INIT
              mysGateway: TSM:INIT
              mysGateway: !TSM:INIT:TSP FAIL
              mysGateway: TSM:FAIL:CNT=4
              mysGateway: TSM:FAIL:PDT
              mysGateway: TSM:FAIL:RE-INIT
              mysGateway: TSM:INIT
              mysGateway: !TSM:INIT:TSP FAIL
              mysGateway: TSM:FAIL:CNT=5
              mysGateway: TSM:FAIL:PDT
              mysGateway: TSM:FAIL:RE-INIT
              mysGateway: TSM:INIT
              mysGateway: !TSM:INIT:TSP FAIL
              mysGateway: TSM:FAIL:CNT=6
              mysGateway: TSM:FAIL:PDT
              mysGateway: TSM:FAIL:RE-INIT
              mysGateway: TSM:INIT
              mysGateway: !TSM:INIT:TSP FAIL
              mysGateway: TSM:FAIL:CNT=7
              mysGateway: TSM:FAIL:PDT
              mysGateway: TSM:FAIL:RE-INIT
              mysGateway: TSM:INIT
              mysGateway: !TSM:INIT:TSP FAIL
              mysGateway: TSM:FAIL:CNT=7
              

              make output:

              pi@raspberrypi:~/MySensors$ make
              Makefile:12: Makefile.inc: Bestand of map bestaat niet
              [Running configure]
              [SECTION] Detecting target machine.
              [OK] machine detected: SoC=BCM2835, Type=RPi, CPU=armv6l, REV=0010.
              [OK] init system detected: systemd
              [SECTION] Saving configuration.
              [OK] Finished.
              cc  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/log.o drivers/Linux/log.c
              g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -D__RPI_BPLUS -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/noniso.o drivers/Linux/noniso.cpp
              g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -D__RPI_BPLUS -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/Print.o drivers/Linux/Print.cpp
              g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -D__RPI_BPLUS -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/EthernetClient.o drivers/Linux/EthernetClient.cpp
              g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -D__RPI_BPLUS -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/SerialPort.o drivers/Linux/SerialPort.cpp
              g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -D__RPI_BPLUS -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/Stream.o drivers/Linux/Stream.cpp
              g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -D__RPI_BPLUS -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/IPAddress.o drivers/Linux/IPAddress.cpp
              g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -D__RPI_BPLUS -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/compatibility.o drivers/Linux/compatibility.cpp
              g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -D__RPI_BPLUS -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/Linux/EthernetServer.o drivers/Linux/EthernetServer.cpp
              g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -D__RPI_BPLUS -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o examples_linux/mysGateway.o examples_linux/mysGateway.cpp
              cc  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/RPi/piHiPri.o drivers/RPi/piHiPri.c
              cc  -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/RPi/bcm2835.o drivers/RPi/bcm2835.c
              g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -D__RPI_BPLUS -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/RPi/rpi_util.o drivers/RPi/rpi_util.cpp
              g++ -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DLINUX_ARCH_RASPBERRYPI -Ofast -g -Wall -Wextra -D__RPI_BPLUS -I. -I./core -I./drivers/Linux -I./drivers/RPi -MMD -c -o drivers/RPi/SPI.o drivers/RPi/SPI.cpp
              g++ -pthread  -o examples_linux/mysGateway drivers/Linux/log.o drivers/Linux/noniso.o drivers/Linux/EthernetClient.o drivers/Linux/SerialPort.o drivers/Linux/Stream.o drivers/Linux/Print.o drivers/Linux/IPAddress.o drivers/Linux/compatibility.o drivers/Linux/EthernetServer.o examples_linux/mysGateway.o drivers/RPi/piHiPri.o drivers/RPi/bcm2835.o drivers/RPi/rpi_util.o drivers/RPi/SPI.o
              
              1 Reply Last reply
              0
              • M Offline
                M Offline
                marceloaqno
                Code Contributor
                wrote on last edited by
                #18

                @hawk_2050 same for you guys who helped, thank you for all the feedback.

                @jerseyguy1996 I don't see anything wrong with your config.Try to add a small delay() after the first send() and before the sendBattery().

                @annegerben This looks like a wire problem. I updated the guide, check the wire section again.

                A M 2 Replies Last reply
                1
                • M marceloaqno

                  @hawk_2050 same for you guys who helped, thank you for all the feedback.

                  @jerseyguy1996 I don't see anything wrong with your config.Try to add a small delay() after the first send() and before the sendBattery().

                  @annegerben This looks like a wire problem. I updated the guide, check the wire section again.

                  A Offline
                  A Offline
                  annegerben
                  wrote on last edited by
                  #19

                  @marceloaqno thanks for the updated in the guide, I've now successfully connected the radio to the RPI.

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

                    Would it be possible to connect a I2C display to display some information, and drive that display from within mysGatway.cpp ?

                    M 1 Reply Last reply
                    0
                    • E ericvdb

                      Would it be possible to connect a I2C display to display some information, and drive that display from within mysGatway.cpp ?

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

                      @ericvdb I2C is the next thing I'll do as soon as I finished adding support for signing.

                      1 Reply Last reply
                      0
                      • jerseyguy1996J Offline
                        jerseyguy1996J Offline
                        jerseyguy1996
                        wrote on last edited by
                        #22

                        @marceloaqno Amazing....adding the short delay fixed it! I'm curious why that is the case. Do you have an explanation for that?

                        M 1 Reply Last reply
                        0
                        • jerseyguy1996J jerseyguy1996

                          @marceloaqno Amazing....adding the short delay fixed it! I'm curious why that is the case. Do you have an explanation for that?

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

                          @jerseyguy1996 It's probaly related to this: https://www.mysensors.org/build/raspberry#improving-throughput-for-nrf24

                          jerseyguy1996J 1 Reply Last reply
                          0
                          • Patrik SöderströmP Offline
                            Patrik SöderströmP Offline
                            Patrik Söderström
                            wrote on last edited by
                            #24

                            Just installed MySensors on one of my Raspberry. Works really great! :) Picks up the other node I have over NRF without trouble. Next I will try and add some sensors directly on the Raspberry.
                            Big thanks for this!

                            1 Reply Last reply
                            0
                            • M marceloaqno

                              @jerseyguy1996 It's probaly related to this: https://www.mysensors.org/build/raspberry#improving-throughput-for-nrf24

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

                              @marceloaqno Oh that makes sense :-) I'm wondering if that is also what is causing my problem with reconnecting when the node loses contact with the gateway. The node connects perfectly when the gateway is running but if it loses the connection for any reason it can't seem to be able to reconnect and just goes into a loop of attempts. Here is the debug info from the node:

                              This is the initialization output

                              Starting sensor (RNNNA-, 2.0.0)
                              TSM:INIT
                              TSM:RADIO:OK
                              TSP:ASSIGNID:OK (ID=3)
                              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=ok:1
                              TSP:MSG:READ 0-0-3 s=255,c=3,t=25,pt=1,l=1,sg=0:1
                              TSP:MSG:PONG RECV (hops=1)
                              TSP:CHKUPL:OK
                              TSM:UPL:OK
                              TSM:READY
                              TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
                              TSP:MSG:SEND 3-3-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0
                              TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:0
                              TSP:MSG:READ 0-0-3 s=255,c=3,t=15,pt=6,l=2,sg=0:0100
                              TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=11,pt=0,l=11,sg=0,ft=0,st=ok:Sensor Node
                              TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=ok:1.0
                              TSP:MSG:SEND 3-3-0-0 s=1,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=ok:
                              TSP:MSG:SEND 3-3-0-0 s=2,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=ok:
                              TSP:MSG:SEND 3-3-0-0 s=3,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
                              TSP:MSG:SEND 3-3-0-0 s=4,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
                              TSP:MSG:SEND 3-3-0-0 s=5,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
                              Request registration...
                              TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2
                              TSP:MSG:READ 0-0-3 s=255,c=3,t=27,pt=1,l=1,sg=0:1
                              Node registration=1
                              Init complete, id=3, parent=0, distance=1, registration=1
                              TSP:MSG:SEND 3-3-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:32.00
                              TSP:MSG:SEND 3-3-0-0 s=2,c=1,t=24,pt=3,l=2,sg=0,ft=0,st=ok:0
                              TSP:MSG:SEND 3-3-0-0 s=3,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=ok:1
                              TSP:MSG:SEND 3-3-0-0 s=4,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=ok:1
                              TSP:MSG:SEND 3-3-0-0 s=5,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=ok:1
                              TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=ok:39
                              TSP:MSG:SEND 3-3-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:32.00
                              TSP:MSG:SEND 3-3-0-0 s=2,c=1,t=24,pt=3,l=2,sg=0,ft=0,st=ok:0
                              TSP:MSG:SEND 3-3-0-0 s=3,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=ok:1
                              TSP:MSG:SEND 3-3-0-0 s=4,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=ok:1
                              TSP:MSG:SEND 3-3-0-0 s=5,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=ok:1
                              TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=ok:76
                              

                              So far so good!

                              Next I shutdown the gateway to simulate a lost connection:

                              TSP:MSG:SEND 3-3-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:32.00
                              TSP:MSG:SEND 3-3-0-0 s=2,c=1,t=24,pt=3,l=2,sg=0,ft=0,st=ok:0
                              TSP:MSG:SEND 3-3-0-0 s=3,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=ok:1
                              !TSP:MSG:SEND 3-3-0-0 s=4,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=fail:1
                              !TSP:MSG:SEND 3-3-0-0 s=5,c=1,t=2,pt=1,l=1,sg=0,ft=1,st=fail:1
                              !TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=0,pt=1,l=1,sg=0,ft=2,st=fail:74
                              !TSP:MSG:SEND 3-3-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,ft=3,st=fail:32.00
                              !TSP:MSG:SEND 3-3-0-0 s=2,c=1,t=24,pt=3,l=2,sg=0,ft=4,st=fail:0
                              !TSP:MSG:SEND 3-3-0-0 s=3,c=1,t=2,pt=1,l=1,sg=0,ft=5,st=fail:1
                              !TSP:MSG:SEND 3-3-0-0 s=4,c=1,t=2,pt=1,l=1,sg=0,ft=6,st=fail:1
                              !TSP:MSG:SEND 3-3-0-0 s=5,c=1,t=2,pt=1,l=1,sg=0,ft=7,st=fail:1
                              !TSP:MSG:SEND 3-3-0-0 s=255,c=3,t=0,pt=1,l=1,sg=0,ft=8,st=fail:72
                              

                              Its still doing what I expect it to do. It begins attempting to reconnect:

                              !TSM:UPL FAIL, SNP
                              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
                              Fixing Transport Layer
                              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:
                              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
                              Fixing Transport Layer
                              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:
                              !TSM:FPAR:FAIL
                              !TSM:FAILURE
                              TSM:PDT
                              !TSP:SEND:TNR
                              !TSP:SEND:TNR
                              !TSP:SEND:TNR
                              !TSP:SEND:TNR
                              !TSP:SEND:TNR
                              !TSP:SEND:TNR
                              

                              Still working as intended. Next I start the gateway back up to see if it will reconnect. Here is where I have problems.

                              Fixing Transport Layer
                              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
                              Fixing Transport Layer
                              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
                              

                              It looks like the first few messages to initialize the reconnect go through okay and then it misses everything afterwards. If I reset the node it will connect again with no problems.
                              What do you think might be happening here?

                              1 Reply Last reply
                              0
                              • ysinhY Offline
                                ysinhY Offline
                                ysinh
                                wrote on last edited by
                                #26

                                A tiny hint for the users of domoticz :
                                ./configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyUSB20
                                make
                                sudo ./examples_linux/mysGateway -d

                                :) i hope this helps
                                then in the hardware setup
                                MySensors Gateway USB
                                serial port: /dev/ttyUSB20

                                carlylerC 1 Reply Last reply
                                2
                                • G Offline
                                  G Offline
                                  gvorster
                                  wrote on last edited by
                                  #27

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

                                  1 Reply Last reply
                                  0
                                  • hekH Online
                                    hekH Online
                                    hek
                                    Admin
                                    wrote on last edited by
                                    #28

                                    @gvorster said:

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

                                    Yes!

                                    1 Reply Last reply
                                    0
                                    • jerseyguy1996J Offline
                                      jerseyguy1996J Offline
                                      jerseyguy1996
                                      wrote on last edited by
                                      #29

                                      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?

                                      1 Reply Last reply
                                      1
                                      • jerseyguy1996J Offline
                                        jerseyguy1996J Offline
                                        jerseyguy1996
                                        wrote on last edited by
                                        #30

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

                                        1 Reply Last reply
                                        2
                                        • NiklasON Offline
                                          NiklasON Offline
                                          NiklasO
                                          wrote on last edited by
                                          #31

                                          Where do I put the security stuff for the signing?

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


                                          13

                                          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
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular