ATtiny85 micro controller help

I am going to use an ATtiny85 to monitor heat tape with a thermistor. When the heat tape gets up to a hot enough temperature it will shut the relay off that the heat tape is plugged into. When the temperature gets low it will turn it on. I want to have, a reset button to reset the chip and the range values. I want a button to raise the range by one, and another button to lower the range by one. My digital buttons aren't working right, they are tripping without me pushing them? I got the buttons in a radio shack components kit. Is that because they are just cheep radio shack buttons? I have 5 volts going in a 10k resistor on the other pin to ground it and the out put to the chip. Can I make the analog input 3 and 2 digital inputs? Because that is what the buttons are on. It would be easy to just say, if button = high do this.

I doubt it’s a problem with the switches, more likely a problem with your circuit. Unfortunately I can’t see it from here … my crystal ball is at the cleaners.

fungus: I doubt it's a problem with the switches, more likely a problem with your circuit. Unfortunately I can't see it from here ... my crystal ball is at the cleaners.

You should know better than to try and clean your crystal ball.

This is the schematic

10k pull up and 10k pull down. (assuming that the pull-up is typical on all units) so ,the voltage divider circuit is keeping the level at about 2.5 volts.

or, is it at 5V until you press a switch ? then it brings it to 2.5v ?

(does the 85 have internal pull-ups?)

should't the buttons be connected to grount and not +5V? and i think you are going to have debouncing problems with the switches... you shoul connect all buttons to gnd and inputs .. and add 10k pull-up resistors to those inputs... the reset will defenetly not work because you have the reset button connected to +5V and not ground.

The ports are bi-directional I/O ports with optional internal pull-ups. Figure 10-2 shows a functional description of one I/O-port pin, here generically called Pxn. P.53

The simplest method to ensure a defined level of an unused pin, is to enable the internal pull-up. In this case, the pull-up will be disabled during reset. If low power consumption during reset is important, it is recommended to use an external pull-up or pulldown. Connecting unused pins directly to VCC or GND is not recommended, since this may cause excessive currents. P.57

I made my schematic look like this example from arduino

fixed your schematics… try it like this… hope it works :wink:

ups forgot to change the connection for the reset button... please fix it :roll_eyes:

Okay I'll have to try that. So the ground goes to the top button pin and the pin lead goes to the bottom button pin?

Also how could I turn pin 6, analog input 1, into a digital input? In the schematic the digital buttons are on the analog inputs but I will prohibit move them over to pin 7 and pin 6. I want it to be digital input for ease of programming. Just ... If button = high do this.

can you post your code? i never programmed a tiny85… but posting your code could help?

here is another repared schematic… i repared the reset button wiring and i added two capacitors to the select buttons… because i think you will have big problems with switch debouncing… when you will push the button it will not incremet by one but for 10 or even mor … depends on how the switch contact bounce… if you will have that kind of problem add these capacitors. the value is not fixed but try something in the 100nF range for start…

are these the switches you are using?

12 (1).JPG

Yes those are the switches I have. The way the schematic is right now is working. I don’t have the code made up for the ATtiny85 yet. I an running it on my arduino with the buttons on digital pins 5 and 6. The thermistor is on A0. I an running a serial com to monitor when the buttons get pressed, what the temperature is, what the upper and lower range is. with a delay (100) to kind of slow it down do it won’t increment by a lot. But if I add capacitors I can take out the delay right?

This is my code for the arduino. It seams to be running fine... Sometimes you miss the button press because of the delay. The capacitor will allow me to take the delay out and only have one press per press?? And what kind of capacitor? I have no idea what the middle part (uncommitted part) is doing?? i took the code from somewhere and changed it alot to clean it, and tried to get the middle part into void loop but i had no success with it.

//                                          DIAGRAM
//  GROUND-----------10K RESISTOR-----------INPUT A0-----------50K THERMISTOR-----------5V    

const int ledPin = 13;               //PIN FOR THE SSR(SOLID STATE RELAY)
double fTemp;                        //VARIABLE TO STORE DEGS IN FAHRENHEIT
double Lower = 82;                   //LOWER LIMIT FOR TEMP RANGE IN FAHRENHEIT
double Upper = 86;                   //UPPER LIMIT FOR TEMP RANGE IN FAHRENHEIT
const int ContUp = 6;                //BUTTON TO RAISE TEMP RANGE UP ON PIN 6
const int ContDw = 5;                //BUTTON TO LOWER TEMP RANGE DOWN ON PIN 5
int ReadUp;                          //READ VALUE OF THE TEMP UP BUTTON
int ReadDw;                          //READ VALUE OF THE TEMP DOWN BUTTON

void setup(void) {

  Serial.begin(9200);                //TAKE THIS OUT WHEN PUT ON CHIP
  pinMode(ledPin, OUTPUT)            //PIN FOR THE SSR SET TO OUTPUT
  pinMode(ContUp, INPUT);            //PIN FOR THE TEMP UP BUTTON INPUT     
  pinMode(ContDw, INPUT);            //PIN FOR THE TEMP DOWN BUTTON INPUT

double Thermister(int RawADC) {

  double Temp;
  Temp = log(((10240000/RawADC) - 50000));
  Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
  Temp = Temp - 272.15;           // Convert Kelvin to Celcius
  return Temp;


void loop(void) {

  double temp = Thermister(analogRead(0));  // READ THERMISTOR
  Serial.print("Temperature is:");          //TAKE OUT
  Serial.print(temp);                       //TAKE OUT
  Serial.println(" C / ");                  //TAKE OUT
  fTemp = (temp * 1.8) + 32.0;              // Convert to USA
  Serial.print(fTemp);                      //TAKE OUT
  Serial.println(" F");                     //TAKE OUT
  Serial.println();                         //TAKE OUT
  delay(100);                               //SLOW DOWN THE CODE

  Serial.println(digitalRead(ContUp));      //TAKE OUT    MONITOR WHEN TEMP UP BUTTON PRESSED
  Serial.println(digitalRead(ContDw));      //TAKE OUT    MONITOR WHEN TEMP DOWN BUTTON PRESSED
  Serial.println(Upper);                    //TAKE OUT    DISPLAY UPPER TEMPERATURE VALUE
  Serial.println(Lower);                    //TAKE OUT    DISPLAY LOWER TEMPERATURE VALUE
  ReadUp = digitalRead(ContUp);             //STORING THE DIGITAL BUTTON INPUT
  ReadDw = digitalRead(ContDw);             //STORING THE DIGITAL BUTTON INPUT
  if(ReadUp == HIGH){                       //INCREMENT THE RANGE UP BY ONE WITH BUTTON PRESS 
    Lower = Lower + 1;
    Upper = Upper + 1;

  if(ReadDw == HIGH){                       //INCREMENT THE RANGE DOWN BY ONE WITH BUTTON PRESS 
    Lower = Lower - 1;
    Upper = Upper - 1;

  if(fTemp > Lower && fTemp < Upper){       //TURN HEAT TAPE RELAY ON IF TEMPERATURE IS IN RANGE
    digitalWrite(ledPin, HIGH);

  if(fTemp < Lower){                        //TURN HEAT TAPE ON WHEN BELLOW THE RANGE
    digitalWrite(ledPin, HIGH);

  if(fTemp > Upper){                        //TURN HEAT TAPE OFF WHEN ABOVE THE RANGE
    digitalWrite(ledPin, LOW);   


yes you can take out the delay... but i woul rather keep it and change it down to about 10 or even one. because you are printing to the serial port and it kinda wise to slow down the loop so the processor doesn't freeze. do you realy need a loop so fast? if it's not time critical i woul even keep the delay(100) 8)

witch middle part of the code?

ok i looked at the code and it seem in general you can set the setpoint with the buttons… the code incorporates a small hysteresis so the heating element does’t turn on and off to fast… there are some logarithmic calculations done i guess it’s because the thermistor is not linear… to tell you simply why not use a different approach? a made a thermostat for a spider terarrium for my friend once. it uses an LM35 sensor and a potentiometer for setting the setpoint (i used it so the setpoint is the same even if there is a power outtage). and everything is printed to an 2x16 lcd :slight_smile:

I am going to flash the code to the 8 pin chip. All the serial prints are going to get deleted, hence the take out comment. So the delay can go right away can't it? There won't be any monitoring, except for with an inferred heat gun.

that was my next question. How are you going to know what setpoint you set... but i guess yes you can do it with a infrared monitor. still you should have a small amount of delay so the loop doesn't run too fast delay(1) or delay(5) shoul be fine... As for the capacitors you will have to experiment. The value depends on the resistor value. in your case i voul use a normal 100nF capacitor or something around that value. Delete the delay in your code and put a capacitor like i draw a few posts back and test it on a serial monitor. if the number increments of decrements when te button is pressed your ok but if it jumps a few numbers increment your capacitor value.