I've purchased two RFM69HCW breakouts from Adafruit.
I wired them to two UNOs using the wiring hookup below, and uploaded the code below and have had no problems.
I then tried to move the transmitter from an UNO to an ATTiny1616 using the hookups below, and teh receiver isn't receiving anything. I added an LED blink to the setup code of the ATTINy to make sure it's running the code, and it is.
I'm assuming at this point it's a wiring issue with the ATTiny or the pins not being a direct replacement for the UNO pins.
This is the breakdown of my pins and assumptions.
VCC/GND- I don't suspect any problems here.
G0 pin - The adafruit documentation says this must be hooked up to a hardware interrupt. I have it hooked up to digital pin 2 which is labeled as a hardware interrupt on both the UNO and the ATTiny.
SCK,MISO,MOSI - I have these hooked up as shown below directly to their match.
CS and RST - Adafruit documentation says these can be any digital pin. I attached them on the ATTiny to the same pin numbers I had on the UNO, but no success. My gut is telling me it's the CS pin that's the problem. In some libraries (Radiohead) it's user defined. I can't get Radiohead to compile for ATTiny1616 so I went with another library I found on the forums here but the CS (also called NSS) isn't userdefined and I can't seem to find it in the library file.
I'm wondering if anyone has any experience that could help me out here. Thanks!
Transmitter Code:
// Include the RFM69 and SPI libraries:
#include <RFM69.h>
#include <SPI.h>
// Addresses for this node. CHANGE THESE FOR EACH NODE!
#define NETWORKID 0 // Must be the same for all nodes
#define MYNODEID 1 // My node ID
#define TONODEID 2 // Destination node ID
#define RFM69_RST 9
// RFM69 frequency, uncomment the frequency of your module:
#define FREQUENCY RF69_915MHZ
RFM69 radio;
//Veriables
int BigButt = 0; //This will become the first sensor value, for test puposes it is now fixed to the value of 10. This is also the value that should be transmitted to the other arduino.
int Butt1 = 1; //This will become the second sensor value, for test puposes it is now fixed to the value of 15. This is also the value that should be transmitted to the other arduino.
int Butt2 = 2;
int Butt3 = 3;
int Butt4 = 4;
int Butt5 = 5;
int Butt6 = 6;
int Butt7 = 7;
int Butt8 = 8;
char input[62]; // This will become the message to send
static int sendlength; // The size of your message
void setup()
{
Serial.begin(9600);
pinMode(RFM69_RST, OUTPUT);
// manual reset
digitalWrite(RFM69_RST, HIGH);
delay(10);
digitalWrite(RFM69_RST, LOW);
delay(10);
// Initialize the RFM69HCW:
radio.initialize(FREQUENCY, MYNODEID, NETWORKID);
radio.setHighPower(); // Always use this for RFM69HCW
}
void loop()
{
sprintf(input, "%d,%d,%d,%d,%d,%d,%d,%d,%d", BigButt, Butt1, Butt2, Butt3, Butt4, Butt5, Butt6, Butt7, Butt8);
sendlength = 62; // give your message an adequate size
delay(10); //wait 5s to send in 5s takt
radio.send(TONODEID, input, sendlength);
}
Receiver Code
// RFM69HCW Example Sketch
// Send serial input characters from one RFM69 node to another
// Based on RFM69 library sample code by Felix Rusu
// http://LowPowerLab.com/contact
// Modified for RFM69HCW by Mike Grusin, 4/16
// This sketch will show you the basics of using an
// RFM69HCW radio module. SparkFun's part numbers are:
// 915MHz: https://www.sparkfun.com/products/12775
// 434MHz: https://www.sparkfun.com/products/12823
// See the hook-up guide for wiring instructions:
// https://learn.sparkfun.com/tutorials/rfm69hcw-hookup-guide
// Uses the RFM69 library by Felix Rusu, LowPowerLab.com
// Original library: https://www.github.com/lowpowerlab/rfm69
// SparkFun repository: https://github.com/sparkfun/RFM69HCW_Breakout
// Include the RFM69 and SPI libraries:
#include <RFM69.h>
#include <SPI.h>
// Addresses for this node. CHANGE THESE FOR EACH NODE!
#define NETWORKID 0 // Must be the same for all nodes
#define MYNODEID 2 // My node ID
#define TONODEID 1 // Destination node ID
#define RFM69_RST 9
// RFM69 frequency, uncomment the frequency of your module:
#define FREQUENCY RF69_915MHZ
RFM69 radio;
int BigButt;
int Butt1;
int Butt2;
int Butt3;
int Butt4;
int Butt5;
int Butt6;
int Butt7;
int Butt8;
char msg [63]; // The array in which the message is stored
void setup()
{
Serial.begin(9600);
pinMode(RFM69_RST, OUTPUT);
// manual reset
digitalWrite(RFM69_RST, HIGH);
delay(10);
digitalWrite(RFM69_RST, LOW);
delay(10);
// Initialize the RFM69HCW:
radio.initialize(FREQUENCY, MYNODEID, NETWORKID);
radio.setHighPower(); // Always use this for RFM69HCW
// Turn on encryption if desired:
}
void loop()
{
if (radio.receiveDone()) // Got one!
{
for ( byte i = 0; i < radio.DATALEN; i++)
msg[i] = char(radio.DATA[i]);
sscanf(msg, "%d, %d, %d, %d, %d, %d, %d, %d, %d", &BigButt, &Butt1, &Butt2, &Butt3, &Butt4, &Butt5, &Butt6, &Butt7, &Butt8);
Serial.print(BigButt);
Serial.print(", ");
Serial.print(Butt1);
Serial.print(", ");
Serial.print(Butt2);
Serial.print(", ");
Serial.print(Butt3);
Serial.print(", ");
Serial.print(Butt4);
Serial.print(", ");
Serial.print(Butt5);
Serial.print(", ");
Serial.print(Butt6);
Serial.print(", ");
Serial.print(Butt7);
Serial.print(", ");
Serial.println(Butt8);
}
}