Tiny328 – A mini wireless Arduino clone

Tiny328
The first Tiny328 successfully reflow soldered

So here is the reason for the last couple of blog posts.

This is my first venture into designing an SMT board and apart from the practice run I did with some breakout boards it is the first time I’ve attempted to solder anything as small as a TQFP package or the tiny 0603 passives (1.6 x 0.8mm) used here. It’s something I’ve been wanting to try for a while and I’m happy to report that it all went well and yes, you can definitely solder these things at home with a minimal outlay.

ATmega328 + RFM12B * TinyTX = Tiny328

The original TinyTX wireless sensors were named as such due to the use of the ATtiny microcontroller rather than because they were tiny, this one uses the ATmega328P but the Tiny name still seems to fit as at only 23 x 36 mm its actually slightly smaller than both the previous TinyTX PCBs. So Tiny328 it is.

The idea behind the Tiny328 (apart from the intro to SMT) was to make something that is as small as the TinyTX but with a lot more I/O and full Arduino compatibility without any messing around with different cores or USI implementations of SPI/I2C. I went through several design iterations with this board, originally starting with a square board with the I/O pins around all four edges but eventually decided on something more like the Arduino mini, Teensy or Moteino designs with the I/O pins down the long edges spaced so that it is breadboard and stripboard friendly which makes it a lot more universal. Other than a (to me) more sensible pinout than the mini the other main differences are the use of an external FTDI adapter instead of an on board FTDi chip (keeps it simple and low cost) and on the bottom side of the board is a footprint for an optional RFM12B/Alpha TRX433S or Ciseco SRF transceiver. With those decisions made the final size sort of dictated itself and it couldn’t really be any smaller than it is without making compromises somewhere.

Apart from the requirement for a separate FTDI programmer the Tiny328 can pretty much do everything that an Arduino Duemilanove or Uno can do as all the pins are broken out to the standard 0.1″ spaced headers and by using the standard Uno bootloader it is fully compatible with the an unmodified Arduino IDE.

Here’s a comparison between the TinyTX and the Tiny328:

From the left: TinyTX2, TinyTX3, Tiny328 front and rear
From the left: TinyTX2, TinyTX3, Tiny328 front and rear
TinyTX3 Tiny328
Microcontroller ATtiny84A-PU ATmega328P-AU
Logic Voltage VIN* VIN*-3.3V
Input Voltage (recommended) 2.7-3.8V 2.7-5.0V
Input Voltage (limits) ~2.0-3.8V ~2.0-6.0V
Digital I/O Pins 6 (1 with PWM) 14 (6 with PWM)
Analogue Input Pins 5 (shared with digital pins) 8 (6 can be used as digital)
DC Current per I/O Pin (max) 40 mA 40 mA
DC Current all I/O combined 200 mA 200 mA
Flash 8 KB 32 KB (0.5 KB used by bootloader)
SRAM 0.5 KB 2 KB
EEPROM 0.5 KB 1 KB
Clock Speed 8 MHz (internal oscillator) 16 MHz (resonator)
Hardware I2C No Yes
Hardware SPI No Yes
Hardware USART No Yes
USI Yes No
Dimensions 22.9 x 41.9 mm 22.9 x 36.3 mm

As a bonus the TQFP packaged version of the ATmega328 actually has 2 more analogue inputs (8 v 6) compared to the DIP version although the two extra pins are analogue only and cannot double as digital pins like the other six.  So in total we have up to 14 digital I/O pins, 8 analogue (of which 6 can be used as digital) as well as the benefits of proper hardware SPI and I2C interfaces so no more faffing around porting code and libraries to work with the arduino-tiny core and USI. Along with the extra flash and RAM it also makes adding things like the WIZ820io ethernet module a practical proposition.

Underside showing RFM12B
Underside showing RFM12B

Even after adding the optional RFM12B radio module we still have a potential 17 pins that can be used for other things compared to 2 for the TinyTX2 or 6 for the TinyTX3.

If the RFM12B is installed then the following pins will be in use:

D2 – RFM12B Interrupt
D10 – RFM12B Slave Select
D11 – SPI MOSI (can be shared with other SPI devices)
D12 – SPI MISO (can be shared with other SPI devices)
D13 – SPI Clock (can be shared with other SPI devices)

I’ve also brought the nFFS pad from the RFM12B footprint out to D4 allowing two way serial if using the Ciseco SRF as an alternative to the RFM12B. When using the SRF only the D2 and D4 pins will be occupied.

I’ve built these with a 16 MHz resonator, yes that is slightly overclocked but this has proved to be fine in the past and a slower resonator could be fitted or the internal 8MHz oscillator could be used if required.

Here is a Teensy style pinout diagram for the Tiny328 showing the various pin functions:

Tiny328_Pinout

Power

Like the TinyTX this will run on a couple of AA or AAA batteries connected to one of the the “3V3″ pins but there is also a 5V input which allows the use of a 5V FTDI programmer as well as power sourced from USB or the common USB type mains adapters. The MCP1700 low dropout voltage regulator can actually take up to 6V input and deliver up to 250 mA of current although the practical limits are dependent on the input voltage, output current, heat dissipation and ambient temperature, some quick calculations tell me that with a 5V input it will allow up to 205mA (at a max ambient temperature of 40°C) but drops off to only 132mA at 6V. With a 4.2V input the full 250mA should be available but bear in mind the ATmega can only handle 40mA on each I/O pin and 200mA overall. The regulator has over current and over temperature protection and will shut down and restart when back within limits so it should survive if accidentally pushed too far.

With the RFM12B I’ve tested it as working down to almost 2.0V although the official lower limit for the RFM12B is actually 2.2V so YMMV and or course you will need to factor in any additional components/sensors etc.

Battery life should be comparable to the TinyTX, in fact one of my earliest sensor nodes was built on stripboard with a DIP ATmega328P, RFM12B and DS18B20 temperature sensor and it is just nearing its second birthday running on the same set of AA batteries which currently stand at 2.75V. Pretty good considering a lot of that time it was running early code without any optimisations and that it is also my furthest away node so needs to resend quite often.

The first three boards off the line
The first three boards off the line

Code and Programming

Most of the code for the TinyTX on GitHub will run on this unmodified, just watch that some of the TinyTX examples use the D10 pin for sensor pins where on the Tiny328 this is the SPI select pin for the RFM12B so that will need changing and anything that uses I2C like the BMP085 pressure sensor will need converting to use the proper hardware I2C instead of the USI version, I’ll get round to uploading a working version of that at some point.

For uploading the code there is an FTDI header onboard for easy programming and serial debugging, for the initial flashing of the bootloader I made a simple programming jig with pogo pins which means I don’t have to fully populate headers that aren’t otherwise required and saved having to find space on the board for a dedicated ICSP header. I think I’ll make one of those for the FTDI too.

To allow low voltage use the brown out detector (BOD) should be set to 1.8V instead of the default 2.7V, to do this change the uno.bootloader.extended_fuses value in the Arduino boards.txt file from 0x05 to 0x06 before flashing the bootloader.

Pogo pin jig for flashing bootloader
Pogo pin jig for flashing bootloader

Cost

Thanks to the low cost of SMT components the cost per board is comparable to the TinyTX despite the increased component count and functionality, without the RFM12B these cost me £4.44 each to build including the PCB. As usual I had the PCBs made at SeeedStudio which was £10 for 10 including delivery to the UK.

Stencil ready for paste to be applied
Stencil ready for paste to be applied

Building it

Of course this is open source hardware and you can download the Eagle files or Gerbers below. For anyone who has built the previous TinyTX boards and is put off by the surface mount components I would say give it a try. As I said above this is my first go with TQFP and 0603 components and building it wasn’t difficult at all, I can definitely see why a lot of people say SMT is actually easier than through hole once you get into the swing of it and I’ll be doing more designs like this in the future.

I did make a few things to help, a stencil really isn’t necessary for something this simple, applying solder paste with a cocktail stick or similar is good enough and you don’t need to get it on the individual pins of the TQFP as the capillary action combined with the solder mask should make the solder flow where you want it and if you do get any bridges it is easy enough to clean up with some desoldering braid.  That said I did make a stencil as an experiment, I cut it on 100 micron acetate overhead projector transparency using a vinyl sign cutting machine at work, this was pushing the cutter well beyond its limits and cutting holes for the individual pins on the TQFP wasn’t possible but I got something workable out of it with some perseverance, it’s nice to have but certainly not necessary. The vacuum pick up tool I made also helps for placing the components quickly but again it isn’t absolutely necessary, in fact the board in most of the pictures above was actually placed with tweezers as I was still waiting for the 0.6mm tip for my pick up tool at the time.

Tiny328 with the ILSoft 1.5" OLED breakout
Tiny328 with the ILSoft 1.5″ OLED breakout

Next steps

So now I know it works and I can build it, it’s time to get on with some of the add ons I have planned. I’ve got ideas for various power options, sensors and batteries (a la PanStamp), WIZ820io ethernet, LCD and OLED displays, the WMOi3 GSM module, GPS module, arduino shield converter and more. The TinyTX isn’t dead either, it still has its place and I have roughed out a board for an even tinier TinyTX using SMT components that may see the light of day at some point.

Downloads
Schematic (PNG format)
Eagle files (or on Solderpad)
Gerbers

BOM
1 x Tiny328 PCB
1 x ATMEGA328P-AU Microcontoller
1 x SMT ceramic resonator 16.0MHz
1 x Microchip MCP1700T-3302E/TT 3.3V SOT23 LDO Regulator
1 x Hope RF RFM12B or Alpha TRX433S or Ciseco SRF (optional)
5 x 0603 0.1uF ceramic capacitors
1 x 0603 1uF ceramic capacitor
1 x 0603 10uF ceramic capacitor
1 x 0603 10K resistor
2.54mm male or female headers as required
Wire for RFM12B antenna, eg. 0.6mm solid core (165mm for 433MHz, 82mm for 868MHz)

 

Open Source HardwareThis is Open Source Hardware licenced under a
Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) licence.

 

25 thoughts on “Tiny328 – A mini wireless Arduino clone

  1. Very nice, I like getting smaller and smaller but my eyesight is the limiting factor, also have you thought about using bluetooth modules instead of RF, I’ve used them so I can use my Android phone as the display.

    Also I’m starting to like the OLED displays but the ILSoft, although nice, is a bit pricey for me yet.

  2. Hadn’t thought of Bluetooth, range would be the limiting factor I guess.

    The OLED is nice but I agree it is a bit pricey, if you want a much cheaper alternative these 1.8″ LCDs are good: http://www.flickr.com/photos/41533053@N03/8523094084/

    Under £4 delivered on eBay and they work well with the Adafruit ST7753 library:
    http://www.ebay.co.uk/itm/1-8-Serial-SPI-TFT-LCD-Module-Display-PCB-Adapter-Power-IC-SD-Socket-128X160/261281402779

  3. I found that bluetooth worked across my house OK but the main reason for me was to create my own control interface on the phone using MIT app inventor.

    There are two versions of the BT module on Ebay, the HC-05 and HC-06, I found the HC06 was the better one for straight serial comms, the HC-05 required an extra button to put it in AT command mode.

    I also made my own carrier PCB from Seeedstudio.

    I like the LCD display, for the price I might as well get one for the collection ;-).

  4. I’ve added links to the parts from RS that I used as a couple of people had asked on Twitter. The price seems to be fluctuating on the ATmega328 a bit at the moment, for the last lot I paid £1.52+VAT each but they are currently £1.92+VAT for 5+ (still a good price).

    For the RFM12B/Alpha 433 I’ve linked to the 433MHz version which is what I use but the 868MHz version is also available from RS. If you are after keeping the cost down though the best place I have found for these is the Jeelabs shop which is €29.50 for 6: http://jeelabs.com/products/rfm12b-433-mhz

  5. Nathan

    Looking forward to your next update as this looks exactly what I need to roll out some Openenergymonitor nodes. I couple of thoughts/suggestions:

    1. Could you add a couple of mounting holes to your PCB design as it would make securing the board into an enclosure and making sure I do not short anything much easier

    2. Any chance of making the wireless section modular, perhaps using a module based on your RFM12 breakout board which has been very useful. As the RFM12s are looking pricey compared to the likes of the 2.4ghz boards kicking around ebay it would be good to be able to swap the wireless as things evolve. Perhaps adding a small through hole pad to your breakout design so you could use RFM12 style components or nRF24L01s would work (assuming they both have similar pinouts requirements)

    Keep up the blogging

    Gary

  6. Interesting… I use RFM from here…

    http://www.tme.eu/en/katalog/?idp=1&search=%7CRFMQ2&cleanParameters=1#search=RFM12&s_field=accuracy&s_order=DESC

    They have them for 3.3€/piece. Shiping next day. Bought ~ 100 pcs in total.

    I expected something like Attiny in SOIC14 packaging with 1,2V stepup on it… :-)

    I did a lot of SMD soldering, but wth 1206, no reflow… but will give it a chance…

    Right now i will stay with Attiny84.

    Is apha ocmpatible with RFM12 JeeLabs library? What is the difference there?

  7. @GaryP Yes mounting holes would be a good idea, will add that for the next revision. One of the add on boards I was thinking of is for the nRF24L01, hadn’t thought of doing one for the RFM12B but that’s a good reason to do so. I’ll have to have a think about the best way to do it.

    @PACi An SMT version of TinyTX with SOIC14 is in the pipeline. The Alpha version is functionally identical to the RFM12B so they are interchangeable, I believe it is made under the same IP licence.

  8. Nathan

    If you wanted to keep the bottom of the main board clear perhaps a mini-shield might be a way to mount the RF boards. Most of the necessary connections for the RF board look to be down near the power in connections on the main board and maybe a little juggling could get the all down there. Or perhaps a bottom mounted shield, although this would make the main board a little top heavy unless the other end of it was somehow propped up.

    I think I saw something recently about Seeed Studios now doing a full prefab service for smaller runs – did you have a look at this when you ordered your boards? I have done some 0805 soldering before but never a TQFP or 0603 before – might need a magnifying glass and some practice!

    All the best

    GaryP

  9. Nathan

    Your picture looks pretty much what I was thinking of.

    I think I could probably hand solder these 2 parts quite easily – it is the MCU that is going to be more challenging.

    It might be worth increasing the PCB size very slightly (unless you are trying to squeeze it into one of Seeed’s standard sizes. Seeed are stocking the Dangerous Prototypes sick of beige cases which have a good looking 40 mm x 40mm one for $3 which looks pretty good value

    http://www.seeedstudio.com/depot/sick-of-beige-basic-case-v1-40mm-square-dp4040-p-1327.html?cPath=55_60

    One thought for you on the FTDI connection. I am sure I have seen someone extend their pads to the edge of their PCB so that they could then just push on a double row header/socket to make the contacts and this could then just be unplugged once the programming is done. It might need some matching pads on the other side of the PCB and some vias just to make sure of a good connection.

    I know lots of ideas – if only I could use CAD ;-)

  10. Great ideas, keep them coming. I know exactly what you mean about the edge connector, Martin Harizanov uses that for the ICSP connector on his Funky boards and I was thinking of doing the same on a new SMT ATtiny board but hadn’t thought of doing it for the FTDI on this. Should be possible to have the extended pads and the holes so you still have the option to fit headers too.

    If you ever fancy having a go with Eagle these video tutorials are a good start, wish I had seen them before I started, would have saved a lot of head scratching. It’s not the most intuitive program but very powerful once you get to grips with it. http://www.youtube.com/watch?v=1AXwjZoyNno

  11. GaryP,
    Thanks for the link to the cases on Seeedstudio, what a brilliant idea, just right for the 50x50mm PCBs I get made.

    I always forget about the mounting holes until I’ve no room left, now I can use the eagle template, brilliant idea.

  12. Nathan,

    Just discovered your post. Are you selling these units?

    I’ve tried Modeino but it has two severe limitations:
    1. Interrupt 0 is used internally and pin 2 is off limits.
    2. ISR routines will not compile when used with the RFM69 libraries.

    I like the RFM69 transceiver much better than any of the other brands on the market because of its range and clarity. However, the one-man-band who makes the Modeino sells it as is, is not open to mods, and won’t even take a look at the library to see why it won’t compile. I don’t need a vendor who’s not interested in improving (or fixing) his product.

    If you intend to market these and they overcome the two obstacles I’ve listed, I would love to hear from you.

  13. No, I’m not selling them, it’s just a hobby for me.

    It also uses interrupt 0 which is the default in the Jeelib RF12 library, it could be moved to INT1 if you really needed D2 free for some reason. Not had any issues with ISR.

    There is a variation of the RFM69 with the same footprint as the RFM12B (RFM69CW) and that could be used with the Tiny328, I’ve had a play with one using the Moteino library but I’m waiting for the Jeelib one to be finished before going any further with them as that is being designed to be backwards compatible with the standard Jeelib RF12 lib.

  14. Hi Nathan,

    are your sketches for the TinyTX sensors fully compatible with JeeLib/Nanode communication protocol?
    Meaning, can they talk to an existing Nanode RF base without modifying the sketch on the Nanode RF?

    Thank you!

  15. Nathan,

    Once again great post but I had a couple more questions on the RFM69CW.

    Have you looked into it any more on your side for replacing the RFM12B?

    When you did your testing I guess you were using lowpowerlab library for testing? Was there much change to your code?

    Thanks Josh

  16. @Lucas Pretty much, I am using the same packet format and sending structs but you need to make sure the payload structure matches on both ends, eg. if you are ending three ints you need to have the struct on the receive end set the same way.

    @John, I haven’t done a panelised version of this yet but I know someone who did so will ask them.

    @Josh, When I first tested them I only tried with the lowpowerlab code as a quick test. There is now a RFM12B compatible RFM69 driver in Jeelib so I’m using that now, there hasn’t been a formal announcement of it yet but jcw mentioned it here: http://jeelabs.net/boards/6/topics/4050
    This currently allows the RFM69 to mixed into a RFM12B network but without using any of the extra features*, hopefully that will be added in the future, it is part of the plan I think.

    *Not quite true: If you use a RFM69CW on the receive end then you do get the RSSI (signal strength) of each node including the RFM12B nodes which is handy.

  17. If you want to power from a couple of AA batteries you can just connect to one of the 3V3 pins and ground to bypass the regulator, that’s what I have done. I use a 5V FTDI lead for programming so need the regulator for that.

  18. I’m liking the Tiny328 design. Due to another project I was working on, I was designing a wireless daughter board to fit on my minDUINO v1.5 minimal Arduino clone. It used the RFM69HW. However I’m going to modify it to use the RFM12b. I’ll be watching here for future developments.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.