I have a Motion with the RFMHCW69 915mhz transceiver. When I do a call to
radio.getFreqency() the number 1023999936 is returned. Is that correct?
Forgot to mention this happens even after a radio.setFrequency(n) call, no matter what n is
The arguments are in Hz.
How do you make those calls?
Can you add the code you're using including variables?
Using a very slightly modified version of the example file Struct_send.
My mods are marked with //KDW
#include <RFM69.h>
#include <SPI.h>
#include <SPIFlash.h>
#define NODEID 99
#define NETWORKID 100
#define GATEWAYID 1
#define FREQUENCY RF69_915MHZ // KDW
#define KEY "sampleEncryptKey" //has to be same 16 characters/bytes on all nodes, not more not less!
#define LED 9
#define SERIAL_BAUD 115200
#define ACK_TIME 30 // # of ms to wait for an ack
#define IS_RFM69HW_HCW //uncomment only for RFM69HW/HCW! Leave out if you have RFM69W/CW!
int TRANSMITPERIOD = 300; //transmit a packet to gateway so often (in ms)
byte sendSize=0;
boolean requestACK = false;
SPIFlash flash(8, 0xEF30); //EF40 for 16mbit windbond chip
RFM69 radio;
typedef struct {
int nodeId; //store this nodeId
unsigned long uptime; //uptime in ms
float temp; //temperature maybe?
} Payload;
Payload theData;
void setup() {
Serial.begin(SERIAL_BAUD);
radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW_HCW
radio.setHighPower(); //must include this only for RFM69HW/HCW!
#endif
radio.encrypt(KEY);
char buff[50];
sprintf(buff, "\nTransmitting at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
Serial.println(buff);
if (flash.initialize())
Serial.println("SPI Flash Init OK!");
else
Serial.println("SPI Flash Init FAIL! (is chip present?)");
radio.setFrequency(FREQUENCY); //KDW
}
long lastPeriod = -1;
void loop() {
Serial.println(radio.getFrequency()); //KDW
//process any serial input
if (Serial.available() > 0)
{
char input = Serial.read();
if (input >= 48 && input <= 57) //[0,9]
{
TRANSMITPERIOD = 100 * (input-48);
if (TRANSMITPERIOD == 0) TRANSMITPERIOD = 1000;
Serial.print("\nChanging delay to ");
Serial.print(TRANSMITPERIOD);
Serial.println("ms\n");
}
if (input == 'r') //d=dump register values
radio.readAllRegs();
//if (input == 'E') //E=enable encryption
// radio.encrypt(KEY);
//if (input == 'e') //e=disable encryption
// radio.encrypt(null);
if (input == 'd') //d=dump flash area
{
Serial.println("Flash content:");
int counter = 0;
while(counter<=256){
Serial.print(flash.readByte(counter++), HEX);
Serial.print('.');
}
while(flash.busy());
Serial.println();
}
if (input == 'e')
{
Serial.print("Erasing Flash chip ... ");
flash.chipErase();
while(flash.busy());
Serial.println("DONE");
}
if (input == 'i')
{
Serial.print("DeviceID: ");
word jedecid = flash.readDeviceId();
Serial.println(jedecid, HEX);
}
}
//check for any received packets
if (radio.receiveDone())
{
Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
for (byte i = 0; i < radio.DATALEN; i++)
Serial.print((char)radio.DATA[i]);
Serial.print(" [RX_RSSI:");Serial.print(radio.readRSSI());Serial.print("]");
if (radio.ACKRequested())
{
radio.sendACK();
Serial.print(" - ACK sent");
delay(10);
}
Blink(LED,5);
Serial.println();
}
int currPeriod = millis()/TRANSMITPERIOD;
if (currPeriod != lastPeriod)
{
//fill in the struct with new values
theData.nodeId = NODEID;
theData.uptime = millis();
theData.temp = 91.23; //it's hot!
Serial.print("Sending struct (");
Serial.print(sizeof(theData));
Serial.print(" bytes) ... ");
if (radio.sendWithRetry(GATEWAYID, (const void*)(&theData), sizeof(theData)))
Serial.print(" ok!");
else Serial.print(" nothing...");
Serial.println();
Blink(LED,3);
lastPeriod=currPeriod;
}
}
void Blink(byte PIN, int DELAY_MS)
{
pinMode(PIN, OUTPUT);
digitalWrite(PIN,HIGH);
delay(DELAY_MS);
digitalWrite(PIN,LOW);
}
Try 915000000 instead of RF69_915MHZ which is a library directive (value==91 which is an invalid Hz argument).
915mhz = 915 million hertz.
Same result
Ensure you write the sketch with new 915000000 value, then recycle power to clear any invalid saved value.
Here's a working example that conditionally sets frequency to 916mhz:
https://github.com/LowPowerLab/RFM69/blob/master/Examples/WirelessProgramming_OTA/Target/Target.ino
Still same result.
I added a line to get/print the frequency at the end of loop.
Attached is screenshot of output.
Is it possible I have a bad radio? That I did something to fry the radio? Only soldering was for FTDI and antenna.
Quote from: Felix on September 25, 2018, 03:04:19 PM
Try 915000000 instead of RF69_915MHZ which is a library directive (value==91 which is an invalid Hz argument).
915mhz = 915 million hertz.
Are you sure it shouldn't be 915000000UL? I'm not sure if it gets truncated to an unsigned int without the UL bit.
Mark.
Still same result when using 915000000UL.
Here is screenshot
On a lark, I decided to go back to an older version of the RFM69 library.(1.1.0) and older version of SPIFlash Library(101.1.0).
Now I get the proper readout.
UPDATE:
I reloaded the current RFM69 libraries and now it all works. Regardless of whether I use 915000000UL or 915000000.
I must have had a bad update before.
Thanks for all the suggestions/help.
Ken
Thanks for the update, I was gonna look into it, but I was pretty confident no such bug was introduced in the latest releases.
I will mark this solved but please verify the library you now have installed is the latest available on github.
Also, there should never be 2 versions of the library (renamed / in separate folders) in your libraries folder or strange things will happen if it even compiles.