Programming with Adafruit Trinket

I’m very excited about using the Adafruit Trinkets, which are essentially small breakout boards for the Atmel ATtiny85 microcontroller.  It is intended to be used with the Arduino IDE (and I hoped this would be easy), and I found this to work well for compiling source code into a HEX file.  However, I was never successful getting the upload to work directly with Arduino IDE.  At this point, I learned to use avrdude from the command line (I’ve been working in Windows XP up to this point, but I’m switching to Ubuntu since MS doesn’t support XP anymore).

I followed the instructions from Adafruit given here.  These are well written and got me a long way.  I only had trouble uploading with avrdude.

I found this to be a two step process:

1.  I used this command to clear the on-chip flash:  avrdude -c usbtiny -p attiny85 -U flash:w:<hexfile.hex>

This would flag tons of errors that would require a CTRL-C to stop.

Inline image 1


2.  Then run this similar command:  avrdude -c usbtiny -p attiny85 -D -U flash:w:<hexfile.hex>

This will actually write to the flash.  If you don’t do step 1, you will get a verification error.

Inline image 1


Once the chip was programmed, everything worked well.  Many of the Arduino commands work with the ATtiny85.

Wireless Temperature Sensor

In continuing with my quest to automate my house, I want to have better temperature control of various rooms.  My goal is to create a few digital thermometers connected to the nRF24 radios that I have started working with.  I’m using an Adafruit Trinket microcontroller, a DHT11 temperature and humidity sensor, and an nRF24L01+ 2.4GHz radio.  I wired together a quick prototype pictured below.


The Trinket has 5 pins:

– D0: SPI Clock to nRF

– D1: SPI Data Write to nRF

– D2: SPI Data Read From nRF

– D3: SPI Chip Select Bar to nRF (CSN)

– D4: Chip Enable to nRF (CE) \ Data Wire to DHT11

Notice how I had to overlap the 5th Trinket pin.  The nRF was powered down in software in order to read from the DHT11.  I learned several important things about programming with the Trinket.  I’ll discuss that next time.