Hi,
I’m trying to get the RFM69 existing library to work with Photon. The same code works on an Arduino Pro Mini but on the Photon while it compiles without error, it never reports receiving any radio message.
First off, can someone please confirm the correct wiring diagram for connecting an RFM69W/CW/HCW device to a Photon? I’ve created my own mapping based on the Photon datasheet and listed it as such:
/*
Photon SPI mapping from https://docs.particle.io/reference/firmware/photon/#spi
Photon Arduino RFM69
GND GND GND
3V3 3.3V VCC
A2 10 NSS
A3 13 SCK
A5 11 MOSI
A4 12 MISO
D2 2 DI00
ANA Antenna
D9 RST
*/
Here is the full RX Photon node code (the TX node runs on an Arduino):
// This #include statement was automatically added by the Particle IDE.
#include "RFM69/RFM69.h"
// SEE ORIGINAL LICENSE AND AUTHOR INFORMATION AT END OF MAIN LOOP
//*********************************************************************************************
// *********** IMPORTANT SETTINGS - YOU MUST CHANGE/ONFIGURE TO FIT YOUR HARDWARE *************
//*********************************************************************************************
//below was tested both as int16_t and #define with no difference in making it work
int16_t NETWORKID = 100; //the same on all nodes that talk to each other
int16_t NODEID = 1;
//Match frequency to the hardware version of the radio on your Feather
//#define FREQUENCY RF69_433MHZ
//#define FREQUENCY RF69_868MHZ
#define FREQUENCY RF69_915MHZ
#define ENCRYPTKEY "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes!
#define IS_RFM69HCW true // set to 'true' if you are using an RFM69HCW module
//*********************************************************************************************
#define RFM69_CS A2 //tried A3 no difference //Arduino 10
#define RFM69_IRQ 2
#define RFM69_IRQN 0 // Pin 2 is IRQ 0!
#define RFM69_RST 9
int16_t packetnum = 0; // packet counter, we increment per xmission
//RFM69 radio = RFM69(RFM69_CS, RFM69_IRQ, IS_RFM69HCW, RFM69_IRQN);
RFM69 radio; //tried above statement also no difference in making it work
//*********************************************************************************************
// *********** Wiring the RFM69 Radio *************
//*********************************************************************************************
/*
Photon SPI mapping from https://docs.particle.io/reference/firmware/photon/#spi
Photon Arduino RFM69 Color
GND GND GND Black
3V3 3.3V VCC Red
A2 10 NSS Yellow
A3 13 SCK Green
A5 11 MOSI Blue
A4 12 MISO Violet
D2 2 DI00 Gray
ANA Antenna
D9 RST
*/
void setup()
{
Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
pinMode(D7, OUTPUT);
Particle.publish("Startup setup","Completed",360,PRIVATE);
Serial.println("RFM69HCW Receiver");
// Initialize radio
radio.initialize(FREQUENCY,NODEID,NETWORKID);
if (IS_RFM69HCW) {
radio.setHighPower(); // Only for RFM69HCW & HW!
}
radio.setPowerLevel(10); // power output ranges from 0 (5dBm) to 31 (20dBm)
radio.encrypt(ENCRYPTKEY);
Serial.print("\nListening at ");
Serial.print(FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
Serial.println(" MHz");
}
//=========================MAIN LOOP===========================================
void loop() {
Serial.print(".");
//check if something was received (could be an interrupt from the radio)
if (radio.receiveDone())
{
//print message received to serial
Serial.println(" "); //if received the ..... will new line
Serial.print('[');Serial.print(radio.SENDERID);Serial.print("] ");
Serial.print((char*)radio.DATA);
Serial.print(" [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");
//check if received message contains Hello World
if (strstr((char *)radio.DATA, "Hello World"))
{
//check if sender wanted an ACK
if (radio.ACKRequested())
{
radio.sendACK();
Serial.println(" - ACK sent");
}
else {Serial.println(" - No ACK sent");}
}
}
radio.receiveDone(); //put radio in RX mode
delay(1000);
} //end loop
//END OF MAIN LOOP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/* RFM69 library and code by Felix Rusu - felix@lowpowerlab.com
// Get libraries at: https://github.com/LowPowerLab/
// Make sure you adjust the settings in the configuration section below !!!
// **********************************************************************************
// Copyright Felix Rusu, LowPowerLab.com
// Library and code by Felix Rusu - felix@lowpowerlab.com
// **********************************************************************************
// License
// **********************************************************************************
// This program is free software; you can redistribute it
// and/or modify it under the terms of the GNU General
// Public License as published by the Free Software
// Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will
// be useful, but WITHOUT ANY WARRANTY; without even the
// implied warranty of MERCHANTABILITY or FITNESS FOR A
// PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General
// Public License along with this program.
// If not, see <http://www.gnu.org/licenses></http:>.
//
// Licence can be viewed at
// http://www.gnu.org/licenses/gpl-3.0.txt
//
// Please maintain this license information along with authorship
// and copyright notices in any redistribution of this code
// **********************************************************************************/