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. Development
  3. Porting MySensors to work with the RadioHead library

Porting MySensors to work with the RadioHead library

Scheduled Pinned Locked Moved Development
portingradiohead
288 Posts 24 Posters 187.5k Views 12 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #247

    @kolaf and @hek
    Thanks for the great work. I will try to setup a test node and gateway by tomorrow and let it run over the Easter weekend. Hopefully it still runs when I am back :)

    1 Reply Last reply
    0
    • hekH hek

      @kolaf
      Sound good.

      K Offline
      K Offline
      kolaf
      Hero Member
      wrote on last edited by kolaf
      #248

      @hek I tried setting up a second sensor (temperature and power supply voltage) with the updated library. I wiped eeprom, uploaded the sketch, and fired it up.

      It requested a node ID from the gateway, which it received, and everything seemed to go smoothly until it had transmitted the first data point. After that it immediately enters a request for a new node ID, which it receives, and things go in an endless loop. Here is the log:

      find parent
      send: 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
      read: 0-0-255 s=255,c=3,t=8,pt=1,l=1,sg=0:0
      parent=0, d=1
      req id
      send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
      read: 0-0-255 s=255,c=3,t=4,pt=0,l=1,sg=0:1
      send: 1-1-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.4.1
      send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      id=1
      send: 1-1-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.4.1
      send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      sensor started, id=1, parent=0, distance=1
      send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=20,sg=0,st=ok:Temperature basement
      send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
      send: 1-1-0-0 s=1,c=0,t=6,pt=0,l=5,sg=0,st=ok:1.4.1
      send: 1-1-0-0 s=2,c=0,t=13,pt=0,l=5,sg=0,st=ok:1.4.1
      1023send: 1-1-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=ok:5.4
      send: 1-1-0-0 s=255,c=3,t=0,pt=1,l=1,sg=0,st=ok:102
      send: 1-1-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=ok:20.6
      req id
      send: 1-1-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
      read: 0-0-1 s=255,c=3,t=4,pt=0,l=1,sg=0:3
      send: 1-1-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.4.1
      send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      sensor started, id=1, parent=0, distance=1
      send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=20,sg=0,st=ok:Temperature basement
      send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
      send: 1-1-0-0 s=1,c=0,t=6,pt=0,l=5,sg=0,st=ok:1.4.1
      send: 1-1-0-0 s=2,c=0,t=13,pt=0,l=5,sg=0,st=ok:1.4.1
      955send: 1-1-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=ok:5.0
      send: 1-1-0-0 s=255,c=3,t=0,pt=1,l=1,sg=0,st=ok:95
      send: 1-1-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=ok:20.7
      req id
      send: 1-1-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
      read: 0-0-1 s=255,c=3,t=4,pt=0,l=1,sg=0:3
      send: 1-1-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.4.1
      send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      sensor started, id=1, parent=0, distance=1
      send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=20,sg=0,st=ok:Temperature basement
      send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
      send: 1-1-0-0 s=1,c=0,t=6,pt=0,l=5,sg=0,st=ok:1.4.1
      send: 1-1-0-0 s=2,c=0,t=13,pt=0,l=5,sg=0,st=ok:1.4.1
      956send: 1-1-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=ok:5.0
      send: 1-1-0-0 s=255,c=3,t=0,pt=1,l=1,sg=0,st=ok:95
      send: 1-1-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=ok:20.7
      

      As far as I can see this should be caused by the node ID still being AUTO, but this shouldn't be the case since it appears to be correctly stored in ROM?

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kolaf
        Hero Member
        wrote on last edited by
        #249

        Please disregard my previous "analysis"/guess. It turns out that the repeating behaviour that was caused by a program crash. The trigger for this crash is MyHwATMega328::sleep(ms) . I'm running a RFM69HW radio on a anarduino board, which should be using the ATMega 328 chip, same as the moteino.

        By replacing the call to this function in MySensor::sleep(unsigned long ms) with a simple delay(ms), the crashes no longer occur.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kolaf
          Hero Member
          wrote on last edited by
          #250

          My current guess is that the watchdog timer resets the chip after the time period instead of throwing an interrupt to wake the system...?

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kolaf
            Hero Member
            wrote on last edited by
            #251

            I narrowed it down even further. It appears that there is no appropriate interrupt and present to handle when the watchdog fires. I have no idea why this is the case, and I do not know if this fix is correct, but by a placing this code somewhere in MySensors.cpp everything works nicely:

            ISR( WDT_vect ) {
                /* dummy */
            }
            
            hekH 1 Reply Last reply
            0
            • K kolaf

              I narrowed it down even further. It appears that there is no appropriate interrupt and present to handle when the watchdog fires. I have no idea why this is the case, and I do not know if this fix is correct, but by a placing this code somewhere in MySensors.cpp everything works nicely:

              ISR( WDT_vect ) {
                  /* dummy */
              }
              
              hekH Offline
              hekH Offline
              hek
              Admin
              wrote on last edited by
              #252

              @kolaf

              Ok, strange. Would be nice to know why this fixes the problem,

              It should probably be placed here if it's atmega328 related (and only need to be called once):
              https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/MyHwATMega328.h#L22

              K 1 Reply Last reply
              0
              • hekH hek

                @kolaf

                Ok, strange. Would be nice to know why this fixes the problem,

                It should probably be placed here if it's atmega328 related (and only need to be called once):
                https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/MyHwATMega328.h#L22

                K Offline
                K Offline
                kolaf
                Hero Member
                wrote on last edited by kolaf
                #253

                @hek
                As far as I know the function is the interrupt routine that is called by the watchdog when the time expires. I guess it doesn't matter where it is defined so it should be fine to move it. It is not called explicitly anywhere in the code, but by the watchdog. As such, I don't think it should be defined as is done in the header file for the other functions.

                My question is why is it not working for me without this code, I assume it has been working for everyone else?

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

                  Ah.. doh..

                  Moved parts of the low-power library into MyHwATMega328 and forgot the ISR-thingie.

                  https://github.com/mysensors/Arduino/blob/master/libraries/MySensors/utility/LowPower.cpp#L850

                  Good catch.

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    kolaf
                    Hero Member
                    wrote on last edited by
                    #255

                    Glad I could help :-). I guess my prize will be that you patch this so that I do not have to create a pull request ;)

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kolaf
                      Hero Member
                      wrote on last edited by
                      #256

                      I might as well continue while I'm at it :-)

                      Another weird issue I'm having is that every node requests a new ID whenever it starts, but it does not switch to the new ID it receives. It just continues with the old ID it already had.

                      When I wipe the ROM it requests a new ID as expected, and this time it is saved and used for subsequent communication. Why is it requesting a new ID when it boots, when it already has one?

                      hekH 1 Reply Last reply
                      0
                      • K kolaf

                        I might as well continue while I'm at it :-)

                        Another weird issue I'm having is that every node requests a new ID whenever it starts, but it does not switch to the new ID it receives. It just continues with the old ID it already had.

                        When I wipe the ROM it requests a new ID as expected, and this time it is saved and used for subsequent communication. Why is it requesting a new ID when it boots, when it already has one?

                        hekH Offline
                        hekH Offline
                        hek
                        Admin
                        wrote on last edited by
                        #257

                        @kolaf

                        Should not happen. Will look at it later tonight.

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

                          Ok, finally got the thumbs out and actually tested the RFM69 code using a couple of Moteinos. They seem to communicate just fine. :)

                          Tested with SerialGateway<->RelayActuator-Example.

                          K 1 Reply Last reply
                          0
                          • R Offline
                            R Offline
                            reddy11
                            wrote on last edited by
                            #259

                            I can also report success and things look pretty good. Had to change the line:

                            //MyTransportRFM69 transport;
                            MyTransportRFM69 transport(RFM69_FREQUENCY, RFM69_NETWORKID, RF69_SPI_CS, RF69_IRQ_PIN, true, RF69_IRQ_NUM);
                            
                            

                            So that the rfm69HW could be supported.

                            Now, on to see if I can get the MQTT working.

                            K 1 Reply Last reply
                            0
                            • R reddy11

                              I can also report success and things look pretty good. Had to change the line:

                              //MyTransportRFM69 transport;
                              MyTransportRFM69 transport(RFM69_FREQUENCY, RFM69_NETWORKID, RF69_SPI_CS, RF69_IRQ_PIN, true, RF69_IRQ_NUM);
                              
                              

                              So that the rfm69HW could be supported.

                              Now, on to see if I can get the MQTT working.

                              K Offline
                              K Offline
                              kolaf
                              Hero Member
                              wrote on last edited by
                              #260

                              @reddy11 I had to do the same, although I did the change in the default parameters for the function definition since all my radios are HW :-).

                              I'm not using the MQTT gateway, I'm using the serial gateway together with a Perl script someone here made which functions as a MQTT gateway, and which I modified to handle node ID assignments.

                              R 1 Reply Last reply
                              0
                              • hekH hek

                                Ok, finally got the thumbs out and actually tested the RFM69 code using a couple of Moteinos. They seem to communicate just fine. :)

                                Tested with SerialGateway<->RelayActuator-Example.

                                K Offline
                                K Offline
                                kolaf
                                Hero Member
                                wrote on last edited by
                                #261

                                @hek You didn't see any extra node ID requests when the sensor booted?

                                tekkaT 1 Reply Last reply
                                0
                                • K kolaf

                                  @hek You didn't see any extra node ID requests when the sensor booted?

                                  tekkaT Offline
                                  tekkaT Offline
                                  tekka
                                  Admin
                                  wrote on last edited by
                                  #262

                                  @kolaf are you using the OTA bootloader?

                                  K 1 Reply Last reply
                                  0
                                  • tekkaT tekka

                                    @kolaf are you using the OTA bootloader?

                                    K Offline
                                    K Offline
                                    kolaf
                                    Hero Member
                                    wrote on last edited by
                                    #263

                                    @tekka said:

                                    @kolaf are you using the OTA bootloader?

                                    No, I haven't figured out that part yet. I'm not even sure if I have available flash memory for this, nor if this is expected to work with the rf69 radios.

                                    tekkaT 1 Reply Last reply
                                    0
                                    • K kolaf

                                      @tekka said:

                                      @kolaf are you using the OTA bootloader?

                                      No, I haven't figured out that part yet. I'm not even sure if I have available flash memory for this, nor if this is expected to work with the rf69 radios.

                                      tekkaT Offline
                                      tekkaT Offline
                                      tekka
                                      Admin
                                      wrote on last edited by
                                      #264

                                      @kolaf ok, i was asking because there is an issue wIth the ID assignment and the OTA bl in the dev branch resulting in the scenario you described.

                                      1 Reply Last reply
                                      0
                                      • ? Offline
                                        ? Offline
                                        A Former User
                                        wrote on last edited by
                                        #265

                                        Thanks everybody for the nice work! My initial tests also work out of the box with a serial gateway and humidity node. I will let it run over the weekend to see if there are any issues coming up.

                                        1 Reply Last reply
                                        0
                                        • L Offline
                                          L Offline
                                          lafleur
                                          wrote on last edited by
                                          #266

                                          I have serial gateway running on a MoteinoMega and a node running on a Moteino with RFM69HW radios... Using the 2April2015 build of the development arm... with the addition of the :

                                          //MyTransportRFM69 transport;
                                          MyTransportRFM69 transport(RFM69_FREQUENCY, RFM69_NETWORKID, RF69_SPI_CS, RF69_IRQ_PIN, true, RF69_IRQ_NUM);

                                          and the correct pin-out for the radios and LED for these boards...

                                          I needed to mod the MsTimer2.cpp file to add 'AVR_ATmega1284P ' to each of the #ifdef line to support the Mega

                                          As I do not yet have a controller running, I see the gateway output as below when the node TX's:

                                          0;0;3;0;9;read: 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:255;255;3;0;3;

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


                                          21

                                          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