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

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

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.

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:

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

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

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

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

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.

33 thoughts on “Tiny328 – A mini wireless Arduino clone”

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.

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

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)

@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.

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!

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

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.

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

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.

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.

@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.

Yes, with the compatibility mode in the latest Jeelib it can be used as a drop in replacement and mixed with RFM12B nodes, nice to have on your gateway etc. so you get the signal strength. More to come in the future hopefully.

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.

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.

Sorry I know this is an old comment so hopefully you worked it out but if you want to burn the bootloader using another Arduino it is the same procedure as described for the Uno here: https://www.arduino.cc/en/Tutorial/ArduinoISP

For a proper ISP programmer you would just hook up reset, power and ground and then:
MOSI to Pin 11
MISO to Pin 12
SCK to Pin 13

Check the board type is set to Uno and your programmer is selected and then burn bootloader.

Hi, nice design. However you need to do something with your system CLK. 16MHz is too high for 3.3 V (see 328 datasheet – Fig. 29.1). Either use 8 MHz resonator, or program fuse CKDIV8 to reduce it dovn to 2 MHz.

I did acknowledge in the post that it was slightly overclocked and suggested using 8MHz as an option but as JohnO says many 328 based boards run at 16MHz without a problem. It seems that Atmel are very conservative with their specs but the proof is in the pudding, I’ve had a number of these running continuously without a problem since this post was made in 2013. The ATtiny84 I used in the TinyTX also works very reliably out of spec too (3+ years). YMMV of course.