I'm designing a circuit to control the power of a heater using an Attiny85. This is the circuit:

Circuit with Attiny85

The Attiny85 is programmed to boot with the heater and mosfet turned off. When the button is pressed, the heater should turn on and stay on (according to the program).

However, when I turn on the circuit with the switch at the bottom, one battery makes a buzzing sound and the Attiny never seems to start running its program. (The voltage on PB1 doesn't change when the button is pressed.)

If any part of the mosfet is disconnected, suddenly the Attiny85 starts running its program correctly. But, of course, the circuit doesn't work with mosfet disconnected.

Powering everything with a single battery also fixes the problem, but then the heater doesn't produce enough heat.

Why doesn't the Attiny85 load up properly and start working in this circuit?

Side info:
Attiny85 should get 4.2V
Heater should get 8.4V when on
The mosfet is a SIR404DP
Apologies if my diagram is weird

EDIT: The mosfet and batteries can handle about 10 amps. I measured the voltage across the Attiny85 to be 4.2V, so it should be operational unless it's getting locked up on startup.

I tried moving the switch (SW) to the VDD pin and got the same result.


@Andrew Morton's comment to replace the heater with LEDs worked. The Attiny85 operates them as expected. Not sure how to get that to work with the heater though.

EDIT 3: Attaching a capacitor between PB1 and GND as per @Nedd's comment did the trick! The batteries are still making a scary buzzing sound corresponding to the PWM frequency, but I guess that's a different problem.

  • 2
    \$\begingroup\$ Can you swap the heater for a 1 kΩ resistor and an LED in series and see if it works then? I suspect the heater is drawing too much current for the cells to maintain their output voltage. Do you have a multimeter to check the voltage supply to the ATTiny? \$\endgroup\$ Commented May 2, 2021 at 19:17
  • \$\begingroup\$ Can your circuit handle the >4A that is needed for the heater? \$\endgroup\$
    – StarCat
    Commented May 2, 2021 at 19:19
  • 2
    \$\begingroup\$ A switch in the GND line is asking for trouble! Just don't do this as it will give unexpected results. See this video to learn why: youtube.com/watch?v=2yFh7Vv0Paw in the video the VDD isn't connected but the same principle applies for a disconnected GND. \$\endgroup\$ Commented May 2, 2021 at 19:48
  • \$\begingroup\$ It’s most unusual for a cell to buzz - if it has internal current protection then this could be causing problems at power-up. IIRC the AtTiny starts up with all GPIO as inputs with a pull-up so the FET may be switched on until your program sets PB1 to be an output and drives it low. \$\endgroup\$
    – Frog
    Commented May 2, 2021 at 19:50
  • 1
    \$\begingroup\$ If problems are being caused by a fast turn on or unintended oscillation (causing a buzzing) try putting an RC delay on the gate line. If your only switching at a slow rate a few extra mS won't be noticed. Maybe try a 3.3k and a 1uF, (with the resistor on PB1 followed by the cap to GND). I also agree that the power switch should be on the + power pin of the ATtiny. (And the pull up on PB3 - or set the internal pull-up.) \$\endgroup\$
    – Nedd
    Commented May 2, 2021 at 21:25

1 Answer 1


As shown when the power switch is off the supply voltage to the ATTiny could reverse by being fed through the FET.

That probably stops the power on reset working properly and could possibly cause damage.

You need to put the switch in the positive lead to VDD. With the GND terminal of the MCU going direct to the battery.

When using a single cell the voltage to the MCU just goes to zero because of conduction through the FET reducing the problem enough for it to work.

  • \$\begingroup\$ Agree with @kevin white. Also maybe try a test of connecting the heater directly across the two batteries and then test the voltage across the bottom battery. Depending on the internal resistance of the battery it is possible that the voltage across it might drop too low to drive the ATTINY when the heater is on. \$\endgroup\$
    – bigjosh
    Commented May 2, 2021 at 19:49
  • \$\begingroup\$ @DanielWilliams you also need a pullupat PB3 it's in a defined state when the button is not pressed. \$\endgroup\$
    – Sim Son
    Commented May 2, 2021 at 19:53
  • \$\begingroup\$ Do you mean to move the (SW) switch to the VDD pin? I tried that, and it didn't make a difference. \$\endgroup\$ Commented May 2, 2021 at 20:23
  • \$\begingroup\$ @DanielWilliams - Yes the switch should be between the tap on the battery and the 22uF capacitor. The GND of the MCU should go direct to the negative terminal of the battery. If it works with the single cell but doesn't work with the correct position of the switch you may have another wiring error. \$\endgroup\$ Commented May 2, 2021 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.