Notes on using the new ATtiny chips with the Arduino IDE

This post contains notes on the use of the ATtiny824 micro-controller with the Arduino IDE. I do not go deep in to the inner workings of the micro-controller. It is more like a quick reference guide.

I am using the megaTinyCore by Spence Konde and most of the pictures and code are from there. A big thanks to Spence Konde. Great work!

Pinout

The ATtinyX24 pinout (enlarge)

Programming

To program the chip you need to make a UPDI programmer. I used the instructions here to make one with an Arduino nano.

Once you have installed megaTinyCore to the Arduino IDE use these settings and you are good to go:

Code examples

Test circuit for the blink sketch

Note: The pins can be address as PIN_Pxn, where x is the port (A or B) and n is the bit number (0-7). E.g. pin 4 (PA6) is PIN_PA6.

Serial port

Test circuit for the serial port sketch

Note: R1 and R2 make a simple level translator (5V to 3.3V).

ADC

Note: More details here:

Test circuit for the ADC sketches

1. Reading at various resolutions with VDD as analog reference:

2. Differential reading between PA4 and PA5 using the internal 2.048V analog reference:

3. Reading VDD

4. Reading the internal temperature

Reading the internal temperature sensor of the ATtiny824. Page 415 of the datasheet. The typical accuracy of the sensor is ±3 °C (page 490 of the datasheet).

Watchdog timer

Note: Read more here.

Just enabling the WDT and resetting it.

Pin interrupts

Test circuit for the pin interrupt sketch

Note: Read more here.

I2C

Test circuit for the I2C sketch

Note: The test sketch is the WriteReadByte.ino from this library. (Copyright © 2012  Julien Le Sech)

1-Wire (kind of...) DHT11 temperature and humidity sensor

Test circuit for the DHT11 sketch

NOTE: Library and example downloaded from microbot.it. Change the pin allocation to PIN_PA4.

To be continued...