# ATTiny85 clock speed problem

Using an ATTiny85 and an Arduino loader I created a simple device for turning on an exhaust fan based on a light sensor. The ATTiny85 turns on the fan after activating a warning light and sounding an alarm. Of course, I use a relay to amplify the signal from the ATTiny85 to switch the AC power to the fan. I’m not using I2C, it is simply an on/off pin command. All well and good.

However, after several weeks of operation the ATTiny85 seems to increase its clock speed. The warning light flashes much faster than it was programmed to and the alarm sounds for a shorter time and at a higher pitch.

digitalWrite(FUNCTION, HIGH);
buzzer(1000, 1, 1);
delay(700);
buzzer(1000, 1, 1);
delay(700);
buzzer(2000, 1, 1);
fan(ON);
digitalWrite(FUNCTION, LOW);


Simply rebooting the system solves the problem for a few weeks.

Initially I figured the problem was dirty power. I replaced the 5V transformer running the chip with a 12V transformer and ran the power through a XL4015 Step-Down Buck Converter. When I test the power going to the ATTiny85 from the buck, I get a steady 5.16V as designed. Still, after a few weeks, the ATTiny85 seems to go into hyper-speed.

I have searched along the lines of “ATTiny85 clock speed” and have found nothing that approximates my problem. The code is a fairly simple loop and the integers passed to the "buzzer" routine should produce a constant time period, I would think.

Assuming the code is not at fault, are there ways that the ATTiny85’s clock speed can be altered by external events? Power spikes? phases of the moon? ;-)...

I wanted to ask this question, before I go wading-in looking for a silly software bug! Which is likely the problem!