Go Down

Topic: ATTiny84 and wireless options (Read 9247 times) previous topic - next topic

steven6282

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.

Osgeld

http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

Coding Badly

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

Arrch

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

steven6282

#4
Jul 25, 2012, 04:12 pm Last Edit: Jul 25, 2012, 04:16 pm by steven6282 Reason: 1
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?

Arrch


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.

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

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.

steven6282


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.

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

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?

steven6282




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.

steven6282

#12
Jul 26, 2012, 01:07 am Last Edit: Jul 26, 2012, 01:11 am by steven6282 Reason: 1

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

Code: [Select]

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):

Code: [Select]

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

sdinnu

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?

steven6282


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?


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.

Go Up