Electronics

Microcontrollers Atmel ATtiny85 20PU

AED 17.95

1

Description

The Atmel ATtiny85 20PU is a microcontroller that belongs to the AVR family of microcontrollers. It is a small, low-power microcontroller with 8 kilobytes of flash memory, 512 bytes of EEPROM memory, and 512 bytes of SRAM. It features 6 general-purpose input/output (GPIO) pins, including 2 PWM-capable pins, 4 analog input channels, and a range of communication interfaces such as SPI, I2C, and USART. It can operate at clock speeds of up to 20 MHz and has a wide operating voltage range of 2.7V to 5.5V. Due to its low power consumption and small size, the ATtiny85 20PU is commonly used in applications such as battery-powered devices, sensors, and control systems.

Package Includes:

  • 1 x Atmel ATtiny85 20PU Microcontroller

 

Features:

  • Flash memory: The ATtiny85 20PU has 8 kilobytes of flash memory, which is used for storing the program code. This memory can be programmed and reprogrammed using standard programming tools.
  • EEPROM memory: The microcontroller also has 512 bytes of EEPROM memory, which can be used to store data that needs to be retained even when power is removed.
  • SRAM: The ATtiny85 20PU has 512 bytes of SRAM, which is used for the temporary storage of data during program execution.
  • GPIO pins: The microcontroller features 6 general-purpose input/output (GPIO) pins, which can be configured as either inputs or outputs. Two of these pins are capable of pulse-width modulation (PWM) for controlling the brightness of LEDs or the speed of motors.
  • Analog input channels: The remaining four pins are analog input channels, which can be used to measure voltages in the range of 0 to 5 volts.
  • Communication interfaces: The microcontroller also has a range of communication interfaces, including SPI, I2C, and USART. These interfaces enable the microcontroller to communicate with other devices such as sensors, displays, and other microcontrollers.
  • Clock speed: The microcontroller can operate at clock speeds of up to 20 MHz, making it suitable for applications that require fast processing.
  • Operating voltage range: The ATtiny85 20PU has a wide operating voltage range of 2.7V to 5.5V, which makes it suitable for use with a variety of power sources.
  • Low power consumption: Due to its low power consumption, the ATtiny85 20PU is commonly used in applications such as battery-powered devices, sensors, and control systems.
  • Small size: The microcontroller is designed to be compact and easy to use, making it ideal for use in applications where space and cost are critical factors. Its DIP package makes it easy to mount on a circuit board or breadboard, and it is compatible with standard programming tools, making it easy to program and reprogram.

 

Description:

The Atmel ATtiny85 20PU is a microcontroller that is designed to provide a low-cost, high-performance solution for embedded applications. It is part of the AVR family of microcontrollers, which are known for their high performance, low power consumption, and ease of use. The ATtiny85 20PU has 8 kilobytes of flash memory, which is used for storing the program code. This memory can be programmed and reprogrammed using standard programming tools. It also has 512 bytes of EEPROM memory, which can be used to store data that needs to be retained even when power is removed. Additionally, it has 512 bytes of SRAM, which is used for the temporary storage of data during program execution.

The microcontroller features 6 general-purpose input/output (GPIO) pins, which can be configured as either inputs or outputs. Two of these pins are capable of pulse-width modulation (PWM) for controlling the brightness of LEDs or the speed of motors. The remaining four pins are analog input channels, which can be used to measure voltages in the range of 0 to 5 volts. The ATtiny85 20PU also has a range of communication interfaces, including SPI, I2C, and USART. These interfaces enable the microcontroller to communicate with other devices such as sensors, displays, and other microcontrollers. The microcontroller can operate at clock speeds of up to 20 MHz, making it suitable for applications that require fast processing. It has a wide operating voltage range of 2.7V to 5.5V, which makes it suitable for use with a variety of power sources. Due to its low power consumption and small size, the ATtiny85 20PU is commonly used in applications such as battery-powered devices, sensors, and control systems. Its small size and low cost also make it ideal for use in applications where space and cost are critical factors. Some common applications include smart home automation, wearable devices, remote controls, and DIY electronics projects.

Principle of Work:

The principle of working for the Atmel ATtiny85 20PU microcontroller is to execute a program stored in its flash memory. The microcontroller operates based on the principle of input/output (I/O) operations. It has GPIO pins that can be programmed to either input or output mode. The input mode allows the microcontroller to read the state of an external signal or sensor, while the output mode enables it to drive an external device such as an LED, motor, or relay. The microcontroller fetches instructions from memory, decodes them, and executes them. The program may include loops, conditional statements, and function calls, which enable the microcontroller to perform complex operations. The ATtiny85 20PU microcontroller can operate at clock speeds of up to 20 MHz, which enables it to execute instructions quickly. It also has a wide operating voltage range of 2.7V to 5.5V, which makes it suitable for use with a variety of power sources.

 

Pinout of the Module:

 

 

Pin 1: This pin has four different functions, including:

  • PB5: A GPIO pin for PORTB pin 5
  • ADC0: An analog input pin for internal ADC channel 0
  • RESET: A reset input pin for the microcontroller
  • PCINT5: An interrupt input pin for Pin Change Interrupt 5

Usually, this pin is used as a reset input pin, which receives an active low pulse to reset the microcontroller. To use any of the above functions, you need to set the internal configuration bits.

Pin 2: This pin has four different functions, including:

  • PB3: A GPIO pin for PORTB pin 3
  • ADC3: An analog input pin for internal ADC channel 3
  • XTAL1: A pin used to connect an external crystal
  • PCINT3: An interrupt input pin for Pin Change Interrupt 3

Normally, this pin is used as a digital input/output pin (pin 3 or PORTB pin 4), or as an analog input pin A3. You can connect a digital/analog sensor or a digital input/output device like an LED or push button to this pin.

Pin 3: This pin has five different functions, including:

  • PB4: A GPIO pin for PORTB pin 4
  • ADC2: An analog input pin for internal ADC channel 2
  • XTAL2: A pin used to connect an external crystal
  • PCINT4: An interrupt input pin for Pin Change Interrupt 4
  • OC1B: A PWM output pin

This pin can be used as a digital input/output pin (pin 4 or PORTB pin 4), a PWM output pin (pin 4), or as an analog input pin A2. You can connect a digital/analog sensor or a digital input/output device like an LED or push button to this pin.

Pin 4: This is the ground pin, which is connected to the circuit ground.

Pin 5: This pin has seven different functions, including:

  • PB0: A GPIO pin for PORTB pin 0
  • MOSI: A pin used as Master Out Slave In pin in SPI communication
  • SDA: A Serial Data pin used in the I2C interface for sending and receiving data
  • PCINT1: An interrupt input pin for Pin Change Interrupt 1
  • OC0A: A PWM output pin
  • AIN0: An analog voltage input pin 0 for the internal comparator
  • AREF: A reference voltage input pin for internal ADC

This pin can be used as a digital input/output pin (pin 0), a PWM output pin, an analog voltage input pin, or a data pin in I2C interfacing, or MOSI pin in SPI communication to communicate with a computer or another microcontroller.

Pin 6: This pin has five different functions, including:

  • PB1: A GPIO pin for PORTB pin 1
  • MISO: A pin used as the Master In Slave Output pin in SPI communication
  • PCINT0: An interrupt input pin for Pin Change Interrupt 0
  • OC1A/OC0B: A PWM output pin
  • AIN1: An analog voltage input pin 1 for the internal comparator

This pin can be used as a digital input/output pin (pin 1), a PWM output pin, an analog voltage input pin, or a MISO pin in SPI communication to communicate with a computer or another microcontroller.

Pin 7:

  • PB2: works as GPIO pin of PORTB pin 2.
  • SCK: used to provide serial clock signal in SPI communication
  • PCINT2: Pin Change on Interrupt pin 2 that is used as an interrupt input pin
  • ADC1: a channel 1 analog input pin for internal ADC
  • SCL: a Serial Clock pin used in I2C interfacing to provide a clock signal
  • INT0: an external interrupt input pin 0 This pin can be used as:
  • Digital input/output pin as pin 2. One can connect a digital IO device like LED / push button or digital sensor with it
  • Analog input pin A1. One can connect an analog sensor with it
  • External interrupt input pin
  • Serial clock in SPI and I2C communication

Pin 8: Vcc pin. This pin is connected to a 5 V supply.

The Atmel ATtiny85 20PU microcontroller has a total of 8 pins that can be used for various functionalities, such as digital input/output, PWM output, analog input, interrupt input, SPI communication, and I2C interfacing. Each pin can have multiple functions, and the microcontroller's internal configuration bits must be set to enable these functionalities. Additionally, Pin 1 can be used as a reset input pin, and Pin 4 is connected to the circuit ground, while Pin 8 is connected to a 5V supply. Understanding the pinout and functionalities of the microcontroller is essential for designing and programming a circuit using the ATtiny85.

 

 

Applications:

  1. Sensor nodes: The ATtiny85's low power consumption and small size make it an ideal choice for building sensor nodes for IoT applications. It can be used to collect data from various sensors such as temperature, humidity, and light sensors and transmit it to a central hub.
  2. Consumer electronics: The ATtiny85 can be used to control various consumer electronics devices such as LED lighting, home automation systems, and smart appliances.
  3. Robotics: The microcontroller's ability to control PWM signals and analog inputs makes it suitable for building small robots and other robotic applications.
  4. Wearable technology: Due to its small size and low power consumption, the ATtiny85 can be used to develop wearable technology such as smartwatches, fitness trackers, and medical monitoring devices.
  5. Education: The ATtiny85 is often used as a teaching tool in electronics and programming courses due to its simplicity and ease of use.
  6. Automotive: The ATtiny85 can be used in automotive applications such as controlling engine functions, monitoring sensors, and controlling various automotive systems.
  7. Security: The microcontroller's low power consumption and small size make it an ideal choice for building security systems such as door locks, alarms, and access control systems.

 

Circuit

We will program the AtTiny with Arduino 

First, to set up an Arduino Uno for programming, using it as an ISP (In-System Programmer), you need to first connect the Arduino Uno to your computer. Once connected, open the Arduino IDE and go to the "Tools" menu. From the drop-down menu, select "Board" and choose "Arduino Uno" as the board type. Then, select the appropriate COM port from the "Port" menu.

Next, navigate to the "File" menu and select "Examples," followed by "ArduinoISP." This will open the Arduino ISP sketch. Finally, upload this code to the Arduino Uno by clicking the "Upload" button. Once the code has been successfully uploaded, the Arduino Uno is ready to be used as an ISP for programming other microcontrollers or devices.

you will need the following components this circuit can be used to make a shield or you can put them on a breadboard:

  • To create a circuit, you will need several components, including male header pins, an 8-pin IC base (which eliminates the need for a breadboard setup), a 10mfd capacitor, a 220E resistor, an LED, a dotted board, an Arduino Uno.
  • The male header pins will allow you to easily connect and disconnect wires as needed. The 8-pin IC base is a socket that will hold the IC, which is the integrated circuit that contains the electronic components of the circuit.
  • The 10mfd capacitor is a type of electronic component that can store electrical energy. The 220E resistor will limit the current flowing through the LED and prevent it from burning out. The LED will emit light when current flows through it.
  • a dotted board which is a type of printed circuit board that has a pattern of holes for connecting components. Finally, the Arduino Uno is a microcontroller board that can be programmed to control the circuit and perform a variety of functions.

Attiny 85 connection diagram

  • Connect Arduino 5v to AtTiny pin – 8
  • Arduino pin 11 to AtTiny pin – 5
  • Arduino pin 12 to AtTiny pin – 6
  • Arduino pin 13 to AtTiny pin – 7
  • Arduino pin 10 to AtTiny pin – 1
  • Capacitor + to AtTiny pin 1 & negative to AtTiny pin 4
  • Led connected to pin5 via 220 e resistor.
  1. To set up the Arduino IDE for programming the Attiny85 microcontroller, you need to follow a few steps. First, open the Arduino IDE and go to File -> Preferences. In the dialog box, find the section called "Additional Board Manager URLs" and paste the following URL: https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json.
  2. Next, go to Tools -> Board -> Board Manager and search for "Attiny." Install the Attiny board support. Then, go to Tools -> Board and select "Attiny 25/45/85" and "Processor -> Attiny 85". Select the clock as "Internal 8MHz" and choose "Arduino as ISP" as the programmer.
  3. Now, connect the Arduino and Attiny85. Select the proper COM port and go to Tools -> Burn Bootloader. Note that burning the bootloader is only necessary the first time you program the Attiny85, not every time.
  4. After the bootloader is burned, the Attiny85 is ready for programming.

To upload the sample LED blink code to Attiny85, follow the steps below:

  1. Open the Arduino IDE and go to File > Examples > Basics > Blink. This will open the LED blink code.

  2. In the LED blink code, change "LED_BUILTIN" to "0" since the LED is connected to pin 5 which works as pin 0 in the Arduino IDE.

  3. Go to Tools > Board and select "Attiny" and then choose the processor, clock, and programmer options.

  4. Connect the Arduino and Attiny85 as previously mentioned and select the proper com port.

  5. Click on "Upload" to upload the code to the Attiny85.

Once the code is uploaded successfully, the LED should start blinking according to the code.

 

Library: 

No Library was used.

 

Code:

 

void setup() {
  pinMode(0, OUTPUT); // set Pin 0 as an output pin
}

void loop() {
  digitalWrite(0, HIGH); // turn on the LED
  delay(1000); // wait for 1 second
  digitalWrite(0, LOW); // turn off the LED
  delay(1000); // wait for 1 second
}




Note that in the setup() function, we set Pin 0 as an output pin using the pinMode() function. Then, in the loop() function, we use digitalWrite() to turn the LED on and off with a delay of 1 second between each state change using the delay() function

 

Technical Details: 

  • Architecture: 8-bit AVR
  • Flash memory: 8 KB
  • SRAM: 512 bytes
  • EEPROM: 512 bytes
  • Clock speed: up to 20 MHz
  • Operating voltage: 2.7V to 5.5V
  • Input/output pins: 6 (including reset pin)
  • ADC channels: 4 (10-bit resolution)
  • PWM channels: 3
  • Timers: 2 (8-bit and 16-bit)
  • Communication interfaces: USI (Universal Serial Interface)
  • Package type: DIP (Dual Inline Package)
  • Package size: 8 pins (300 mils)
  • Temperature range: -40°C to +85°C

Note: "PU" in the part number stands for "Industrial temperature range" and the "20" refers to the maximum clock speed of 20 MHz.

 

 

Resources:

 

Comparisons:

The ATtiny85 and ATtiny13 are both microcontrollers developed by Atmel, which is now a part of Microchip Technology. Here are some comparisons between the two:

  1. Pin Count: The ATtiny85 has 8 pins while the ATtiny13 has only 6 pins. This makes the ATtiny85 more versatile and suitable for applications that require more I/O pins.
  2. Flash Memory: The ATtiny85 has 8KB of flash memory, while the ATtiny13 has only 1KB of flash memory. This means that the ATtiny85 can store more code and perform more complex tasks than the ATtiny13.
  3. RAM: The ATtiny85 has 512 bytes of SRAM, while the ATtiny13 has only 64 bytes of SRAM. This means that the ATtiny85 can handle more data and perform more complex operations.
  4. Timers: Both microcontrollers have two 8-bit timers, but the ATtiny85 also has a 16-bit timer that can be used for more complex timing functions.
  5. Power Consumption: The ATtiny13 has a lower power consumption than the ATtiny85, making it more suitable for low-power applications.
  6. Price: The ATtiny13 is generally less expensive than the ATtiny85, making it a good choice for cost-sensitive applications.

the choice between the ATtiny85 and ATtiny13 depends on the specific requirements of the project. The ATtiny85 is a more capable microcontroller with more features, but the ATtiny13 is smaller, less expensive, and more suitable for low-power applications.