I'm currently doing a project, which requires me to talk to a RHT-03 via OWI and read/send out IR signals, while being connected to the Internet.
I've got the Internet part down (I'll be using an Electric Imp module to get on the Cloud), the RHT-03 will be talked to via DHT22 library and the IR stuff will be done via the IRremote library.
Basically I'm using the Arduino as a bridge for the RHT-03 and IR Stuff, since it's either too complex or not yet possible to do that directly with the Imp. The Arduino <-> Imp communication will be done via Serial, as shown here - https://www.sparkfun.com/tutorials/397
I've got the whole setup running smoothly on a breadboard, but now I'm thinking about minimizing my design and possibly eliminating some external hardware and hence my question - what Arduino-compatible IC can I use in place of the AtMega328 to do the RHT-03 and IR Stuff for me?
Here are the requirements I initially see towards this IC:
Arduino-compatible - I would need to use my existing code and programming interface (burn Bootloader and code via USB)
5V vs 3V3 - The Electric Imp runs off 3V3 and if the bridge IC is on 3V3 my life would be a lot easier, eliminating the level shifting. There's also the question whether the RHT-03 and IR components will run reliably off 3V3
Minimal external components - integrated clock and caps would be optimal
At least 5 IOs - IR RX, IR TX, Serial RX, Serial TX, OWI (RHT-03)
Nano
Pro Micro
Mini Pro (If you only need USB for Uploading)
or alternatively the Teensy range
I haven't included the ATTiny range as I guess (You didn't say) your code size would be too big for this range.
I also assumed you are looking for a finished board (vs a chip)
I was more leaning towards a single-chip approach such as the AtTiny, but I've never personally used those in any of my projects and don't know whether the quoted libraries will work as expected...
All of the 'brains' in terms of code will be on the Imp so I hope I'll be able to fit the communication code into an AtTiny (wild guess).
Would you please propose some chips, which might work?
Do you want a small CPU in a DIP package or can you use a surface mount chip. The surface mount 328 is very small.
If you have the space for a DIP 328 (as in the Uno) I would use that for the simplicity.
I don't know if there are DIP chips that are bigger than the Attiny and smaller than the 328. The disadvantage of the Attiny is that it doesn't have a hardware USART for serial comms - though you can do it with software. And when you move away from the 328 you may run into minor incompatibilities that cause annoyance and waste time while you figure out how to get around them. For example differences in pin numbering.
I can't use SMD components sadly... I'm planning to keep this on a breadboard for the time being.
The 'no hardware serial' isn't an issue - I can always go software for my needs. Furthermore, the baud I'm going to need isn't that high.
I thought about going with the 328 for ease of use, but I'd really like to keep the part count low... And when I think of all of the things the 328 needs to operate optimally - caps, resistors, oscillator, etc.
So basically I need the smallest (in terms of associated part count) non-SMD Arduino-compatible IC, which can run off 3V3 and plug into the IRRemote and DHT22 libraries. Any ideas?
Arduino-compatible - I would need to use my existing code and programming interface (burn Bootloader and code via USB)
5V vs 3V3 - The Electric Imp runs off 3V3 and if the bridge IC is on 3V3 my life would be a lot easier, eliminating the level shifting. There's also the question whether the RHT-03 and IR components will run reliably off 3V3
3.3V, 8 MHz, no problem.
Minimal external components - integrated clock and caps would be optimal
No problem, Internal 8 MHz oscillator. Two 0.1uF caps on VCC, AVCC pins. Need to change fuse setting in boards.txt.
At least 5 IOs - IR RX, IR TX, Serial RX, Serial TX, OWI (RHT-03)
No problem: Twenty IO available. Hardware UART for Rx, Tx.
Or make an Uno compatible board:
DIP: https://solarbotics.com/product/kardw/
or Surface mount with one of my cards: Cross Roads Electronics
PL down at the bottom of the page. Populate as needed. Off board FTDI for programming serially, or go bootloaderless with ICSP programming. Cross Roads Electronics
(typed this all up before I saw your no SMD post)
So basically I need the smallest (in terms of associated part count) non-SMD Arduino-compatible IC, which can run off 3V3 and plug into the IRRemote and DHT22 libraries. Any ideas?
Look into the AtTiny series chips (Attiny45, Attiny85, Attiny44, Attiny84) from Atmel.
Just google "Attiny arduino"
I have bought one, but I haven't played around with it much yet. Its sitting on my desk still.
Well, I too had had my spark sitting on my desk, but last night, I finally got it running, but I can't find some of the shield/headers from the original order.
However, the issue of the small memory and small pin count in the ATtiny85 chips might be an issue for the OP. There is no hardware serial support either, but software serial might work for the OP. The digispark is 5v by default.
Here's my current sketch size as reported by the IDE just for reference in order to rule out chips, which might not have enough space to store the code: 14,188 bytes (of a 30,720 byte maximum)
Here are my options as I see them, based on the replies:
- 328P running @ 3V3 and 8MHz with internal oscillator -
This is probably my best bet for a couple of reasons:
I have a couple of chips laying around, which I can use without purchasing any additional hardware.
Programming and support will be optimal since this is the same hardware, which is in the Arduino board and I can use that very board to program the chip. Again, no additional hardware.
Breadboard-friendly and easily available.
My only question is whether the IRRemote and DHT22 libraries will work correctly under 8MHz. Anyone have any ideas?
- Arduino Pro Mini @ 3V3 and 8MHz -
Pretty much the same as above, but is somewhat pricier and I have to order it (not readily available) in order to start working on this project.
The smaller footprint is a welcome plus, though.
Again the question about the IRRemote and DHT22 libraries under 8MHz remains...
- ATTiny? -
I don't really have enough experience with this in order to know the potential bumps I might run into... Some, which come to mind are:
3V3 / 5V? I'd really like to run off 3V3 if possible in order to cut out level shifters from the design.
I've used the ATtiny with arduino on it. Just programmed bootloader to it, and downloaded sketch to it by using "Ardiuno as ISP" (hook up ICSP and hold shift when pressing "download") http://hlt.media.mit.edu/?p=1695 <-MIT comes up with awesome stuff
I had to use AVR studio and go in with a ICSP programmer (I used Atmel Dragon) to set the fuses (specifically, turn internal oscillator to 1/8/20MHz, depending on which "board" you selected in arduino (i.e. ATtiny85 w/ internal 1/8/or 20mhz clock))
As long as you select the proper "board", telling the attiny what speed its running at, and you set the fuses properly, I don't see a reason why any library would have problems with it.
You may need to adjust the library's pins though (if it's expecting to use ports/pins that dont exist on the tiny45/85)
the 3.3v/5v operation depends on how fast you want to run the clock (please see page 1 of following summary datasheet)
Those two are also viable options (ATTiny / Cheapduino), but what seems easiest to me (since I have a couple of chips lying around) is the 328 @ 3V3. My only question at this point is: has anyone tried out either the IRRemote lib or the DHT one at those specs (8 MHz)?
If you are using serial comms, then you need to use a crystal or ceramic resonator unless you are prepared to calibrate the clock. Also, it will be easier using a chip that has on-board async serial I/O, which rules out the ATtiny25/45/85. Check out the ATtiny2313, which I think meets your requirements and is smaller than the atmega328p.
I may just end up going with a full-blown Arduino on a breadboard, but can I run it off 3V3, while keeping the clock @ 16 MHz in order to minimize possible timing issues with the libraries?
Also, why would I need the async serial I/O? Can't I use a Software Serial for this?
x2dz:
I may just end up going with a full-blown Arduino on a breadboard, but can I run it off 3V3, while keeping the clock @ 16 MHz in order to minimize possible timing issues with the libraries?
No.
x2dz:
I thought about going with the 328 for ease of use, but I'd really like to keep the part count low... And when I think of all of the things the 328 needs to operate optimally - caps, resistors, oscillator, etc.
What makes you think those requirements differ from any other chip?
You can run the 328 without oscillator just as you can any other chip - with exactly the same restrictions. You always need the capacitors. You don't strictly need a resistor on the reset, but you do if you wish to use the auto-reset function. All chips are essentially the same in these regards.
Or get the Teensy 3.0, which is an Arm board that runs at 3.3v, supporting the Arduino IDE and most libraries: PJRC Store, and is a little more than the Teensy 2.0 and less than the Teensy 2.0++. It fits in a DIP-28 form factor.
I'm not a fan of software serial and I never use it for receiving data. Hardware serial is better, especially if you need to receive data while the microcontroller is doing other things, or the baud rate is high.