ATTiny84 and wireless options

Does anyone know of any wireless libraries / hardware that will work with an ATTiny84 with an arduino bootloader on it?

Trying to find the best low cost solution for some wireless sensors I’m working on and I’ve got some ATTiny84 chips which are a good bit cheaper than the Mega328 chips.

I’ve got two pieces of wireless hardware atm, a standard RF Transmitter operating at 315mhz, and a nrf2401 transceiver that operates at 2.4 - 2.5ghz. But neither seem to work with standard libraries on the attiny84.

The VirtualWire library for the rf transmitter doesn’t seems to screw with the timer and interfere with the clock causing the next delay() statement to last forever (I’m guessing it’s not really forever but it is definitely a lot longer than it should be). And I really have no clue where to even start figuring out how to modify it to work with the ATTiny timers.

The RF24 library for the transceiver uses SPI which the attiny84 doesn’t seem to support. From what I’ve read and can gather the attiny84 has a USI instead, and again I really have no clue on what it would take to convert the library over to using it.

I don’t really have time atm to go in depth in these things to figure out how to modify them, so I’m wondering if anyone knows of any actively working libraries for one or the other methods.

If not I guess I’ll end up having to use the more expensive mega328 chips.

you could use software serial

...an ATTiny84 with an arduino bootloader on it?

Which bootloader?

These may give you some ideas... http://jeelabs.net/projects/9/wiki/JeeNode_Micro https://github.com/jcw/jeelib

Post I made earlier: http://arduino.cc/forum/index.php/topic,115624.0.html

You can use the JeeLabs library for the transceiver; It also works with the 84. SPI does work on the the Tiny84, but the SPI library doesn't so you would have to write on yourself (the JeeLabs library does this).

I'll try out the JeeLabs library when I get home this evening, but looking at the source on github, it looks like it's coded specifically for the RF12B transceiver? I had a few of those transceivers but sent them back because they cost 3 times as much as the nrf2401 that i have now, and seemed to be less reliable. It also used 50% more power than the nrf2401, and since these sensors are going to be running on batteries, minimizing the power drain while it's awake and sending / receiving data is very important.

Does the nrf2401 use the same commands as the rf12b so that the library would work the same with it?

steven6282: I'll try out the JeeLabs library when I get home this evening, but looking at the source on github, it looks like it's coded specifically for the RF12B transceiver? I had a few of those transceivers but sent them back because they cost 3 times as much as the nrf2401 that i have now, and seemed to be less reliable. It also used 50% more power than the nrf2401, and since these sensors are going to be running on batteries, minimizing the power drain while it's awake and sending / receiving data is very important.

Does the nrf2401 use the same commands as the rf12b so that the library would work the same with it?

Where are you getting your nordics from? I haven't been able to find any for less than $3, but I'd be interested in looking into that if I can get it for cheap.

I haven't had any issues with power, because I only send the data out once every minute. I've been running my sensors on a single coincell for months now.

I can almost guarantee you the library won't work for the Nordic, but you might be able to extract the SPI portion of it from the library reuse it to interface with the nordic.

Arrch:

steven6282:
I’ll try out the JeeLabs library when I get home this evening, but looking at the source on github, it looks like it’s coded specifically for the RF12B transceiver? I had a few of those transceivers but sent them back because they cost 3 times as much as the nrf2401 that i have now, and seemed to be less reliable. It also used 50% more power than the nrf2401, and since these sensors are going to be running on batteries, minimizing the power drain while it’s awake and sending / receiving data is very important.

Does the nrf2401 use the same commands as the rf12b so that the library would work the same with it?

Where are you getting your nordics from? I haven’t been able to find any for less than $3, but I’d be interested in looking into that if I can get it for cheap.

I haven’t had any issues with power, because I only send the data out once every minute. I’ve been running my sensors on a single coincell for months now.

I can almost guarantee you the library won’t work for the Nordic, but you might be able to extract the SPI portion of it from the library reuse it to interface with the nordic.

Well the ones I bought are about $3 each:

http://www.ebay.com/itm/170854842896?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

But there are others on ebay for as low as $2 each, you just have to wait for them to ship from China or somewhere like that. I paid the extra dollar per to get them quicker from an american warehouse (they still originated in China but were stocked over here already).

Even at $3 each that still puts the RF12B at twice the cost. And while yes, the power differences are small (about 6ma while transmitting) over time it will make a huge difference.

Take your usage, once a minute transmits, the RF12B is 18 mA transmit, and the nrf2401 is 12 mA. If you figured no other power usage on a 20mm coin cell typically ~225mAh. You are looking at around 31.25 days on the RF12B and around 46.875 days on the nrf2401. This is assuming max power drain for 1 second each minute and not taking into account the sleeping power drain or the power usage of other components in the device.

I haven’t tested it directly, but based on the numbers alone in the datasheet and such I really don’t know how you are getting months out of a single coin cell batter and a RF12B. The RF12B must not use the full 18 mA during transmit stated in the datasheet or something. The nrf2401 may be the same, I just finally got new fuses for my multimeter yesterday so that I can test the current (blew my fuse testing current in parallel instead of series, doh! hehe).

I've measured the sleeping power drain to be around 4.5 uA and it definitely takes much less than one second to transmit.

Arrch: I've measured the sleeping power drain to be around 4.5 uA and it definitely takes much less than one second to transmit.

Well yeah I didn't even really think about that. I'd guess a transmit really only takes a couple tenths of a second if that. If it took 2 tenths of a second that would mean your battery life would last 5 times longer than I estimated (or about 5 months). But at the same time so would the nrf2401, 234 days or about 7.5 months. Like I said it's a small power difference but makes for huge differences in the end. I'm trying to push mine to a year at least on batteries, and since for my purpose I'm only going to be doing transmits less frequently I might be able to pull it off with a single 20mm coin cell.

I was just working on the same issue and I have been trying to use the Manchester RF library. It currently supports the 328 and the Attiny85, but Tom Carpenter from this forum helped out and added the correct registers for it to work on the ATTINY84, but it hasnt been tested yet.

I have tested the library on the 328 and the attiny85 and it works fine for very simple data communciation. Check it out and if it works on the 84, then update us since I am still working on testing it myself (been pretty busy these days).

I have attached the manchester zip file to this post.

Update us,
Din See

Manchester.zip (5.02 KB)

steven6282:

Arrch: I've measured the sleeping power drain to be around 4.5 uA and it definitely takes much less than one second to transmit.

Well yeah I didn't even really think about that. I'd guess a transmit really only takes a couple tenths of a second if that. If it took 2 tenths of a second that would mean your battery life would last 5 times longer than I estimated (or about 5 months). But at the same time so would the nrf2401, 234 days or about 7.5 months. Like I said it's a small power difference but makes for huge differences in the end. I'm trying to push mine to a year at least on batteries, and since for my purpose I'm only going to be doing transmits less frequently I might be able to pull it off with a single 20mm coin cell.

What's the range like on the Nordic's? My understanding is that it's the most limiting out of the wireless options but I'm wondering what that translates into in terms of practicality?

Arrch:

steven6282:

Arrch: I've measured the sleeping power drain to be around 4.5 uA and it definitely takes much less than one second to transmit.

Well yeah I didn't even really think about that. I'd guess a transmit really only takes a couple tenths of a second if that. If it took 2 tenths of a second that would mean your battery life would last 5 times longer than I estimated (or about 5 months). But at the same time so would the nrf2401, 234 days or about 7.5 months. Like I said it's a small power difference but makes for huge differences in the end. I'm trying to push mine to a year at least on batteries, and since for my purpose I'm only going to be doing transmits less frequently I might be able to pull it off with a single 20mm coin cell.

What's the range like on the Nordic's? My understanding is that it's the most limiting out of the wireless options but I'm wondering what that translates into in terms of practicality?

I've tested it at around 20 meters and didn't have any problems. 20 Meters is about the length of my house so without going outside that is my test range hehe :) So that is 20 meters through multiple walls and such, also multiple wireless devices in the same 2.4ghz frequency nearby (2 routers and a couple of other things). With the regular RF transmitter and receiver @ 315mhz at 20 meters I would lose 2 in 5 transmissions, but with the nordic I didn't loose any over a minute of testing at that range. If I get time tonight either with the attiny working or get time to rehook it up to my arduino I'll try walking outside and see if I can find where the max range is.

sdinnu:
I was just working on the same issue and I have been trying to use the Manchester RF library. It currently supports the 328 and the Attiny85, but Tom Carpenter from this forum helped out and added the correct registers for it to work on the ATTINY84, but it hasnt been tested yet.

I have tested the library on the 328 and the attiny85 and it works fine for very simple data communciation. Check it out and if it works on the 84, then update us since I am still working on testing it myself (been pretty busy these days).

I have attached the manchester zip file to this post.

Update us,
Din See

Not it does not appear to work, I get these errors when trying to compile for the attiny84

H:\Users\Steven Hickerson\Documents\Arduino\libraries\Manchester\Manchester.cpp: In function 'void MANRX_SetupReceive()':
H:\Users\Steven Hickerson\Documents\Arduino\libraries\Manchester\Manchester.cpp:194: error: 'TCCR2A' was not declared in this scope
H:\Users\Steven Hickerson\Documents\Arduino\libraries\Manchester\Manchester.cpp:194: error: 'WGM21' was not declared in this scope
H:\Users\Steven Hickerson\Documents\Arduino\libraries\Manchester\Manchester.cpp:195: error: 'TCCR2B' was not declared in this scope
H:\Users\Steven Hickerson\Documents\Arduino\libraries\Manchester\Manchester.cpp:195: error: 'CS22' was not declared in this scope
H:\Users\Steven Hickerson\Documents\Arduino\libraries\Manchester\Manchester.cpp:195: error: 'CS21' was not declared in this scope
H:\Users\Steven Hickerson\Documents\Arduino\libraries\Manchester\Manchester.cpp:196: error: 'OCR2A' was not declared in this scope
H:\Users\Steven Hickerson\Documents\Arduino\libraries\Manchester\Manchester.cpp:197: error: 'TIMSK2' was not declared in this scope
H:\Users\Steven Hickerson\Documents\Arduino\libraries\Manchester\Manchester.cpp:197: error: 'OCIE2A' was not declared in this scope
H:\Users\Steven Hickerson\Documents\Arduino\libraries\Manchester\Manchester.cpp:198: error: 'TCNT2' was not declared in this scope

This code (not even sure if the code is right really but there was no example code and was just trying to figure it out):

#include <Manchester.h>

MANCHESTERClass mc;

void setup()
{
  mc.SetTxPin(10);
  pinMode(0,OUTPUT);
}

void loop()
{
    digitalWrite(0,HIGH);
    unsigned char* tBytes= (unsigned char*)( "H","e","l","l","o" );
    mc.TransmitBytes(5,tBytes);
    delay(100);
    digitalWrite(0,LOW);
    delay(1000);
}

I can get it to compile by adding #define AVR_ATtinyX4 to the Manchester.h file, but either it’s not receiving on the receiver side, or not actually transmitting on the attiny side. Not sure which atm lol. I will try to play with it some more though.

So the library I sent you is derived from this library -> https://github.com/mchr3k/arduino-libs-manchester/

you can see the example code on there and it definately compiles since I have compiled it successfully, just havent been able to test both the send and receive. Are you sure you selected the correct board? Are you using the arduino-tiny core?

It could also be the arduino software version you are using, i remember that 022 works better than 1.0 for this.

Again, im open to simpler options if they exist. Can we not just use like NewSoftSerial or something similar to that and send that over the TX pin to the transmitter?

sdinnu:
So the library I sent you is derived from this library → GitHub - mchr3k/arduino-libs-manchester

you can see the example code on there and it definately compiles since I have compiled it successfully, just havent been able to test both the send and receive. Are you sure you selected the correct board? Are you using the arduino-tiny core?

It could also be the arduino software version you are using, i remember that 022 works better than 1.0 for this.

Again, im open to simpler options if they exist. Can we not just use like NewSoftSerial or something similar to that and send that over the TX pin to the transmitter?

Like I said, I got it to compile by adding that define in the manchester.h file. Not sure if that is supposed to be required or not. And yes I’m sure I had the correct board selected.

I’m using this attiny core: https://github.com/damellis/attiny/tree/Arduino1

Also just using software serial doesn’t seem to work either. Tried configuring it with the rx pin the same as the receiver data pin and the tx the same as the transmitter data pin, and it doesn’t receive anything, no way to verify if it’s even transmitting anything.

Oh, I am using Arduino 1.0.1. I may try .22 but I’d really rather not use it, I don’t like using outdated software.

Just in case I tried the arduino-tiny library here: http://code.google.com/p/arduino-tiny/

With it I can't even get this simple sketch to work

void setup()
{
  pinMode(0,OUTPUT); 
}

void loop()
{
  digitalWrite(0,HIGH);
  delay(500);
  digitalWrite(0,LOW); 
}

Works fine using the core I linked to github... but with arduino-tiny core the led doesn't blink, not sure if it's doing anything. Says it uploaded but I dunno...

EDIT:

Well I found out part of the problem. The ardiuno-tiny cores has the pin layout wrong. Found this: http://www.flickr.com/photos/nathanchantrell/6897568559/ It's referencing pin 0 as pin 10. As seen from the datasheet: http://www.atmel.com/Images/doc8006.pdf That pin that they have as analog 0 digital 10 is supposed to be analog and or digital 0. They count the digitals backwards for some unknown reason to me.

That said, there still seems to be another problem. It will change the pin to HIGH, but changing it to LOW does nothing, led continues to burn.

Oh I'm using arduino-tiny core. Man I'm surprised there isn't a simple wireless solution. Just like virtual wire and such. I thought just using serial would work but I guess not. My project is at a stand still till I can get the wireless working Haha. I got the Manchester to work fine on the attiny85 but I need the extra io pins of the 84... does anyone have any other ideas?

I think that core only works with arduino022. What are the new features of the newest arduino software anyway?

sdinnu: Oh I'm using arduino-tiny core. Man I'm surprised there isn't a simple wireless solution. Just like virtual wire and such. I thought just using serial would work but I guess not. My project is at a stand still till I can get the wireless working Haha. I got the Manchester to work fine on the attiny85 but I need the extra io pins of the 84... does anyone have any other ideas?

I think that core only works with arduino022. What are the new features of the newest arduino software anyway?

Honestly I don't know what all the new features are.. But the version of arudion-tiny that I download says it's for arduino 1.0

Also I figured out it's not a problem setting the pin to low, it's some kind of problem with the timer like I had before with the virtual wire library. If I call any kind of delay everything simply stops working. No idea what it is. Thought this arduino-tiny might be better but it seems like nothing but problems lol, coupled with them numbering the pins incorrectly... bah

It is possible that the rf would work with the 84 if I could figure out what the heck it is doing to screw up the clock, and get my head around their backwards pin numbering.

I'm going to just give up on it soon and use a mega328. Sucks cause it's more expensive and requires a few other components to even work.

Yea I need to use a tiny since I need the low current usage since my project is going to be run off of a coin cell. I wish these controllers wrote more supported by the community. A mega328 is overkill for a lot of battery powered standalone projects.

sdinnu:
Yea I need to use a tiny since I need the low current usage since my project is going to be run off of a coin cell. I wish these controllers wrote more supported by the community. A mega328 is overkill for a lot of battery powered standalone projects.

I’m planning to run off a coin cell as well so I know the problem.

I really don’t get it though, I’ve got some tiny85s, I plugged one of them in with the arduino-tiny core same exact problem as the 84. If I have any sort of delay in the sketch all goes to crap… I’ve got to be doing something wrong, I can’t imagine them having that large of a bug and not knowing about it yet, but I don’t know what the heck I could be doing wrong for it to do this…