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:
|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)|
|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.
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:
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.
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 0×05 to 0×06 before flashing the bootloader.
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.
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.
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.
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)
This is Open Source Hardware licenced under a
Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) licence.