Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Shahariar
Published © GPL3+

@ATtiny Sleep Controller : Low Power Embedded System

A system to truly control power saving for any project which is made using a development board that isn't power saving in nature!

IntermediateFull instructions provided3 hours7,095
@ATtiny Sleep Controller : Low Power Embedded System

Things used in this project

Hardware components

SparkFun Attiny84
×1
SparkFun mini Breadboard
×1
SparkFun RGB common anode LED
×1
6.8 k Resistor
×1
2.2 k Resistor
×1
4.7 k Resistor
×1
10 k Resistor
×1
1N5819 Diode
×1
10 uF Capacitor
×1
100 uF Capacitor
×1
0.1 uF Capacitor
×1
Arduino 101
Arduino 101
×1
Breadboard (generic)
Breadboard (generic)
×1
Adafruit n-Ch MOSFET
×1
Adafruit Terminal Block 2 pins
×2
USB Female A Port
×1
SparkFun Protoboard
×1
SparkFun Resistor Kit
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Sch

Schematic

Code

Tiny Sleep Controller

C/C++
Entire code is available on the zip file.
For better realization entire code is segmented into functions,
Details of the functions can be seen in the tabs.
Codes written using a mix of Arduino Functions and AVR Register Control method.
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <avr/wdt.h>

volatile unsigned int sp = 0;
volatile unsigned int second = 0;
volatile unsigned minute = 0;
volatile unsigned hour = 0;

int old_sec=0;

volatile uint32_t net_sec_counter=0;
uint32_t total_off_sec=0;
uint32_t total_on_sec=0;

int sec_off=0;
int min_off=0;
int hrs_off=0;

int sec_on=0;
int min_on=0;
int hrs_on=0;


///////////// add debounce to switch ///////////////
void setup() 
{
setup_IOpins();
setup_timing();
show_timing();
disable_adc();
setup_watchdog(6);
digitalWrite(10,HIGH);
digitalWrite(9,HIGH);
digitalWrite(7,HIGH);


}


void loop() 


{
    
system_sleep () ;
sleep_disable();                     
update_time();
control_load();

}

full code

Arduino
Open Tiny_Power_Saver.ino file in Arduino IDE,
No preview (download only).

Credits

Shahariar
74 projects • 266 followers
"What Kills a 'Great life' is a 'Good Life', which is Living a Life Inside While Loop"

Comments