Libraries compatible on ATtiny ?

Status
Not open for further replies.
I am currently researching the process of moving from my Teensy 3.2 to an ATtiny 85. Do the libraries that are used in Teensy code seamlessly translate to the ATtiny?
For example, in my first program I am using the following libraries:
  • Snooze
  • Bounce
  • RH_ASK - Radiohead for RF comms

It seems that for the RF comms to work I will just need to change the txpin in the Radio Head header file. Is this correct?
And how do I know if the Snooze/Bounce libraries will work?
While we're at it: in other programs I am also using the libraries Wire, SPI, ClickEncoder, TimerOne, and EEPROM.

I will also need to add in a 16-bit ADC with I2C comms (https://www.adafruit.com/product/1085) since the ATtiny only has a 10-bit ADC.
So pin 5 and 7 of the ATtiny will be used for I2C.

The pins currently being used on the Teensy 3.2 for my first Teensy->ATtiny conversion are:

Thanks in advance,
Blake
 
I am currently researching the process of moving from my Teensy 3.2 to an ATtiny 85. Do the libraries that are used in Teensy code seamlessly translate to the ATtiny?
No, if special teensy features are used :) I guess Snooze is not compatible. And chances are not good for other Teensy-libs.
Best is, to ask in an other forum which provides support for your ATtiny.
 
Last edited:
I gave up on the ATtiny85 because of all of the missing libraries and extremely limited memory. Instead of Wire.h for i2c, you have to use TinyWireM.h (for master mode i2c) and TinyWireS (for slave mode i2c). I recall the PWM support was different also. Forget about Serial debugging. Only 6 data pins (with one of them being the reset pin, which means you really only have 5 pins). No SPI support, you will need to bit bang it (and since SPI takes 4 pins, it may be a challenge).

I don't know about others in the ATtiny lineup, but it may be simpler to go to ATmega328p chips (i.e. chip in Arduino Uno), as the environment will be a lot closer to the Teensy.
 
The ATtiny is a radically different architecture than Teensy, it even differs a lot from AVR Arduino which is of the same family of ATtiny. Only the most basic stuff from Teensy (actually: the most basic stuff in the Arduino IDE) work for ATtiny. E.g. the clock generation is totally different (ATtiny uses an internal oscillator) making most communication libraries incompatible.

What is the particular reason you want to use an ATtiny?
 
Michael,
Ok, that sounds like a nightmare. Thank you for your input.
I will probably go ahead and order some ATmega328p chips and try it out.
 
Last edited:
Epyon,
I wanted to use an ATtiny because it's tiny. I wasn't using very many pins for this particular unit, so I thought an 8-pin chip would be great for minimizing the size of my PCB. But it seems like this is not worth the hassle of dealing with the incompatibility between Teensy and ATtiny.

Would you suggest going the ATmega328p route?

My goal right now is to shrink my project down and present it as cost- and user-friendly.
 
I've never used raw ATmega328p's, but I know a lot of people did/do. The through hole version of the 328p has 28 pins, so it is going to be as long as a Teensy, but it will slightly smaller width at least for the chip. Once you add in all of the other parts, it probably will be the same size. On ebay, it is a few dollars per chip, depending on the quantity.

If you need to go smaller, you have to move away from through hole chips, and go to surface mount chips. Which limits what you can do unless you are really good at soldering and/or have a pick/place machine that can mount the parts.

I know there is the TinyDunio project that offers small circuits that fit snap together with a common bus, but the basic unit is the same price as the Teensy 3.2 (and you need to get some add-on cards to use it).

A lot of people have moved to the ESP8266 which includes built-in wifi. You can get cheap units (without the programming dongles) for a couple of dollars. You can buy integrated units that include a USB serial connector for programming for maybe $7-10, or you can buy a dongle and program the units with the dongle, or with some of them that use a common infrastructure, you can program them over the internet. Size wise the units range from about 2/3 the size of a Teensy, to a little bit bigger.

Digispark came out with their Oak system that has an infrastructure with various shields, but their web store hasn't been updated in awhile (last news was June 2016 announcing pcbs.io, which they have since sold). There does seem to be traffic on the forums. Even though I purchased 3 oaks through their kickstarter, I haven't done anything with them. The original Digispark was an ATtiny85, and as I said, I had gotten used to the environment on the Arduino Uno and then Teensy, and it was too constricting to me.

The follow on successor to ESP8266 seems to be ESP32.

In terms of the ATtiny85, it was a decision because I tend to only deal with 1-2 units. If I were making hundreds of units, it might be worth it to fit everything into a small space. But since I'm doing it for fun, I would rather the easier route of using Teensys where Paul puts a huge effort into to providing useful products and more especially updates where things get fixed. When I was using Arduinos, at the time, there rarely was any fixes to the infrastructure (it appears to be a little different now).
 
Last edited:
Have used some Atinys and they are OK for single function tasks where you can look at your entire code in your head and trace it's flow and all the possible conditions. As soon as you have multitasking going on you spend more time coding debug indications than you spend getting your actual code to work.

So critical question is finding a radio library that works on them and would suggest the digistump forums as the place to search for that. If you are finding success stories there I think they had made a sleep function that worked, though I think there were limits since it didn't have a true wake up timer.

Certainly you will be needing to re-write any teensy code from scratch. If this is a serious project then would suggest getting some digistump or equivalent boards and seeing what works since that's the easiest way to a small footprint. If cost and space matter you need to start trading dev time/BOM/capability against whatever the current 8/12 pin offerings are since the entire atiny line is pretty ancient. On the other hand ancient also means reasonably well documented and understood.

If you want to half size a Teensy then a 328 will give you a nice google advantage, but never be that much smaller than a teensy, nor much cheaper.
 
Epyon,
I wanted to use an ATtiny because it's tiny. I wasn't using very many pins for this particular unit, so I thought an 8-pin chip would be great for minimizing the size of my PCB. But it seems like this is not worth the hassle of dealing with the incompatibility between Teensy and ATtiny.

Would you suggest going the ATmega328p route?

My goal right now is to shrink my project down and present it as cost- and user-friendly.
I agree with Michael: the ATmega328p would be a low-cost alternative that still retains much of the code compatibility, but unless you go for the TQFP version space savings will be negligible compared to Teensy. You will also lose the convenience of programming and communicating with the chip through USB like you do with Teensy, unless you flash the Optiboot bootloader onto the ATmega and use a UART-to-USB chip.

The old adage 'sell before you optimise' would seem to apply here. If you are in the prototyping/small production phase there really isn't much need to lose your head over cost optimisations. You're better of using your time to test functionality, build on your customer relations, act on their feedback etc. When the functionality of your product is finalised and completely debugged, and sales are taking off, then would be good time to invest time in cost optimisations :) .
 
Will agree that it is frustrating to be looking at the size of a Teensy and know there are nice and compact micro's that would happily do the job you need with three lights and a button but they seem to be missing from the hobby market, just showing up in finished devices of variable quality. I'm guessing the margins just aren't there on a board that would need to be selling for <$5 to sustain the scale of code development needed to challenge the atinys with all their quirks.
 
Last edited:
Will agree that it is frustrating to be looking at the size of a Teensy and know there are nice and compact micro's that would happily do the job you need with three lights and a button but they seem to be missing from the hobby market, just showing up in finished devices of variable quality. I'm guessing the margins just aren't there on a board that would need to be selling for <$5 to sustain the scale of code development needed to challenge the atinys with all their quirks.

Well also, there is the fact that if you want to go smaller, you are out of the realm of through hole soldering. Sure there are people that can easily do QFQ soldering or have their own pick & place machine, but the small size limits the number of people entering the club.
 
I'm guessing the margins just aren't there on a board that would need to be selling for <$5 to sustain the scale of code development needed to challenge the atinys with all their quirks.

Not with the ESP8266 on the market. It pretty much owns the $5 range with quirks, and has far more capability than anyone could ever hope to get from an ATTINY.
 
Status
Not open for further replies.
Back
Top