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

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. interrupt mystery with sensebender micro
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

interrupt mystery with sensebender micro

Scheduled Pinned Locked Moved Troubleshooting
17 Posts 6 Posters 4.2k Views 4 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.
  • hekH Online
    hekH Online
    hek
    Admin
    wrote on last edited by
    #4

    No, it's not used right now.

    1 Reply Last reply
    1
    • tbowmoT Offline
      tbowmoT Offline
      tbowmo
      Admin
      wrote on last edited by tbowmo
      #5

      D2 interrupt is not used by nrf24, but if you're going to use it with rfm69 (with an adapter board) then you need interrupt for the radio.

      1 Reply Last reply
      1
      • ikkeTI Offline
        ikkeTI Offline
        ikkeT
        wrote on last edited by
        #6

        According to the above pic, there is plenty of interrupt pins. If thats what the int means in their name. Why can't I use other than the D2 for interrupt, and make sure D2 is not used for interrupts?

        1 Reply Last reply
        0
        • tbowmoT Offline
          tbowmoT Offline
          tbowmo
          Admin
          wrote on last edited by
          #7

          D3 is also an interrupt. The rest of the pins also have a pin change interrupt function (haven't used it yet myself)

          1 Reply Last reply
          1
          • ikkeTI Offline
            ikkeTI Offline
            ikkeT
            wrote on last edited by
            #8

            I used pins 3 and 4 for the interruptible input from sensors. What does D2 have to do with this in my case, if none of the code is using it for interrupts?

            I brought d2 and d3 up because some sample codes for sensors mentioned that only those can be used for interrupts. But I assume now this is not the case for SB, thanks to the pic above.

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

              The CHANGE interrupt can only be used on pin 2,3 of the Atmeta328

              https://www.arduino.cc/en/Reference/AttachInterrupt

              There are other ways of trigger wakeup on all pins, but they are not supported by the MySensors sleep function and requires out to keep track of which pin that was triggered manually.

              ikkeTI 1 Reply Last reply
              2
              • scalzS Offline
                scalzS Offline
                scalz
                Hardware Contributor
                wrote on last edited by scalz
                #10

                +1 on what said @Hek ;)
                there is Pin change Int for other pins but you'll need to use raw registers stuff. There exists a lib for this but not supported by MYS sleep. And it's more efficient for memory consumption to use only what you need :)
                I will publish soon my multisensor sketch where I use D2/int0,D3/int1 and two others pinchange int but in case you will find everything you need for this here : : http://www.gammon.com.au/forum/?id=11497

                1 Reply Last reply
                0
                • hekH hek

                  The CHANGE interrupt can only be used on pin 2,3 of the Atmeta328

                  https://www.arduino.cc/en/Reference/AttachInterrupt

                  There are other ways of trigger wakeup on all pins, but they are not supported by the MySensors sleep function and requires out to keep track of which pin that was triggered manually.

                  ikkeTI Offline
                  ikkeTI Offline
                  ikkeT
                  wrote on last edited by
                  #11

                  @hek thanks, this clears the topic. I'll try cutting off the D2 and reuse that. I'll report back...

                  1 Reply Last reply
                  0
                  • ikkeTI Offline
                    ikkeTI Offline
                    ikkeT
                    wrote on last edited by
                    #12

                    Good news and bad news... I got change based interrupts to work by moving the motion to D2. That required cutting off the radio IRQ. Naturally I lost one radio there cutting too much....

                    So now it works initially. But after some rounds the serial text gets garbled, and it stops sending anything quite soon then.

                    isMetric: 1
                    TempDiff :127.31
                    HumDiff  :151.00
                    T: 27.31
                    H: 51
                    TempDiff :0.01
                    HumDiff  :0.00
                    Door  :0
                    Motion:1
                    TempDiff :0.01
                    HumDiff  :0.00
                    Door  :0
                    Motion:0
                    TempDiff :0.07
                    HumDiff  :0.00
                    Door  :0
                    Motion:1
                    TempDiff :0.10
                    HumDiff  :0.00
                    Door  :0
                    Motion:0
                    x00�����x00�����x00�x00x00��x00��x00x00�x00x00�x00x00x00�x00x00x00x00�x00�x00x00x00x00��x00x00�x00x00x00���������```
                    

                    the last line contines for long. Any ideas what could cause it? Some trick I missed with interrupts?

                    Again, the fixed code is here, it's almost the original SB Micro sample:
                    https://github.com/ikke-t/sensebender/blob/master/SenseBender/SenseBender.ino

                    1 Reply Last reply
                    0
                    • ikkeTI Offline
                      ikkeTI Offline
                      ikkeT
                      wrote on last edited by ikkeT
                      #13

                      Solved the scrambled test. I removed the interrupts, and made it loop faster. It always got screwed after five rounds, so it seemed to be due the clock speed change in the template:

                      #ifndef MY_OTA_FIRMWARE_FEATURE
                        if ((measureCount == 5) && highfreq) 
                        {
                          clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power.
                          highfreq = false;
                        } 
                      #endif
                      

                      Removing that takes it further. I suppose the sample code is missing something to fix the serial speed after prescaler change. I also wonder if the radio would require some reconfig after clock speed change?

                      1 Reply Last reply
                      0
                      • ikkeTI Offline
                        ikkeTI Offline
                        ikkeT
                        wrote on last edited by
                        #14

                        But weird still. If I set the sleep time to 10 secs, without interrupts it works just fine. If interrupts are enabled, it stops always in less than ten rounds. So could it be the interrupts break the radio part somehow? E.g. if interrupt comes during transmit? Are interrupts safe in arduino, or should there be some lock set or disable interrupts for time of radio transmit?

                        YveauxY 1 Reply Last reply
                        0
                        • ikkeTI ikkeT

                          But weird still. If I set the sleep time to 10 secs, without interrupts it works just fine. If interrupts are enabled, it stops always in less than ten rounds. So could it be the interrupts break the radio part somehow? E.g. if interrupt comes during transmit? Are interrupts safe in arduino, or should there be some lock set or disable interrupts for time of radio transmit?

                          YveauxY Offline
                          YveauxY Offline
                          Yveaux
                          Mod
                          wrote on last edited by Yveaux
                          #15

                          @ikkeT Have a look at the other pin interrupt related post: https://forum.mysensors.org/topic/4999/solved-latest-git-snapshot-causes-freezes/38
                          I fixed an issue that might also bother you.

                          http://yveaux.blogspot.nl

                          ikkeTI 1 Reply Last reply
                          1
                          • YveauxY Yveaux

                            @ikkeT Have a look at the other pin interrupt related post: https://forum.mysensors.org/topic/4999/solved-latest-git-snapshot-causes-freezes/38
                            I fixed an issue that might also bother you.

                            ikkeTI Offline
                            ikkeTI Offline
                            ikkeT
                            wrote on last edited by
                            #16

                            @Yveaux Thanks, I was following the thread. I confirm, the change fixed my problem too, excellent.

                            1 Reply Last reply
                            0
                            • rborerR Offline
                              rborerR Offline
                              rborer
                              wrote on last edited by
                              #17

                              @ikkeT, I've used the PIN 3 with a door sensor, it work perfectly, just enable the mode INPUT_PULLUP on the setup.

                              void setup() {
                              pinMode(DOOR_PIN, INPUT_PULLUP);

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


                              14

                              Online

                              11.7k

                              Users

                              11.2k

                              Topics

                              113.0k

                              Posts


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

                              • Don't have an account? Register

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