Project

General

Profile

RFM69CW node with Attiny84

Added by nerofirestarter100 6 months ago

Hi all,

I built up a node (Attiny84 and RFM69CW) to measure the electric consumption of my flat and want to send the data wireless to my jeelink adapter (connected to FHEM).
Something like this:
http://www.hobbyheizer.de/index.php/haussteuerung/stromzaehler

I have chosen the Attiny84 because I wanted to start with something small and simple, maybe this was a bit optimistic.

I have build up an Arduino Nano to be used as ISP programmer for the ATTINY84.

I have also connected a Serial connection to the ATTINY84 (RX and TX) and a LED for debugging,
both is working fine. I am using the Arduino IDE 1.6.10 on a windows machine with the ATTinyCore from Spence Konde Version 1.1.1,
PinMapping CounterClockwise(like AttinyCore).
I have "burned the bootloader" with the 8MHz (internal) setting.

To test the hardware I have tried the RF12DEMO.12 Sketch from the Jeelib library with limited success.
Some friendly guys from the lowpowerlab forum pointed out the Attiny84 might run out of RAM and not a good choice for that purpose.
It is a pity that I built it up already, so I would like to see it working...

I found a solution to test my hardware and saw it works in principle (replacement of RF12demo).
Tiny Node:
https://github.com/flabbergast/RFM69/tree/attiny
Arduino Gateway:
https://github.com/flabbergast/RFM69/tree/master

I changed the code a bit. Not perfect, but working with the used core including status LED and Serial connection, see attachment for Node.

I can upload the RFM12demo to the Arduino Nano and it receive data (bad packets).
"
Current configuration:
A i1 g212 @ 868 MHz
? 16 89 1 72 204 (-39)
"

I can also upload LaCrosseITPlusReader.10.1e or LaCrosseITPlusReader.10.1q hex file with the help of XLoader and get invalid packages like this:
"
End receiving, HEX raw data: FB 33 61 E7 CD F 96 9B 4D 9B 17 C 3A 7C 38 88
# # CRC FAIL # #
No valid start
No valid Voltage: 13.30
"

Now that I know the HW works (I am almost happy), how to talk to the Jeelink adapter (RFM12) and how to modify the code (, encryption off, CRC)?

Sven

RF69_Node_sven.ino (4.09 KB)


Replies (19)

RE: RFM69CW node with Attiny84 - Added by JohnO 6 months ago

How about using this on your ATTiny84 and receiving its transmissions on your Arduino Nano. You will need to tweak radioBlip2.ino to use the RFM69 radio you have fitted.

RE: RFM69CW node with Attiny84 - Added by nerofirestarter100 6 months ago

Thanks a lot for the fast answer I will try as soon as possible.

Sven

RE: RFM69CW node with Attiny84 - Added by nerofirestarter100 6 months ago

Hey JohnO,

I tried the radioBlip2.ino quickly and I thought I saw it running...
Now I wanted to adapt the code a bit and I can't get it running any more :(

I changed the following
"
#define RF69_COMPAT 1 // use RFM69 instead of RFM12
#include < JeeLib.h >
#include < avr/sleep.h >

#define BOOST 0 // measure battery on analog pin if 1, else vcc after

#define BLIP_NODE 22 // wireless node ID to use for sending blips
#define BLIP_GRP 212 // wireless net group to use for sending blips
#define BLIP_ID 1 // set this to a unique ID to disambiguate multiple nodes
#define SEND_MODE 0 // set to 3 if fuses are e=06/h=DE/l=CE, else set to 2
"

and
"
/*
#if defined( __ AVR_ATtiny84 __ )
// power up the radio on JMv3
bitSet(DDRB, 0);
bitClear(PORTB, 0);
#endif
*/
"

I cannot receive anything useful with the Arduino Nano (RF12demo.12):
Current configuration:
A i1 g212 @ 868 MHz
? 179 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (-105)

I tried to debug and saw that "rf12_sendWait(3)" and "rf12_sendWait(2)" never returned, so I used "0".
I tried to strip down the code but no effect (see attachment and IDE report).

Maybe I have overlooked something...
Any ideas?
Thanks Sven

radioBlip2_sven.ino (1.25 KB)

report.txt Magnifier (24.4 KB)

RE: RFM69CW node with Attiny84 - Added by JohnO 6 months ago

If you are feeling adventurous you could try example/RF12/RFxConsole.ino from this version of the library on your Nano. You need to load up the whole RFxConsole-RSSI library to support RFxConsole.

RE: RFM69CW node with Attiny84 - Added by JohnO 6 months ago

N.B. 115200 serial connection required on your terminal emulator to connect to Nano running RFxConsole.ino

RE: RFM69CW node with Attiny84 - Added by nerofirestarter100 6 months ago

Hi JohnO,

in the meantime I felt a little bit adventurous, trying RFxConsole.ino on the nano with little success.
By the way is there a possibility to switch between two JeeLib.h libraries?
I had to delete/move the other folder to use RFXConsole.

I have not seen any packet coming in, just this:
"
0,Key=13, 143s elapsed, Led is off, Free Ram 649b, RX Restarts 3, Rate 0m0/s, Sync Match 0, Good CRC 0, Noise Floor 167/0/167, Ack: Aborts 0, Floor 255/0, Eeprom A i1 g212 @ 868 MHz 1c0
[0,0,0,0],0,0
"

After this test I came back to the RF69_Node_sven.ino and no packet comes in using RFXConsole (NANO).
Then I used RF69_Gateway_sven.ino (NANO) and it works immediatly :(

Sven

RE: RFM69CW node with Attiny84 - Added by JohnO 6 months ago

Hi Sven,

Do you use GitHub Desktop? What I do is setup the specific jeelib repository to be inside the arduino/library directory such that changing the jeelib branch is immediately reflected in the library that Arduino will use at next build. This means that you can change the library being used by selecting master or RFxConsole-RSSI from Github desktop UI.

I am sorry that RFxConsole-RSSI didn't do anything for you, it is usually a most reliable receiver and the one I use full time.

Since you can now receive packets with RF69_Gateway_sven.ino does this not mean we have achieved the objective?

As background, I think you need an additional ATMega328 based node to really get into diagnosis, you might consider http://www.digitalsmarties.net/products/jeelink as a very compact debugging device.

RE: RFM69CW node with Attiny84 - Added by nerofirestarter100 6 months ago

Hi JohnO,

Thanks for the hint with GitHub Desktop, so far I did everything "manually".
I will give it a try next time.

You are right, I can send and receive packets with the help of Flabbergast's fork (RFM69_f.h).
https://github.com/flabbergast/RFM69/tree/attiny

So the HW seems to work, but my configuration is not compatible with the "Jeelink protocol".
I am already using an Jeelink Adapter (RFM12B) with FHEM and thougth it would be nice to build some Nodes for it...

Do you think it is possible to adapt the code (RFM69_f.h / RF69_Node_sven.ino) in terms of data rate, CRC to be compatible with the Jeelink adapter (RFM12B)?

Sven

RE: RFM69CW node with Attiny84 - Added by JohnO 6 months ago

I appear to be getting confused in what we are trying to acheive. The link to https://github.com/flabbergast/RFM69/tree/tiny is unavailable, 404 for me.

Is your desired outcome is to use Jeelink protocol between ATTiny with RFM69CW and a Nano equipped with RFM12B board equipped with a second RFM69CW ?

Jeelink can do the above, out of the box but I believe there are a few wrinkles with rf12Demo when built for RFM69 radios which is why I use the RFxConsole-RSSI library. The challenges I see are, using the ATTiny84, it works fine but without an underlying infrastructure to understand and debug what is happening it can be difficult. With a second ATMega328 RF node you can establish what traffic is happening, what the noise levels are etc. Once that is understood you can bring the ATTiny into the arena knowing that one end of your RF link is solid - the ATMega328 end.

It is possible to have problems with sending too much signal when you have the two nodes on your test bench. If they are too close it can appear that nothing is being received. Increasing the distance or turning down the transmit power will resolve that issue. Without sufficient trusted hardware life can be all uphill. I don't think we need to adapt the Flabbergast fork, if you choose to change the bit rate then we can do that by adjusting RF69.cpp here:
~~~
0x03, 0x02, // BitRateMsb, data rate = 49,261 khz
0x04, 0x8A, // BitRateLsb, divider = 32 MHz / 650 == 49,230 khz
~~~
The advantage of staying as we are is that it is known to work and other forum member know what you can expect from it.

I run a few ATTiny84 nodes with RFM69CW radios and also with the earlier and still compatible RFM12B radios. I would still deploy ATTiny84 nodes but would probably only use RFM12B radios due to the RAM/FLASH cost of my RFxConsole-RSSI library.

RE: RFM69CW node with Attiny84 - Added by nerofirestarter100 6 months ago

Sorry for the confusion.

I have changed the link to attiny (no clue why I copied it wrongly).

My setup is the following:
At home I have a Jeelink Adapter (RFM12B) connected to FHEM and flashed with "JeeLink_LaCrosse.hex" to read several Temperature Sensors.

I wanted to build up a node measuring the power consumption of my flat and built up the following:
-ATTiny84 with RF6M9CW (LED connected and possibility to connect USB-Serial-Adapter for testing), all soldered
-Nano with RFM69CW as test gateway, only breadboard

My goal is to use the Jeelink Adapter and connect the Attiny as node.
The Nano is just for testing, unfortunately I have no RFM12B for testing only another RFM69CW

Is it possbilbe for you to provide a sketch for the ATTiny84 with RFM69CW for me to test?
I still don't know were my fault is or even were to search for.

The distance is a good point, they are only 1 m apart, I try to find an extension cable...
How can I change the power when using "RadioBlip2"?

Thanks for the support,
Sven

RE: RFM69CW node with Attiny84 - Added by JohnO 6 months ago

There is a .hex file here:
https://github.com/jcw/jeelib/blob/RFxConsole-RSSI/examples/RF12/RF12demo/V12-RF12demo-T84-RFM69.hex

This is a working image for an ATTiny84. It is a cut down version without a menu and with limited error messages.

-ATTiny84 with RF6M9CW (LED connected and possibility to connect USB-Serial-Adapter for testing), all soldered

Is not a good choice for a testing node.

Let us know how you get on.

N.B.
~~~
#if TINY
// Serial support (output only) for Tiny supported by TinyDebugSerial
// http://www.ernstc.dk/arduino/tinycom.html
// 9600, 38400, or 115200
// hardware\jeelabs\avr\cores\tiny\TinyDebugSerial.h Modified to
// move TinyDebugSerial from PB0 to PA3 to match the Jeenode Micro V3 PCB layout
// Connect Tiny84 PA3 (D7) to USB-BUB RXD for serial output from sketch.
// Jeenode AIO2
//
// With thanks for the inspiration by 2006 David A. Mellis and his AFSoftSerial
// code. All right reserved.
// Connect Tiny84 PA2 (D8) to USB-BUB TXD for serial input to sketch.
// Jeenode DIO2
// 9600 or 38400 at present.
// http://jeelabs.net/boards/7/topics/3229?r=3268#message-3268
~~~

RE: RFM69CW node with Attiny84 - Added by nerofirestarter100 6 months ago

A 3m extension cable did the tric!

ATTiny84 with RF69_Node_sven.ino and Reception via Nano with RF12demo:
A i1 g212 @ 868 MHz
? 16 89 6 248 16 (-50)
? 16 89 7 16 16 (-49)
? 16 88 7 24 16 (-49)
? 16 90 7 64 32 (-49)
? 16 89 7 40 16 (-49)

ATTiny84 with modified radioBlip2.ino and Reception via Nano with RF12demo:
OK 22 1 0 0 (-50)
OK 22 2 0 0 (-50)
OK 22 3 0 0 (-50)
OK 22 4 0 0 (-49)
OK 22 5 0 0 (-50)

So it was actually working.
Thanks for the help!
Sven

RE: RFM69CW node with Attiny84 - Added by JohnO 6 months ago

Excellent.

RE: RFM69CW node with Attiny84 - Added by nerofirestarter100 6 months ago

Hi JohnO,

after some days off and some other workload I resumed testing a bit.
Although happy with the 3m cable the configuration seemed to be unstable
and strange in behavior:
-sometimes working, sometimes not
-switching off and on sometimes helped, sometimes not
-changing the location seems to have an influence (or not)
-touching and pulling on the wires sometimes helps to get connection.

I have checked the soldered connections and resoldered some of them - no change.
I checked the antenna length and it was OK for the frequency: Lambda/4.
Asking google showed that Lambda/2 is an alternative and in this case the
grounding is not as critical BINGO!

I changed the antenna length to Lambda/2 and now it seems to work better.
A shorter distance between Node and GW is also not a problem any longer,
so the longer cable was not a real sollution (for me).

I assume my setup is not ideal from the RF perspective (grounding).

Sven

RE: RFM69CW node with Attiny84 - Added by JohnO 6 months ago

Hi Sven,

I find radio waves amazing, mysterious and captivating but my knowledge is limited. I hope that @martynj will see your comment regarding Lambda/2 and add detail but I know he is very busy at the moment.

Regarding the intermittent performance, is it possible yet for you to decide if there is a TX or a RX issue. As I mentioned earlier, RX issues can happen with RF12Demo and the master branch on GitHub. I only use RFxConsole with the RFxConsole-RSSI branch which has fewer issues with RX.

RE: RFM69CW node with Attiny84 - Added by JohnO 6 months ago

Regarding distance between nodes, transmitting with the 69 radio in close proximity to a 69 receiver assuming a reasonable ground plane and antenna has ALWAYS cause problems for me. Lambda/2 may well have impaired the TX power to make this no longer a problem for you. RFxConsole has commands that enable the TX power to be lowered rather than dissipated with a compromised ground plane or antenna.

RE: RFM69CW node with Attiny84 - Added by nerofirestarter100 6 months ago

Hi JohnO,

is it an RX problem or an TX problem, good question!
To be honest I don't know. From my feeling I would say that it was related to the Attiny84 (TX) and not with the Nano (RX),
but the libraries from flabbergast were working fine with the Lambda/4 HW in both directions which still confuses me.
With flabbergasts libraries I was also able adjusting the power values.
It could be a combination of problems on both side (RX and TX).
At the moment I assume that the Lambda/2 antenna shows an improvement (TX).

When I find some time I will have a look at RFxConsole again.

Sven

RE: RFM69CW node with Attiny84 - Added by nerofirestarter100 5 months ago

Hi JohnO,

I tried to use RFxConsole on the Nano, but could not get any packet.
I also tried the RFdemo from that library, but no packet was received.

I uploaded the RFdemo from the master brunch and it worked after a power reset of the nano.
I repeated the test with the RFxConsole and a power reset, but still no packet arrives (2m, 3m distance...).

Sven

RE: RFM69CW node with Attiny84 - Added by JohnO 5 months ago

Thanks for taking a look.

John.

    (1-19/19)