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. Troubleshooting
  3. High current

High current

Scheduled Pinned Locked Moved Troubleshooting
13 Posts 6 Posters 2.5k 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.
  • kk02067K kk02067

    @mfalkvidd
    I will look into using your suggestions when I have the time.

    Regarding using my code in the library I don't see it beeing an option. The reason is that I'm an amateur programmer and as such I dont know all the "rules" on how code should look. In swedish as you know we have the term "spagettikod" and thats kind of how my code looks. I'm from an assembler background and and there I'm used to "slap some thing together", poking in registers directly and such.

    gohanG Offline
    gohanG Offline
    gohan
    Mod
    wrote on last edited by
    #4

    @kk02067 maybe you can get in touch with one of the developers so he can review your code. Wake up on ping change is something many people have struggled with, so if you found a solution it would be nice to have it working in the library :)

    1 Reply Last reply
    0
    • scalzS Offline
      scalzS Offline
      scalz
      Hardware Contributor
      wrote on last edited by scalz
      #5

      Hi,
      it's not so easy to add pcint change to the lib in a clean way actually. Also doing this would increase lib size. It exists an external lib for this but not ready to use with mysensors yet afaik..
      Need some work.. and now it's so easier with more powerful mcus and it's cheap.

      So for the moment, it's easier, and saving mem, to do it by hand like you've done ;) (i also use pcint like this).

      Regarding sleep code, that can work sure, by using the transport functions (i did that a while) but, @mfalkvidd is right, I think your asm sleep code is missing some important code part from the mysensors sleep functions.. When i did that i tried to mimic some parts of mysensors sleep code and so on.

      kk02067K 1 Reply Last reply
      0
      • scalzS scalz

        Hi,
        it's not so easy to add pcint change to the lib in a clean way actually. Also doing this would increase lib size. It exists an external lib for this but not ready to use with mysensors yet afaik..
        Need some work.. and now it's so easier with more powerful mcus and it's cheap.

        So for the moment, it's easier, and saving mem, to do it by hand like you've done ;) (i also use pcint like this).

        Regarding sleep code, that can work sure, by using the transport functions (i did that a while) but, @mfalkvidd is right, I think your asm sleep code is missing some important code part from the mysensors sleep functions.. When i did that i tried to mimic some parts of mysensors sleep code and so on.

        kk02067K Offline
        kk02067K Offline
        kk02067
        wrote on last edited by kk02067
        #6

        @scalz

        The snippet of code in my previous post isn't the whole code. This is a bit more of the code (the loop section),

        
          while(!isTransportReady){   //kolla om allt ok för "sleep"
            _process();               //om inte så kör processen som styr biblioteket
          }
        
          transportPowerDown();   //Stäng ner radion
        //  Serial.print("Gonatt :");
          asm("cli");
          sleepcounter++;
          asm("sei");
        //  Serial.println(sleepcounter);
          Serial.flush ();    //vänta på serial skall bli klar
          WDTCSR=0b00011000;  //Starta watchdog timer interupt på 1s
          WDTCSR=0b01000110;
          SMCR=0b00000101;    //Välj powerdown mode
        sleep:
          asm("sleep");
          if (pinchange){     //Om pinchange är anledningen till vakna så sov igen
            pinchange=false;
            goto sleep;
          }
        // Här har det gått en sekund skicka nya data om det behövs
        
          asm("cli");
          TCNT1=0;            //Nollställ cykelräknaren 
          asm("sei");
          sendwind();
          sendbattery();
          sendtemp();
          sendrain();
          sendsolar();
          sendfail();
          asm("cli");
          cycle=TCNT1;
          asm("sei");
        //  Serial.print("Cykeltid: ");
        //  Serial.println(cycle*8);
        
        

        But it seems to consume to much power.

        The pinchange interupt fires fairly often but the mcu is mostly awake for about 120 cycles every second. So a drop of 0.2 Volts in battery in under 18 hours seems a bit high. This on a 3.3v pro mini at 8MHz.

        1 Reply Last reply
        0
        • pansenP Offline
          pansenP Offline
          pansen
          wrote on last edited by pansen
          #7

          Sorry for OT but I am a bit confused, doesn't support sleep wakeups on pin changes? I guess you mean something else then?

          /**
             * Sleep (PowerDownMode) the MCU and radio. Wake up on timer or pin change.
             * See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin
             * is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
             * @param interrupt Interrupt that should trigger the wakeup
             * @param mode RISING, FALLING, CHANGE
             * @param sleepingMS Number of milliseconds to sleep or 0 to sleep forever
             * @param smartSleep Set True if sending heartbeat and process incoming messages before going to sleep
             * @return Interrupt number if wake up was triggered by pin change, @ref MY_WAKE_UP_BY_TIMER if wake up was triggered by timer, @ref MY_SLEEP_NOT_POSSIBLE if sleep was not possible (e.g. ongoing FW update)
             */
          int8_t sleep(const uint8_t interrupt, const uint8_t mode, const uint32_t sleepingMS = 0,const bool smartSleep = false);
          

          Orange Pi Plus 2e connected to nrf24 PA via SPI running git-development MySensors gateway, OpenHAB2, mosquitto and MySQL persistence.

          AWIA 1 Reply Last reply
          0
          • gohanG Offline
            gohanG Offline
            gohan
            Mod
            wrote on last edited by
            #8

            In theory it's supported, but in practice many people didn't get it to work using CHANGE

            1 Reply Last reply
            0
            • pansenP pansen

              Sorry for OT but I am a bit confused, doesn't support sleep wakeups on pin changes? I guess you mean something else then?

              /**
                 * Sleep (PowerDownMode) the MCU and radio. Wake up on timer or pin change.
                 * See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin
                 * is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
                 * @param interrupt Interrupt that should trigger the wakeup
                 * @param mode RISING, FALLING, CHANGE
                 * @param sleepingMS Number of milliseconds to sleep or 0 to sleep forever
                 * @param smartSleep Set True if sending heartbeat and process incoming messages before going to sleep
                 * @return Interrupt number if wake up was triggered by pin change, @ref MY_WAKE_UP_BY_TIMER if wake up was triggered by timer, @ref MY_SLEEP_NOT_POSSIBLE if sleep was not possible (e.g. ongoing FW update)
                 */
              int8_t sleep(const uint8_t interrupt, const uint8_t mode, const uint32_t sleepingMS = 0,const bool smartSleep = false);
              
              AWIA Offline
              AWIA Offline
              AWI
              Hero Member
              wrote on last edited by
              #9

              @pansen The pinchange interrupt is a different feature in the atmega. It can be used on any pin and is not supported in MySensors. That is why you need to make sure yourself that everything goes to sleep as wanted.

              1 Reply Last reply
              0
              • pansenP Offline
                pansenP Offline
                pansen
                wrote on last edited by pansen
                #10

                @gohan @AWI I understand, so the main issue is that CHANGE does not work. I checked the datasheet and INT0 and INT1 can also do CHANGE so it's a bit weird:

                0_1493197213711_upload-fce2880a-1075-44e0-a230-4ed6d513d5db

                Of course you're limited to the INT0/1 pins then.

                But also:

                0_1493197914736_upload-f3abb58d-503e-4bfc-abd2-611463f2e019

                So PCINT is just not implemented in MySensors? Code is probably based on an old datahseet:

                0_1493197957731_upload-0d9666b3-298c-4435-b0a0-8ae72415c10a

                Because that's just wrong...Looking at hwSleep for AVR it looks like it's just using attachInterrupt with the passed through mode. I'll test later because in fact I'm working on a project with a MPR121 touch controller that wakes up my Pro Mini on FALLING so I change it to CHANGE and see what happens...

                Anyhow, @kk02067 I'd use INT0/1 pins if you can...also, just measure the current consumption und unplug the nrf to see how much it changes. My mentioned MPR121 project consumes about 0.5-0.9mA in sleep and ~18mA in awake (MPR121+Pro Mini+nrf) just to give you some ballpark numbers. Consumption went to 5mA with nrf unplugged.

                Orange Pi Plus 2e connected to nrf24 PA via SPI running git-development MySensors gateway, OpenHAB2, mosquitto and MySQL persistence.

                AWIA 1 Reply Last reply
                0
                • kk02067K Offline
                  kk02067K Offline
                  kk02067
                  wrote on last edited by kk02067
                  #11

                  The pinchange interupt works fine.

                  I found the offending things on my board. It was a combination of a couple of things. First it was the BME280 that was constantly active. Change to forced mode dropped the consumption from 0.4mA to 0.1 mA. I stopped using the internal pullup for my windspeedsensor which is based on a reedswitch. I noticed when the switch was open the consumption dropped to 0.04mA so I mounted a 1Mohm resistor instead of the internal pullup. Turning off the ADC dropped a about 10-20 uA. And lastly it seems that my nimh batterys where bad. They could not keep the charge. Changed to 2 x aaa and now it looks better.

                  Current now on average 0.035 mA in sleepmode

                  I will buy new nimh's to see if my solar panel circuit will work as expected. I hope to keep it running for about 5 years without changing the battery.
                  Only time will tell now.

                  1 Reply Last reply
                  0
                  • gohanG Offline
                    gohanG Offline
                    gohan
                    Mod
                    wrote on last edited by
                    #12

                    I am planning to use supercaps, instead of rechargeable batteries, with solar panel. I'll see what it can do when I get the parts

                    1 Reply Last reply
                    0
                    • pansenP pansen

                      @gohan @AWI I understand, so the main issue is that CHANGE does not work. I checked the datasheet and INT0 and INT1 can also do CHANGE so it's a bit weird:

                      0_1493197213711_upload-fce2880a-1075-44e0-a230-4ed6d513d5db

                      Of course you're limited to the INT0/1 pins then.

                      But also:

                      0_1493197914736_upload-f3abb58d-503e-4bfc-abd2-611463f2e019

                      So PCINT is just not implemented in MySensors? Code is probably based on an old datahseet:

                      0_1493197957731_upload-0d9666b3-298c-4435-b0a0-8ae72415c10a

                      Because that's just wrong...Looking at hwSleep for AVR it looks like it's just using attachInterrupt with the passed through mode. I'll test later because in fact I'm working on a project with a MPR121 touch controller that wakes up my Pro Mini on FALLING so I change it to CHANGE and see what happens...

                      Anyhow, @kk02067 I'd use INT0/1 pins if you can...also, just measure the current consumption und unplug the nrf to see how much it changes. My mentioned MPR121 project consumes about 0.5-0.9mA in sleep and ~18mA in awake (MPR121+Pro Mini+nrf) just to give you some ballpark numbers. Consumption went to 5mA with nrf unplugged.

                      AWIA Offline
                      AWIA Offline
                      AWI
                      Hero Member
                      wrote on last edited by
                      #13

                      @pansen What i meant is that the MySensors API only specifies the (hw) INT0/INT1 RISING/ FALLING/ CHANGE. All of these work as expected.

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


                      9

                      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