1

Please mind that this is an "example" question.

How to make a "tiny arduino"?

I've ordered a bunch of ATtiny85's off E-bay, they're like tiny Arduino's.

I've set up the latest Arduino IDE and would like to run the blink example.

My process so far:

Wiring

enter image description here

Code

(The blink example)

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}
0

1. The Tiny

The ATtiny differs a little from the Arduino, don't expect it to be "fully compatible". It's a microcontroller which is just a part of an Arduino and not a full Arduino itself.

It's more of a device for "advanced users" and gives some more flexibility (at cost of usability). You can easily add this microcontroller on a breadboard, since putting a full Arduino on a breadboard makes little sense.

1.1 USB?

Since the ATtiny is a microcontroller (like the ATmega on an Arduino) and not a development board (as an Arduino), it does not have an USB connector. The ATtiny series also does not have hardwareUART (Rx/Tx). The

You'll have to take care for a steady power-supply to your Microcontroller and the programming will be a little more tricky (details further below). It is however possible to use SoftwareSerial and a customized bootloader. My ATtiny85 runs software serial with 115200 fine, though I have found a post which states that the internal oscillator should be tuned for a reliable connection.

1.2 RAM/program memory

The ATtiny has less RAM and program memory. This essentially means your program can't be as 'big' as on a normal Arduino. It also means that you can't use as much variables. A program for the tiny should be "small" or very efficient.

1.3 "Speed"

My ATtiny came with 1Mhz internal clock set, but if you change the fuse bits you can make it run at 8Mhz. An standard Arduino has a 16Mhz clock on the board. So your code would run 16x slower on default and 2x slower on "max". You could use an external clock for the ATtiny, but that eats up 2 pins. The cool thing is, when you set it to 1Mhz it can run on about 2.7V (check datasheet first).

Arduino                   16Mhz
ATtiny (standard)         1Mhz
ATtiny (set fuses)        8Mhz
ATtiny (external crystal) up to 20Mhz

Higher Mhz is faster. Keep in mind that 1Mhz is roughly 1000000 instructions per second, which is still blazingly fast and good enough for most occasions, especially on such a tiny device.

2. Programming the Tiny

Most of the ATtiny's don't come with a customized (software serial) Arduino bootloader. This essentially means that you have to burn a custom bootloader by yourself or use another type of programmer. You should really watch the video from Ben Heck. He explains that Arduino boards have an USB converter on board and have custom code that is able to "bootload" your Arduino. But that ICSP/ISP programmers are used to upload programs without a bootloader/uart connection.

2.1 The programmer

You've got a load of options, check the "Programmer" item in the "tools" tab in your Arduino IDE. I'm using an USBasp which can be bought on ebay for as little as 3€. You should get one that has a selectable voltage (3.3V and 5V).

(If your ATtiny85 already has the bootloader, which is unlikely, you can use the software rx/tx pins for uploading)

2.2 Preparation

Check your microcontroller if it really is a ATtiny85 my E-bay reseller actually had one ATtiny45 included, which lead to an "error" when trying to upload.

The Arduino IDE does not know the "ATtiny board" so you can't select it easily. You'll have to let the IDE know that the ATtiny can also be programmed.

I found a very nice tutorial that describes how to do this.

  1. Open the preferences dialog in the Arduino software. Find the “Additional Boards Manager URLs” field near the bottom of the dialog.
  2. Paste the following URL into the field (use a comma to separate it from any URLs you’ve already added): https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
  3. Click the OK button to save your updated preferences.
  4. Open the boards manager in the “Tools > Board” menu.
  5. Scroll to the bottom of the list; you should see an entry for “ATtiny”.
  6. Click on the ATtiny entry. An install button should appear.
  7. Click the install button. The word “installed” should now appear next to the title of the ATtiny entry.
  8. Close the boards manager. You should now see an entry for ATtiny in the “Tools > Board” menu.

2.3 Changing the internal clock

Some interesting post I found told me that you can change the internal clock/oscillator to 8Mhz by selecting 8Mhz (internal) as the clock and pressing the "Burn bootloader" button. This won't flash a bootloader (since that makes little sense on a Tiny85) but does change the fuse-bits.

2.4 Code

You'll not get away with the standard blink tutorial. It uses digital pin 13 (the tiny only has 8 pins).

Mind that you might have to upload using Ctrl+Shift+U (or sketch->Upload with programmer).

I used the diagram below to check the pins (from highlowtech.org) enter image description here enter image description here

3. Hardware

Your "schematic" isn't complete, I don't see a way to program or power the microcontroller. And you might want to take some precautions.

I personally think a well-drawn schematic looks better as a "breadboard view".

enter image description here

The 10Kohm pull-up resistor on the reset pin is not 100% neccesary according to the datasheet. But the Uno has one in it's reference design (which I use as a reference).

There are two capacitors, one "big" capacitor as a reservoir. If one device suddenly pulls a lot of current, this capacitor will handle that. The smaller decoupling capacitor will damp the noise of other IC's or switching supplies. It may work withouth these, but your circuit will be more reliable with them. Mind that the decoupling capacitor should be (physically) close to the IC.

You can power the board through the programming header, but mind that you'll need a smooth voltage between (most likely) 3.3V and 5V. If you want to power it with a bigger voltage (9V battery) then you'll need a voltage regulator.

  • Many of your "you can't" claims with regard to serial and USB are incorrect - there is no hardware support, but both regularly done with software implementations, including for bootloader use. It's not clear that an incomplete presentation in the necessarily limited form of an answer here is doing people a favor when there are much more developed presentations elsewhere that could be pointed to instead. Stackexchange does not exist to duplicate the web over again... – Chris Stratton Apr 3 '16 at 15:03
  • @ChrisStratton I've updated the statements, I must agree that they were atleast half-true, since uploading the "custom bootloader" also takes an other type of programmer. I've combined (and referred to) multiple sources which can be of great ease. Another point is that someone who is relatively new can easily find all the important info on one page, and more details if they look a little further. – Paul Apr 3 '16 at 19:23
  • @ChrisStratton I've made the post "community wiki" so that everyone can contribute (I won't get points for upvotes). I believe it would be better if everyone (who wants to research ATtiny's) can contribute to an open "reference" or "starter guide". Which would work better as everyone creating their own blog ;) – Paul Apr 3 '16 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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