Setting up Arduino IDE 1.0 and 1.6 for ATtiny and Manchester library

Background

I am currently working on a project where I want to deploy small battery powered ATtiny based modules to track a few things and to communicate back to an Arduino or Raspberry PI.

While I was first trying to use the Virtual Wire library, I found out it couldn't handle the ATtiny85 that I was operating at 1 MHz. The reason for this is that it has a different timing from chips that run at regular speeds, like the Arduino itself.

Luckily there is an alternative in form of the Manchester Encoding library for Arduino. It works not just with the typical Arduino chips but also with various ATtiny variants. The only problem was that my Arduino IDE setup I had in place did not work with this library. In the following I will outline what the issue was and how I got around fixing it.

My original ATtiny85 setup

When I started out coding for the ATtiny85 I used sparkfun's excellent tutorial on how to set-up the Arduino environment to compile and upload ATtiny programs. At one point you need to install the hardware specs and code for the ATtiny family. Sparkfun and other places recommended David A. Mellis' repository, which I downloaded and which worked fine for the blink tutorial and a few simple projects. Even Virtual Wire was no problem with this setup.

Switching to arduino-tiny

As I mentioned in the beginning, I had to switch over to the Manchester encoding library. And when I did I got a bunch of error messages about symbols not being found:

error: 'TCCR2A' was not declared in this scope
error: 'WGM21' was not declared in this scope
error: 'TCCR2B' was not declared in this scope
error: 'CS21' was not declared in this scope
error: 'OCR2A' was not declared in this scope
error: 'TIMSK2' was not declared in this scope
error: 'OCIE2A' was not declared in this scope
error: 'TCNT2' was not declared in this scope

Through a post on Stack Exchange I found an alternative library for supporting the ATtiny hardware specs that seems more complete than the one I used before. It's called arduino-tiny and can be found on Google Code at the moment (though it might move since Google Code is in the process of shutting down).

Installing arduino-tiny in the Arduino IDE 1.0 was easy, but I had a few issues with Arduino 1.6 - though I eventually got it to work as well. I've done this on Windows but there shouldn't be a difference for doing this on other platforms.

Installing arduino-tiny for Arduino IDE 1.0

Installing arduino-tiny for Arduino 1.0 is pretty easy. The Google Code site has two archives at the moment, one is for Arduino 1.0 and the other one for Arduino 1.5. Download the package for 1.0 and then:

  • Extract the folder called 'tiny' from the archive you downloaded and put it into the .../Arduino/hardware directory. So in the end you'll have .../Arduino/hardware/tiny/...
  • Navigate into the .../tiny/avr/ directory and create a new file called "boards.txt".
  • Either copy the whole "Prospective Boards.txt" contents to this new file or search for the chip you have and only copy out this section. This will make your "Boards" sub-menu in the IDE less cluttered.
  • This should be it. Restart the Arduino IDE and you should see the ATtiny in the "Boards" menu. Try to compile e.g. a blink program, it should all work.

Installing arduino-tiny for Arduino IDE 1.6

With Arduino 1.5/1.6 they seem to have changed a bit about where the compilers live and how the hardware specs have to be defined. Luckily the arduino-tiny site has an archive for Arduino 1.5 which already has the specs changed to be compatible. However, I couldn't get it to work with the IDE after following the steps I outline for Arduino IDE 1.0 above. When I did this I got an error when I tried to compile saying that the IDE couldn't find the compiler:

Third-party platform.txt does not define compiler.path. Please report this to the third-party hardware maintainer.

Cannot run program "E:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-g++": CreateProcess error=2, The system cannot find the file specified

After looking at the Arduino 1.6 file structure I was surprised to not find the compilers and linkers in the tools directory. In fact I couldn't find them anywhere at first. After some digging around I finally found them in a zip archive under .../Arduino/dist/default_package.zip.

When I tried to Google about it I couldn't find much information, and maybe there is a better way to achieve what I want, but in the end I got it to work by unzipping parts of the archive to make the compiler accessible. Here is the full list of steps I needed to perform in order to compile for the ATtiny with the new Arduino 1.6 and the arduino-tiny hardware specs:
  • Following the same steps I outlined for Arduino 1.0, with the only difference that you need to take the arduino-tiny archive for version 1.5. At the time I write this there was no 1.6 package, but the format seems to be the same.
  • Next, take a look at .../Arduino/dist/default_package.zip. It contains a folder /packages/arduino/tools/avr-gcc/4.8.1-arduino2 (The exact name/version might be different if you got a newer/older version of the IDE, I am currently using 1.6.2.
  • Create a new folder .../Arduino/hardware/tools/avr and extract the contents of default_package.zip/packages/arduino/tools/avr-gcc/4.8.1-arduino2 into there.
  • The last thing you need to do is to edit .../Arduino/hardware/tiny/avr/platform.txt. Find the commented compiler.path line and replace it with:
    compiler.path={runtime.ide.path}/hardware/tools/avr/bin/
  • This should be all. Restart the IDE and try to compile a sketch for the ATtiny, including one that uses the Manchester encoding library.

Final Thoughts

I hope this post helps some folks to get set-up with their ATtiny and some more advanced libraries like the Manchester encoding library. I have the feeling that there might be an easier way to get the arduino-tiny hardware spec to work with Arduino IDE 1.6. If you know how to get around extracting the AVR compiler, please reach out and I will update this tutorial.

But in any way, I am glad I was able to unblock my wireless project which is using an ATtiny85 to transmit data using a 433MHz transmitter to an Arduino which has a receiver. I will create another article about this little project, but didn't want to spam it with these library and set-up issues.

Comments

electricbiscuit said…
many thanks for this tutorial sasha! I've been looking for a solution for Manchester lib to work for my 85s... for quite a while. Many thanks!
bogdan said…
what HW/SW do you plan to use for the RPi gateway?
Edwin said…
Interesting. I initially had some problems with the 'tiny' core you describe. Under 1.0.6 couldnt get my Manchester working. Only when I updated to the 'attiny' core did it work.
However... when I updated to 1.6.3... again problems with manchester.. can't find various timer related registers:
TCCR2A
TCCR2B
OCR2A
TIMSK2
TCNT2
all 'not declared in this scope'
No doubt this is because of the different file structure under 1.6.
oddly, during compile it can find my manchester core, but then it goes wrong.
I will study your solution a bit more because I am sure the answer is in there somewhere for the attiny core as you found for the tiny core
Edwin said…
Interesting article. I got Manchester working on 1.0.6 without much ado, however it does give a bunch of timer2 related errors on 1.6.3
as the core is the same (I guess), both being from MIT, I presume the error must be somewhere in the way the various core files are nested. Also, somewhere along the line I have installed a specific Attint45-85 related manchestercore. Maybe I need to bring that into the new structure as well
Sascha said…
@bodgan: I am currently working on my own software stack. You can follow my sevelopment here:
https://github.com/shaeberling/winston

But it's still very early.

@Edwin: Yeah they changes the structure between 1.0 and 1.6 which also gave me these headaches. This is why I wanted to document my solution in this blog post since I knew I and others would run into this problem.
bogdan said…
now that's something! android wear + rpi + sensors
Unknown said…
Was getting all these same errors with IDE 1.6.5. I think they fixed the issue with the default package.zip because I couldn't find that anywhere. Brought the tiny library into C:\Users\(username)\Documents\Arduino\hardware then renamed tiny/avr/Prospective Boards.txt to Boards.txt and all the options showed up in the Boards dropdown...voila! didn't even have to rename the compiler path.

Popular posts from this blog

Installing DD-WRT on the Linksys EA2700

Backing up a NAS to CrashPlan using a Raspberry Pi