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. Controllers
  3. Code for beta-testing?

Code for beta-testing?

Scheduled Pinned Locked Moved Controllers
33 Posts 10 Posters 15.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    ToSa
    Code Contributor
    wrote on last edited by
    #24

    Changing the mongo database URL in the dbDetails,js file
    from:
    mongodb://mysensors:27017/pi
    to:
    mongodb://localhost:27017/mysensors

    fixed the "Error looking up radioIdo" issue on the RPi. Now the Rpi generates a new radioId but the attempt to send this to the Arduino fails:

    RPi output:
    Received: from=255, to=0, childId=255, mtype=4, type=5, crc=139, ''
    139, 2, 0, 255, 0, 255, 255, 4, 5
    Message crc ok.
    header.type=5, header.to=0, radioId=0
    Got message
    Message type: 4
    msgTypeId=4 int=4
    Sending data 255;255;4;5;1
    Writing back messageWe have input
    Nread=14
    INP:255;255;4;5;1
    .
    INGOT radioId=255, childId=255, messageType=4, type=5, value=1
    Sending data to GATEWAYRelaying message back to gateway.
    Sending: from=0, to=255, childId=255, mtype=4, type=5, crc=193, '1
    ', sent via 0
    193, 2, 0, 0, 255, 0, 255, 4, 5
    radioId: Inserted id=1
    Send failed. No ack received.
    Sent to JS
    Dynamic payload size=9

    1 Reply Last reply
    0
    • T ToSa

      The "Message crc error." is a bit misleading. The code in the validate() routine actually checks the crc as well as the protocol version. Looking at the Arduino and the RPi 1.4 branch the versions don't match. I've adjusted the library and protocol version in the Sensor.h file on the Rpi to:

      LIBRARY_VERSION "1.4"
      PROTOCOL_VERSION 2

      and the crc error disappeared.

      While changing the data rate from 2M to 1M in line 30 of the Arduino Sensor.cpp, I had to fix a syntax error to recompile successfully in line 361: a missing "}" to close the do/while. The full line should be "} while (--retry);"

      With these two fixed the RPi and the Arduino now communicate - but I get a lot of "Send failed" messages on the Arduino and a lot of "Error looking up radioIds" on the RPi now:

      RPi output:
      Received: from=255, to=0, childId=255, mtype=4, type=5, crc=139, ''
      139, 2, 0, 255, 0, 255, 255, 4, 5
      Message crc ok.
      header.type=5, header.to=0, radioId=0
      Got message
      Message type: 4
      msgTypeId=4 int=4
      Error looking up radioIds
      ...and so on...

      Android in DEBUG mode:
      Started sensor.
      Relay=0, distance=1
      No radio id found in EEPROM fetching one from sensor net gateway
      Relaying message back to gateway.
      Tx: fr=255,to=0,la=255,ne=0,ci=255,mt=4,ty=5,cr=139:
      Send failed.
      Relaying message back to gateway.
      Tx: fr=255,to=0,la=255,ne=0,ci=255,mt=4,ty=5,cr=139:
      Send failed.
      ...and so on...

      B Offline
      B Offline
      Bmlsx
      wrote on last edited by
      #25

      @ToSa thank you ...u saved my rpi;)

      1 Reply Last reply
      0
      • T Offline
        T Offline
        ToSa
        Code Contributor
        wrote on last edited by ToSa
        #26

        @BMLSX - probably rather saved your stomach - eating the raspberry sounds noxious :)

        I got one step further (maybe) - the Arduino now receives the radioId... looking at the log from the RPi above I stumbled over the RPi sending the data to the gateway ??? the RPi is the gateway !!! Comparing the code to the SerialGateway which seems to work for a lot of folks I found that the sendData() function is missing in the Relay.cpp code used for the RPi. Once that procedure is in place the RPi actually submits the new radioId to the sensor:

        RPi : now "sent via 255" instead of "sent via 0"
        Dynamic payload size=9
        Received: from=255, to=0, childId=255, mtype=4, type=5, crc=65, ''
        Message crc ok.
        header.type=5, header.to=0, radioId=0
        Got message
        Message type: 4
        Writing back message
        msgTypeId=4 int=4
        Sending data 255;255;4;5;1
        We have input
        Nread=14
        INP:255;255;4;5;1
        .
        INGOT radioId=255, childId=255, messageType=4, type=5, value=1
        Sending data to GATEWAY
        No route... try sending direct.
        Sending: from=0, to=255, childId=255, mtype=4, type=5, crc=11, '1
        ', sent via 255
        radioId: Inserted id=1
        Send failed. No ack received.
        Sent to JS

        Arduino
        Started sensor.
        Open ping reading pipe: 255
        Tx: fr=255,to=255,la=255,ne=255,ci=255,mt=4,ty=9,cr=235:
        Message available on pipe 1
        Rx: fr=0,to=255,la=0,ci=255,mt=4,t=10,cr=106(ok): 0
        Message addressed for this node.
        Using relay 0. Distance is 0
        Relay=0, distance=1
        No radio id found in EEPROM fetching one from sensor net gateway
        TH: get: n=0,c=255,st=4,rt=4,vt=5
        Relaying message back to gateway.
        Tx: fr=255,to=0,la=255,ne=0,ci=255,mt=4,ty=5,cr=65:
        Ack: receive timeout
        Message available on pipe 1
        Sent ack msg to 0
        Rx: fr=0,to=255,la=0,ci=255,mt=4,t=5,cr=11(ok): 1

        Message addressed for this node.
        Radio id received: 1
        Radio id stored in EEPROM was: 1
        Relaying message back to gateway.
        Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=0,ty=17,cr=17: 1.3b3 (7afb55c)
        Ack: receive timeout
        Relaying message back to gateway.
        Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=7,cr=176: 0
        Ack: receive timeout
        Relaying message back to gateway.
        Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=14,cr=21: Temperature Sensor
        Ack: receive timeout
        Relaying message back to gateway.
        Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=15,cr=13: 1.0
        Ack: receive timeout
        Relaying message back to gateway.
        Tx: fr=1,to=0,la=1,ne=0,ci=0,mt=0,ty=6,cr=99: 1.3b3 (7afb55c)
        Ack: receive timeout
        TH: get: n=0,c=255,st=4,rt=4,vt=13
        Relaying message back to gateway.
        Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=13,cr=200:
        Ack: receive timeout

        I'm still not sure if the missing ACK for the majority of the messages is by purpose or by accident... would be relatively easy to fix by either not waiting for an ACK for all messages or by always sending an ACK - but I don't want to mess with this code without knowing why it was implemented this way.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          ToSa
          Code Contributor
          wrote on last edited by
          #27

          RPi and Arduino now talk to each other, the Arduino receives the radioId from the Rpi and stores it in the EEPROM and the Arduino presents itself to the network. I still see some timing issues (ACKs too late / replies too early while the other end is still waiting for an ACK / ...) but in general it works.
          To get there I forked both the Arduino and the RPi project and tried to get to the latest and greatest code by merging some of the branches (mainly master and 1.4dev)... When I ran into additional issues due to the RPi code not getting the latest updates and bug fixes available in the Arduino project, I decided to merge across the two and ended up with a common set of RF files: a common codebase for RF24 as well as Sensor/Relay/Gateway. If any of this is of interest for themain development then please let me know and I'll create a pull request.

          What I did in detail:

          Arduino:

          • started new branch tosa-dev based on latest master branch
          • adjusted the message header to use full bytes as mentioned earlier in this thread
          • no need to merge the 1.4dev branch as the message header was essentially the only remaining relevant change in there
          • no need to merge other branches as the majority of these were already merged back into master

          Raspberry:

          • started new branch tosa-dev based on latest master branch
          • merged the 1.4dev branch into tosa-dev
          • a couple of minor tweaks (mongoDb URL / start and stop scripts / data rate / ... majority listed earlier in this thread)

          When I found the missing Relay::sendData() routine I decided to stop tweaking bit by bit and instead looked at what it would take to use the more advanced Arduino code for RF24 and Sensor/Relay/Gateway for the RPi as well. Based on comments in the forum this seems to work for several people using a SerialGateway or EthernetGateway so my expectation was to find well maintained code there avoiding some of the low level communication issues I ran into so far with the RPi code. This code is available in a separate branch "tosa-dev-commonrf" for both Arduino and Raspberry.

          The code is not perfect yet but it works. I'm not a GIT expert but as far as I can tell the fork is public and everybody should be able to see it:
          https://github.com/ToSa27/Raspberry/tree/tosa-dev-commonrf
          https://github.com/ToSa27/Arduino/tree/tosa-dev-commonrf

          Again: happy to create pull requests if you want to use this setup as part of the master branch at some point. The main reason for me to do this is to get a solid foundation to start working on the OTA update code...

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

            Great.

            I'm working on breaking out the message part from Sensor.cpp into a new class and make it more platform independent (c++ bit fields is not good) . This will help when we port code from Arduino to RPI.

            1 Reply Last reply
            0
            • jendrushJ Offline
              jendrushJ Offline
              jendrush
              wrote on last edited by
              #29

              How the work is going?

              1 Reply Last reply
              0
              • D Offline
                D Offline
                donnib
                wrote on last edited by
                #30

                @ToSa How is your system working ? Are you still using the code you cahnged on your sensors and rPI ? Is it working acceptable ?

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  donnib
                  wrote on last edited by
                  #31

                  @ToSa i tried compiling your code but it fails on the RPi with allot of errors :

                  pi@raspberrypi ~/Raspberry $ make
                  make -C librf24
                  make[1]: Entering directory /home/pi/Raspberry/librf24' g++ -Wall -fPIC -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c RF24.cpp RF24.h: In constructor ‘RF24::RF24(std::string, uint32_t, uint8_t)’: RF24.h:65:12: warning: ‘RF24::spispeed’ will be initialized after [-Wreorder] RF24.h:53:11: warning: ‘uint8_t RF24::ce_pin’ [-Wreorder] RF24.cpp:258:1: warning: when initialized here [-Wreorder] g++ -shared -Wl,-soname,librf24.so.1 -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -o librf24.so.1 compatibility.o gpio.o spi.o RF24.o make[1]: Leaving directory /home/pi/Raspberry/librf24'
                  g++ -c -g -o Gateway.o Gateway.cpp -Wall -Ofast -mfpu=vfp -DDEBUG -DRPI -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -I/home/pi/RF24/RPi/RF24/
                  In file included from Sensor.h:15:0,
                  from Relay.h:15,
                  from Gateway.h:15,
                  from Gateway.cpp:12:
                  Config.h:15:0: warning: "DEBUG" redefined [enabled by default]
                  <command-line>:0:0: note: this is the location of the previous definition
                  In file included from Relay.h:15:0,
                  from Gateway.h:15,
                  from Gateway.cpp:12:
                  Sensor.h:154:16: error: expected ‘)’ before ‘_spidevice’
                  In file included from Gateway.h:15:0,
                  from Gateway.cpp:12:
                  Relay.h:43:16: error: expected ‘)’ before ‘_spidevice’
                  In file included from Gateway.cpp:12:0:
                  Gateway.h:47:18: error: expected ‘)’ before ‘_spidevice’
                  Gateway.cpp:34:1: error: prototype for ‘Gateway::Gateway(std::string, uint32_t, uint8_t, uint8_t)’ does not match any in class ‘Gateway’
                  Gateway.h:24:7: error: candidates are: Gateway::Gateway(const Gateway&)
                  Gateway.h:24:7: error: Gateway::Gateway()
                  Gateway.cpp: In member function ‘void Gateway::begin(rf24_pa_dbm_e, uint8_t, rf24_datarate_e, void ()(char))’:
                  Gateway.cpp:62:18: error: ‘OUTPUT’ was not declared in this scope
                  Gateway.cpp:62:24: error: ‘pinMode’ was not declared in this scope
                  Gateway.cpp:65:26: error: ‘digitalWrite’ was not declared in this scope
                  Gateway.cpp:70:25: error: ‘INPUT’ was not declared in this scope
                  Gateway.cpp:86:53: error: ‘PSTR’ was not declared in this scope
                  Gateway.cpp: In member function ‘void Gateway::checkButtonTriggeredInclusion()’:
                  Gateway.cpp:104:59: error: ‘PSTR’ was not declared in this scope
                  Gateway.cpp: In member function ‘void Gateway::parseAndSend(char*)’:
                  Gateway.cpp:161:35: error: ‘PSTR’ was not declared in this scope
                  Gateway.cpp: In member function ‘void Gateway::setInclusionMode(boolean)’:
                  Gateway.cpp:181:33: error: ‘PSTR’ was not declared in this scope
                  Gateway.cpp: In member function ‘void Gateway::serial(message_s)’:
                  Gateway.cpp:236:33: error: ‘PSTR’ was not declared in this scope
                  Gateway.cpp: In member function ‘void Gateway::ledTimersInterrupt()’:
                  Gateway.cpp:243:28: error: ‘digitalWrite’ was not declared in this scope
                  Gateway.cpp:246:30: error: ‘digitalWrite’ was not declared in this scope
                  Gateway.cpp:252:28: error: ‘digitalWrite’ was not declared in this scope
                  Gateway.cpp:255:30: error: ‘digitalWrite’ was not declared in this scope
                  Gateway.cpp:262:28: error: ‘digitalWrite’ was not declared in this scope
                  Gateway.cpp:265:30: error: ‘digitalWrite’ was not declared in this scope
                  make: *** [Gateway.o] Error 1

                  S 1 Reply Last reply
                  0
                  • D donnib

                    @ToSa i tried compiling your code but it fails on the RPi with allot of errors :

                    pi@raspberrypi ~/Raspberry $ make
                    make -C librf24
                    make[1]: Entering directory /home/pi/Raspberry/librf24' g++ -Wall -fPIC -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c RF24.cpp RF24.h: In constructor ‘RF24::RF24(std::string, uint32_t, uint8_t)’: RF24.h:65:12: warning: ‘RF24::spispeed’ will be initialized after [-Wreorder] RF24.h:53:11: warning: ‘uint8_t RF24::ce_pin’ [-Wreorder] RF24.cpp:258:1: warning: when initialized here [-Wreorder] g++ -shared -Wl,-soname,librf24.so.1 -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -o librf24.so.1 compatibility.o gpio.o spi.o RF24.o make[1]: Leaving directory /home/pi/Raspberry/librf24'
                    g++ -c -g -o Gateway.o Gateway.cpp -Wall -Ofast -mfpu=vfp -DDEBUG -DRPI -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -I/home/pi/RF24/RPi/RF24/
                    In file included from Sensor.h:15:0,
                    from Relay.h:15,
                    from Gateway.h:15,
                    from Gateway.cpp:12:
                    Config.h:15:0: warning: "DEBUG" redefined [enabled by default]
                    <command-line>:0:0: note: this is the location of the previous definition
                    In file included from Relay.h:15:0,
                    from Gateway.h:15,
                    from Gateway.cpp:12:
                    Sensor.h:154:16: error: expected ‘)’ before ‘_spidevice’
                    In file included from Gateway.h:15:0,
                    from Gateway.cpp:12:
                    Relay.h:43:16: error: expected ‘)’ before ‘_spidevice’
                    In file included from Gateway.cpp:12:0:
                    Gateway.h:47:18: error: expected ‘)’ before ‘_spidevice’
                    Gateway.cpp:34:1: error: prototype for ‘Gateway::Gateway(std::string, uint32_t, uint8_t, uint8_t)’ does not match any in class ‘Gateway’
                    Gateway.h:24:7: error: candidates are: Gateway::Gateway(const Gateway&)
                    Gateway.h:24:7: error: Gateway::Gateway()
                    Gateway.cpp: In member function ‘void Gateway::begin(rf24_pa_dbm_e, uint8_t, rf24_datarate_e, void ()(char))’:
                    Gateway.cpp:62:18: error: ‘OUTPUT’ was not declared in this scope
                    Gateway.cpp:62:24: error: ‘pinMode’ was not declared in this scope
                    Gateway.cpp:65:26: error: ‘digitalWrite’ was not declared in this scope
                    Gateway.cpp:70:25: error: ‘INPUT’ was not declared in this scope
                    Gateway.cpp:86:53: error: ‘PSTR’ was not declared in this scope
                    Gateway.cpp: In member function ‘void Gateway::checkButtonTriggeredInclusion()’:
                    Gateway.cpp:104:59: error: ‘PSTR’ was not declared in this scope
                    Gateway.cpp: In member function ‘void Gateway::parseAndSend(char*)’:
                    Gateway.cpp:161:35: error: ‘PSTR’ was not declared in this scope
                    Gateway.cpp: In member function ‘void Gateway::setInclusionMode(boolean)’:
                    Gateway.cpp:181:33: error: ‘PSTR’ was not declared in this scope
                    Gateway.cpp: In member function ‘void Gateway::serial(message_s)’:
                    Gateway.cpp:236:33: error: ‘PSTR’ was not declared in this scope
                    Gateway.cpp: In member function ‘void Gateway::ledTimersInterrupt()’:
                    Gateway.cpp:243:28: error: ‘digitalWrite’ was not declared in this scope
                    Gateway.cpp:246:30: error: ‘digitalWrite’ was not declared in this scope
                    Gateway.cpp:252:28: error: ‘digitalWrite’ was not declared in this scope
                    Gateway.cpp:255:30: error: ‘digitalWrite’ was not declared in this scope
                    Gateway.cpp:262:28: error: ‘digitalWrite’ was not declared in this scope
                    Gateway.cpp:265:30: error: ‘digitalWrite’ was not declared in this scope
                    make: *** [Gateway.o] Error 1

                    S Offline
                    S Offline
                    sjostrom
                    wrote on last edited by
                    #32

                    @donnib I got the same error. Checked out the 1.4dev branch instead and got it working.

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      ToSa
                      Code Contributor
                      wrote on last edited by
                      #33

                      @donnib - I didn't continue this way but instead started using node-js based controller code that connects to a standard Ethernet gateway. @hek merged the code about two weeks ago. I will provide a tutorial on how to set it up from scratch shortly...

                      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.1k

                      Posts


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

                      • Don't have an account? Register

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