ATTiny85 electronic fuse with optional temperature sensing

I am in the process of making a bench power supply for a relative which will use a cheap ebay switch mode DC-DC converter board that only allows you to adjust the voltage output and it does not have a current limiter on it. The module is rated at 8 amps output but the tiny heatsinks suggest that it’s probably half that and the transformer feeding it is only rated at 4 amps max.

So I decided to make an auto cutout circuit that works by monitoring the current via an ACS712-5A sensor. The ATtiny85 switches the PSU load on and off via a push button toggle. Useful as the module I’m going to use does not have remote off / on facility and it’s handy to turn the output off whilst connecting up your projects rather than having it permanently on. When the output is on the sensor is read along with an LM35 temperature sensor attached to the switching transistor’s heatsink. If either the current goes above 3 amps or the temperature goes above 60 degrees C the output is disconnected and a red LED lights. These figures are approximate as the analog reference voltage is the 5V supply so if it is not exactly 5V these cut off figures will vary slightly. However in this application accuracy isn’t required. The power button will not turn on again until either or both of the fault conditions have been removed. A green LED indicates that the output is on and all is OK. I used a dual colour LED that simply turns red or green depending on condition.

The temperature sensing is optional. This can be simply disabled by tying the analog input which would be used for the LM35 to ground. The firmware uses David Mellis’s board support at which will need to be added to your Arduino IDE to be able to program the bare chip.

Programming the ATtiny85 from the arduino software is easy. You will need an Arduino board such as the Uno programmed with the Arduino as ISP sketch (in the examples) and then connect it to the ICSP pins on the ATtiny85 and obviously ground and 5V. A 10uf capacitor needs to be placed between reset and ground on the Arduino to prevent it resetting when used as a programmer. You will need to then choose the correct chip in the boards manager and select 16Mhz internal clock option. Then change programmer to arduino as ISP in the arduino IDE. Then go to burn bootloader. This does not actually burn a bootloader but simply sets the fuse bits on the ATtiny85 chip. Once that is complete you can then upload the sketch as you would normally.

Don’t forget to change programmer type back to AVR-ISPMK2 in the arduino options once you are done. If all is programmed OK, the green LED output pin which is also connected to the switching relay will turn on and latch on. Press again to turn off. If the output is overloaded above approx 3 amps or shorted out the relay will turn off and the LED will light red. It will stay in this condition until the overload condition is removed. Press the on button twice to reset and turn on the output again.

I did try and develop this on a digispark development board but it was a waste of time. The components on the board such as the USB pullup resistors and LED interfered with the operation of the program especially the analog inputs. I had to use an external pullup resistor on the button pin. These little boards are OK for very simple things but if you want to use any pin that’s also used for the USB connection it does not always work. There’s a 1.5K pullup resistor on the USB+ pin for start.

When it’s built into the final project I will show more. But for now here is the code. Electronic_fuse


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.