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
A

Andy

@Andy
About
Posts
2
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • MySensors on ATTINY85
    A Andy

    @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
    	}
    }
    
    My Project attiny

  • MySensors on ATTINY85
    A Andy

    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.

    My Project attiny
  • Login

  • Don't have an account? Register

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