Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. Andy
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Andy

    @Andy

    0
    Reputation
    2
    Posts
    351
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Andy Follow

    Best posts made by Andy

    This user hasn't posted anything yet.

    Latest posts made by Andy

    • RE: MySensors on ATTINY85

      @Sweebee Got it working last night (I hope!), I haven't measured the power consumption yet.

      It doesn't have the resolution of ms. To save battery the attiny85 will sleep for 8 seconds, then wake up and go to sleep again. So if you call gw.deep_sleep(7), it will sleep fox 7x8=56 seconds. It is possible to get a more precise timer by calculating the best combination of sleep timers. For example if you want to sleep a minute, sleep 7x8s=56s and then an additional 1x4s=4, total 60s.

      It needs some cleaning up and correct naming/commenting/testing e.t.c.

      void MySensor::deep_sleep(int time) {
      	// Sleep alternatives:
      	// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms, 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec
      	int ii = 9;	// sleep 8 seconds at a time.
      	byte bb;
      	int ww;
      	if (ii > 9 ) ii=9;
      	bb=ii & 7;
      	if (ii > 7) bb|= (1<<5);
      	bb|= (1<<WDCE);
      	ww=bb;
      
      	MCUSR &= ~(1<<WDRF);
      	// start timed sequence
      	WDTCR |= (1<<WDCE) | (1<<WDE);
      	// set new watchdog timeout value
      	WDTCR = bb;
      	WDTCR |= _BV(WDIE);
        
      	// Count some sheeps.
      	for(int i=0;i<time;i++) {
      		RF24::powerDown();	
      		cbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter OFF
      		set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
      		sleep_enable();
      		sleep_mode();                        // System actually sleeps here
      		sleep_disable();                     // System continues execution here when watchdog timed out   
      		sbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter ON
      	}
      }
      
      posted in My Project
      Andy
      Andy
    • RE: MySensors on ATTINY85

      Awsome work Oitzu and Sweebee!

      Just tried it out and it works perfect 🙂

      Have you succeeded with getting the sleep/timer working? I've tried but discovered that my skills aren't good enough.

      posted in My Project
      Andy
      Andy