13
\$\begingroup\$

Inspired by this Make Magazine youtube video, I would like to use the ATtiny chips instead of the Arduino for most of my projects. The video author warns that some Arduino functions won't work on the ATtinys. Is there a complete list of what is and is not supported?

\$\endgroup\$
6
  • 1
    \$\begingroup\$ From what I read (which isn't admittedly very much), not all ATtinys have enough flash for the Arduino bootloader. You can probably still compile via Arduino and upload via AVRdude separately though. \$\endgroup\$ Commented Aug 27, 2013 at 4:17
  • 1
    \$\begingroup\$ It is not about the bootloader here (you can use an external programmer), but some libraries just don't compile to working code (I even understood not all will throw errors either). To the best of my knowledge there is no list of which functions work and which don't, but it doesn't hurt to learn understand how to program the hardware directly anyway because most Arduino functions come with quite a bit overhead. You mustn't want functions like pinMode(); and digitalWrite(); on an ATtiny, just right to the appropriate registers DDRx, PORTx directly. Many similar functions can be found. \$\endgroup\$
    – jippie
    Commented Aug 27, 2013 at 6:17
  • 1
    \$\begingroup\$ For the vast majority of Arduino projects I have seen, ATtiny chips would be plenty capable. For the most part, you would be programming via SPI instead of the bootloader, and writing code in C or Assembly instead of the typical Arduino copy and paste from tutorials. \$\endgroup\$ Commented Aug 27, 2013 at 6:38
  • 1
    \$\begingroup\$ While you can squeeze a lot into an ATTiny, do make sure your desirability comparison is to a bare ATmega in a similarly minimal circuit, and possibly a '168 from a price perspective (the yet smaller chips aren't necessarily cheaper in low quantities). \$\endgroup\$ Commented Aug 27, 2013 at 12:15
  • 1
    \$\begingroup\$ @ChrisStratton Good point. I just imagine that someone who doesn't know the difference between a bare ATtiny or even an ATmega chip and an Arduino board has no idea what any of that even means (ports, run-time debugging, software USB, etc), so I doubt they would ever need to use them. If so, then they really need to learn a bit more about what they are doing so they are capable of solving simple problems as they are encountered. Then again, I guess that's kind of the mindset of all anti-arduino people such as myself. \$\endgroup\$ Commented Aug 27, 2013 at 21:29

3 Answers 3

12
\$\begingroup\$

Update: To better answer the question, ATTiny's can do anything that don't require hardware the ATTiny's are missing, which include the hardware serial port, hardware i2c, or multiple interrupts. Since this is hidden away in the Arduino Libraries, unless you have a good understanding of how they work or read the actual library files, things like the Wire library (hardware i2c) will not work.

From http://forum.arduino.cc/index.php/topic,5582.0.html:

For example a ATTINY84 has 1 Interrupt, no Hardware UART (Serial or i2c) and a small handful of GPIO pins, less program space and much less ram but comes in a 14 pin package.

A ATMEGA328 has 2 Interrupts, 1 Hardware UART, more ram more program space and more GPIO, which is great, if you really need it.

Additionally, most ATTiny's have no hardware multiplication, so a compiler would have to do non-base-2 multiplication in software.

Finally, Arduinos rely on a bootloader instead of spi programming, so you need an ATTiny with atleast 4~8kb flash for them to work with the Arduino bootloader.

ATTiny44/45/84/45/2313 are popular as micro-Arduinos. They have about a fourth or eighth of the ram and flash of a ATMega328 that the official Arduino Uno uses.

There are many ATTiny's, so no single statement can be said about them all.

Also see here: http://hlt.media.mit.edu/?p=1695

\$\endgroup\$
2
  • \$\begingroup\$ Going Off-topic - Noticed even clones price are now up by at-least 50% to make space for these at-tiny ones? What you think? Also I think the Attiny boards (if any) makes more sense for blinking couple of leds than Arduino. I used Pro-mini (wavgat 1 dollar one) and even they are suddenly out of budget. \$\endgroup\$
    – Moons
    Commented Jul 26, 2021 at 14:28
  • \$\begingroup\$ non-base-2 multiplication guessing: non-power-of-2 multiplication \$\endgroup\$
    – greybeard
    Commented Dec 3, 2022 at 17:26
5
\$\begingroup\$

The most attinys don't have a hardware USART module, so you won't be able to communicate with them via serial. For some attinys instead of dedicated I2C and SPI hardware peripherals there is a simplified USI peripheral for which you have to write a bit of glue code to implement SPI or I2C communication. Some attinys don't have ADC.

In general, you have to be more careful when choosing attiny for your project, because those tend not to have full set of features available in Arduino's atmega328. For example attiny2313 does have an UART but does not have ADC, attiny44 does have ADC, but doesn't have an UART, etc.

Just check the Atmel microcontroller selection table and a datasheet at the beginning.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Lack of a hardware UART != won't be able to communicate via serial. \$\endgroup\$ Commented Aug 27, 2013 at 12:12
  • \$\begingroup\$ @ChrisStratton true, you can bit bang it of emulate via USI \$\endgroup\$
    – miceuz
    Commented Aug 27, 2013 at 12:14
1
\$\begingroup\$

A trivial if relevant point, over and above the excellent answers already posted:

Most Arduino boards, not counting the Pro Mini / Pro Micro and perhaps rare others, contain besides the main microcontroller, either a second AVR or some other USB interface part. This allows not just programming of the Arduino from a computer, but also run-time serial terminal debugging. The same USB connection also provides power to the Arduino.

While obviously the ATTiny's power requirement will have been addressed in your design, debugging code at run-time using terminal software can be quite handy.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Some attiny boards solve that problem with software USB. \$\endgroup\$ Commented Aug 27, 2013 at 12:11

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.