Sunday, August 30, 2020

Programming ATTiny85 Microcontroller on Arduino

MacOS 10.15.6
Windows 10
Arduino 1.8.13


Goals:

  • Install drivers and libraries to develop firmware for the ATTiny85 Microcontroller using Arduino IDE, including the ATTiny85 chip alone (uploading firmware using Arduino Uno) and also ATTiny85 Dev Board.



ATTINY85 Features:
  • PB3 - OWOWOD - One Wire / One Way Output for Debugging library. It allows you to output text from the ATtiny85 microcontroller or other similar, though USB-to-Serial or TTL converter and to the computer screen using COM port monitoring tool.
  • Watchdog timer
  • The reset pin can also be used as a (weak) I/O pin.
NameFeatures
CPU Architecture and Speed8-bit RISC Architecture, 1 MIPS@1MHz
CPU Frequency0-8MHz  Calibrated Internal R-C Oscillator
Operating Voltage Range+1.8V to +5.5V (ATTINY85V)
+2.7V to +5.5V (ATTINY85) (+6.0V  being absolute maximum supply voltage)
GPIO PORTS6 GPIO Pins in total 
InterruptsOne External interrupt on INT0 – PB2 - Pin7
Timers
  • one 8-bit Timer/Counter with compare modes
  • one 8-bit high-speed Timer/Counter
PWM3 PWM pins (PB0, PB1 and PB4)
Maximum DC Current per I/O Pin40 mA
Maximum DC Current through VCC and GND Pins200 mA
SPIOne SPI communication channel with pins: MOSI – GPIO5, MISO – GPIO6, SCK – GPIO7
I2COne I2C channel
Operating Temperature-55ºC to +125ºC
ADC4 Pins 10-bit ADC (PB2, PB3, PB4 and PB5)
DACNo Available
Enhanced USART Module1 Channel
SRAM256 bytes
FLASH ( Program Memory)8K bytes [10000 write/erase cycles]
EEPROM512 bytes
Comparatorone analog comparator with input pins as AIN0 – GPIO5 AIN1 – GPIO6
Low power consumptionActive Mode: 1 MHz, 1.8V: 300 μA
Power-down Mode: 0.1μA at 1.8V

Install:

  • By default the Arduino IDE does not support the ATtiny85. So, we need to add support for the ATtiny85 to the Arduino URL Board Manager:
    • Arduino -> Preferences -> Additional Board Managers URLs
      • Copy & paste the following URL (if you already have a board manager URL just add a comma before pasting):
        • https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
      • Also add the URL to support digistump:
        • http://digistump.com/package_digistump_index.json
    • Restart the Arduino IDE
  • Install the ATtiny Board Package:
    • Tools -> Board -> Boards Manager
      • Install attiny board package




  • Install Sensor Libraries:
    • Sensor NRF24L01:
      • NRFLite Library:
        • Arduino -> Sketch -> Include Library -> Library Manager
          • Install NRFLite library by Dave Parson


  • Prepare Arduino Uno to upload the code to the ATTINY85 microcontroller:
    • Set the Arduino Uno Into ISP Mode:
      •  We will need to "prep" the Arduino fist by uploading the ISP sketch to it.
        • Arduino IDE select File -> Examples -> 11. Arduino ISP-->ArduinoISP
        • The ISP sketch should open and upload it to your Arduino Uno
    • Arduino - Attiny85 wiring:

  • Making the ATtiny85 Arduino Compatible:
    • It's required to burn the Arduino bootloader onto the chip to make sure the chip will accept any programs uploaded via the Arduino IDE.
      • Tools -> Board scroll to the bottom select ATtiny25/45/85
      • Tools -> Processor -> ATtiny85
      • Tools -> Clock -> 8 MHz (internal)
      • Tools -> Programmer -> Arduino as ISP
      • Check that all wiring, capacitor, and board selections are correct
      • Finally select Burn Bootloader
  • Uploading the Sketch to Attiny85 chip:
    • Tools -> Board scroll to the bottom select ATtiny25/45/85
    • Tools -> Processor -> 8 MHz (internal)
    • Tools -> Programmer -> Arduino as ISP
    • Upload the sketch


Testing:


References:




If you like this content, feel free to