Author Topic: Operation Freezing on radio.send()  (Read 16933 times)

jessethepro

  • NewMember
  • *
  • Posts: 8
  • Country: us
Operation Freezing on radio.send()
« on: January 21, 2017, 01:43:47 AM »
Hi,

I am trying to troubleshoot my two RFM96 radio modules and I am hoping the forum can be of assistance. I have two radios connected to Arduino Unos. The radios are using separate power supplies rated at 3v (two AA batteries). The Arduinos are powered via the 12v 1a wall adapter. I am using the SPI interface for communicating to the devices and I used Sparkfun's setup guide https://learn.sparkfun.com/tutorials/rfm69hcw-hookup-guide?_ga=1.266083855.1455005990.1484889845. I am also using the code off the Sparkfun site for testing. The code sets a network ID: 100 and two client node IDs: 1 and 2. For troubleshooting further, I set the tonodeid to 255 and each radio into promiscuous mode. See attached code for further reference. On both radios, the operation blocks on either radio.send() or radio.sendWithRetry() and neither radio can see the other's traffic. I don't have access to a Spectrum Analyzer to see if anything is broadcasting on the frequency. Any help on how I can continue to troubleshoot would be greatly appreciated.

Thanks,
Jesse

Node 1 Arduino Code
Code: [Select]
// RFM69HCW_Node_1 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     100   // Must be the same for all nodes
#define MYNODEID      1   // My node ID
#define TONODEID      2   // Destination node ID

// RFM69 frequency, uncomment the frequency of your module:

//#define FREQUENCY   RF69_433MHZ
#define FREQUENCY     RF69_915MHZ

// AES encryption (or not):

#define ENCRYPT       false // Set to "true" to use encryption
#define ENCRYPTKEY    "TOPSECRETPASSWRD" // Use the same 16-byte key on all nodes

// Use ACKnowledge when sending messages (or not):

#define USEACK        true // Request ACKs or not

// Packet sent/received indicator LED (optional):

//#define LED           9 // LED positive pin
//#define GND           8 // LED ground pin

// Create a library object for our RFM69HCW module:

RFM69 radio;

void setup()
{
  // Open a serial port so we can send keystrokes to the module:

  Serial.begin(9600);
  Serial.print("Node ");
  Serial.print(MYNODEID,DEC);
  Serial.println(" ready"); 

  // Set up the indicator LED (optional):

 // pinMode(LED,OUTPUT);
  //digitalWrite(LED,LOW);
 // pinMode(GND,OUTPUT);
 // digitalWrite(GND,LOW);

  // Initialize the RFM69HCW:

  radio.initialize(FREQUENCY, MYNODEID, NETWORKID);
  radio.setHighPower(); // Always use this for RFM69HCW

  // Turn on encryption if desired:

  if (ENCRYPT)
    radio.encrypt(ENCRYPTKEY);
  radio.promiscuous(true);
}

void loop()
{
  // Set up a "buffer" for characters that we'll send:

  static char sendbuffer[62];
  static int sendlength = 0;

  // SENDING

  // In this section, we'll gather serial characters and
  // send them to the other node if we (1) get a carriage return,
  // or (2) the buffer is full (61 characters).

  // If there is any serial input, add it to the buffer:

  if (Serial.available() > 0)
  {
    char input = Serial.read();

    if (input != '\r') // not a carriage return
    {
      sendbuffer[sendlength] = input;
      sendlength++;
    }

    // If the input is a carriage return, or the buffer is full:

    if ((input == '\r') || (sendlength == 61)) // CR or buffer full
    {
      // Send the packet!


      Serial.print("sending to node ");
      Serial.print(TONODEID, DEC);
      Serial.print(", message [");
      for (byte i = 0; i < sendlength; i++)
        Serial.print(sendbuffer[i]);
      Serial.println("]");

      // There are two ways to send packets. If you want
      // acknowledgements, use sendWithRetry():

      if (USEACK)
      {
        if (radio.sendWithRetry(TONODEID, sendbuffer, sendlength))
          Serial.println("ACK received!");
        else
          Serial.println("no ACK received");
      }

      // If you don't need acknowledgements, just use send():

      else // don't use ACK
      {
        radio.send(TONODEID, sendbuffer, sendlength);
      }

      sendlength = 0; // reset the packet
//      Blink(LED,10);
    }
  }

  // RECEIVING

  // In this section, we'll check with the RFM69HCW to see
  // if it has received any packets:

  if (radio.receiveDone()) // Got one!
  {
    // Print out the information:

    Serial.print("received from node ");
    Serial.print(radio.SENDERID, DEC);
    Serial.print(", message [");

    // The actual message is contained in the DATA array,
    // and is DATALEN bytes in size:

    for (byte i = 0; i < radio.DATALEN; i++)
      Serial.print((char)radio.DATA[i]);

    // RSSI is the "Receive Signal Strength Indicator",
    // smaller numbers mean higher power.

    Serial.print("], RSSI ");
    Serial.println(radio.RSSI);

    // Send an ACK if requested.
    // (You don't need this code if you're not using ACKs.)

    if (radio.ACKRequested())
    {
      radio.sendACK();
      Serial.println("ACK sent");
    }
//    Blink(LED,10);
  }
}

void Blink(byte PIN, int DELAY_MS)
// Blink an LED for a given number of ms
{
  digitalWrite(PIN,HIGH);
  delay(DELAY_MS);
  digitalWrite(PIN,LOW);
}

Node 2 Arduino Code
Code: [Select]
// RFM69HCW_Node_2 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     100   // Must be the same for all nodes
#define MYNODEID      2   // My node ID
#define TONODEID      255   // Destination node ID

// RFM69 frequency, uncomment the frequency of your module:

//#define FREQUENCY   RF69_433MHZ
#define FREQUENCY     RF69_915MHZ

// AES encryption (or not):

#define ENCRYPT       false // Set to "true" to use encryption
#define ENCRYPTKEY    "TOPSECRETPASSWRD" // Use the same 16-byte key on all nodes

// Use ACKnowledge when sending messages (or not):

#define USEACK        true // Request ACKs or not

// Packet sent/received indicator LED (optional):

//#define LED           9 // LED positive pin
//#define GND           8 // LED ground pin

// Create a library object for our RFM69HCW module:

RFM69 radio;

void setup()
{
  // Open a serial port so we can send keystrokes to the module:

  Serial.begin(9600);
  Serial.print("Node ");
  Serial.print(MYNODEID,DEC);
  Serial.println(" ready"); 

  // Set up the indicator LED (optional):

 // pinMode(LED,OUTPUT);
  //digitalWrite(LED,LOW);
 // pinMode(GND,OUTPUT);
 // digitalWrite(GND,LOW);

  // Initialize the RFM69HCW:

  radio.initialize(FREQUENCY, MYNODEID, NETWORKID);
  radio.setHighPower(); // Always use this for RFM69HCW

  // Turn on encryption if desired:

  if (ENCRYPT)
    radio.encrypt(ENCRYPTKEY);
  radio.promiscuous(true);
}

void loop()
{
  // Set up a "buffer" for characters that we'll send:

  static char sendbuffer[62];
  static int sendlength = 0;

  // SENDING

  // In this section, we'll gather serial characters and
  // send them to the other node if we (1) get a carriage return,
  // or (2) the buffer is full (61 characters).

  // If there is any serial input, add it to the buffer:

  if (Serial.available() > 0)
  {
    char input = Serial.read();

    if (input != '\r') // not a carriage return
    {
      sendbuffer[sendlength] = input;
      sendlength++;
    }

    // If the input is a carriage return, or the buffer is full:

    if ((input == '\r') || (sendlength == 61)) // CR or buffer full
    {
      // Send the packet!


      Serial.print("sending to node ");
      Serial.print(TONODEID, DEC);
      Serial.print(", message [");
      for (byte i = 0; i < sendlength; i++)
        Serial.print(sendbuffer[i]);
      Serial.println("]");

      // There are two ways to send packets. If you want
      // acknowledgements, use sendWithRetry():

      if (USEACK)
      {
        if (radio.sendWithRetry(TONODEID, sendbuffer, sendlength))
          Serial.println("ACK received!");
        else
          Serial.println("no ACK received");
      }

      // If you don't need acknowledgements, just use send():

      else // don't use ACK
      {
        Serial.println("Sending no ack");
        radio.send(TONODEID, sendbuffer, sendlength);
      }

      sendlength = 0; // reset the packet
//      Blink(LED,10);
    }
  }

  // RECEIVING

  // In this section, we'll check with the RFM69HCW to see
  // if it has received any packets:
  Serial.println("Trying to recieve");
  if (radio.receiveDone()) // Got one!
  {
    // Print out the information:

    Serial.print("received from node ");
    Serial.print(radio.SENDERID, DEC);
    Serial.print(", message [");

    // The actual message is contained in the DATA array,
    // and is DATALEN bytes in size:

    for (byte i = 0; i < radio.DATALEN; i++)
      Serial.print((char)radio.DATA[i]);

    // RSSI is the "Receive Signal Strength Indicator",
    // smaller numbers mean higher power.

    Serial.print("], RSSI ");
    Serial.println(radio.RSSI);

    // Send an ACK if requested.
    // (You don't need this code if you're not using ACKs.)

    if (radio.ACKRequested())
    {
      radio.sendACK();
      Serial.println("ACK sent");
    }
//    Blink(LED,10);
  }
}

void Blink(byte PIN, int DELAY_MS)
// Blink an LED for a given number of ms
{
  digitalWrite(PIN,HIGH);
  delay(DELAY_MS);
  digitalWrite(PIN,LOW);
}

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #1 on: January 21, 2017, 04:35:32 AM »
You said you have two RFM96's but the code you posted is for the RFM69.  I presume that the first is a typo and you bought two of these from sparkfun: https://www.sparkfun.com/products/12775

Rather than use their code which is linking against Felix's you could instead download the complete RFM69 library and use some of his examples.  Promiscuous mode may be the issue, I've never fooled with it.  Here is the Github: https://github.com/LowPowerLab/RFM69

jessethepro

  • NewMember
  • *
  • Posts: 8
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #2 on: January 21, 2017, 12:16:02 PM »
Thanks for the reply. I did typo on the modules. They are RFM69s. I continued to troubleshoot and uploaded the Gateway and Node examples from the repository examples to their perspective Arduinos. I left the examples "as-is" where one radio acts as a Gateway in receiving mode and the other radio transmits to the gateway. The serial output shows normal operation, but none of the traffic is being received. I have included the source code below. I am using standard Arduinos which I believe do not support SPI Flash. Is SPI Flash a requirement for the RF modules? I also have the modules about 6 inches apart and they may need to be further apart to communicate correctly so I will be pulling them apart and testing next.

Thanks,
Jesse

Gateway
Code: [Select]
// Sample RFM69 receiver/gateway sketch, with ACK and optional encryption, and Automatic Transmission Control
// Passes through any wireless received messages to the serial port & responds to ACKs
// It also looks for an onboard FLASH chip, if present
// RFM69 library and sample code by Felix Rusu - http://LowPowerLab.com/contact
// Copyright Felix Rusu (2015)

#include <RFM69.h>    //get it here: https://www.github.com/lowpowerlab/rfm69
#include <RFM69_ATC.h>//get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h>      //comes with Arduino IDE (www.arduino.cc)
#include <SPIFlash.h> //get it here: https://www.github.com/lowpowerlab/spiflash

//*********************************************************************************************
//************ IMPORTANT SETTINGS - YOU MUST CHANGE/CONFIGURE TO FIT YOUR HARDWARE *************
//*********************************************************************************************
#define NODEID        1    //unique for each node on same network
#define NETWORKID     100  //the same on all nodes that talk to each other
//Match frequency to the hardware version of the radio on your Moteino (uncomment one):
#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_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!
#define ENABLE_ATC    //comment out this line to disable AUTO TRANSMISSION CONTROL
//*********************************************************************************************

#define SERIAL_BAUD   115200

#ifdef __AVR_ATmega1284P__
  #define LED           15 // Moteino MEGAs have LEDs on D15
  #define FLASH_SS      23 // and FLASH SS on D23
#else
  #define LED           9 // Moteinos have LEDs on D9
  #define FLASH_SS      8 // and FLASH SS on D8
#endif

#ifdef ENABLE_ATC
  RFM69_ATC radio;
#else
  RFM69 radio;
#endif

SPIFlash flash(FLASH_SS, 0xEF30); //EF30 for 4mbit  Windbond chip (W25X40CL)
bool promiscuousMode = false; //set to 'true' to sniff all packets on the same network

void setup() {
  Serial.begin(SERIAL_BAUD);
  delay(10);
  radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW
  radio.setHighPower(); //only for RFM69HW!
#endif
  radio.encrypt(ENCRYPTKEY);
  radio.promiscuous(promiscuousMode);
  //radio.setFrequency(919000000); //set frequency to some custom frequency
  char buff[50];
  sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
  Serial.println(buff);
  if (flash.initialize())
  {
    Serial.print("SPI Flash Init OK. Unique MAC = [");
    flash.readUniqueId();
    for (byte i=0;i<8;i++)
    {
      Serial.print(flash.UNIQUEID[i], HEX);
      if (i!=8) Serial.print(':');
    }
    Serial.println(']');
   
    //alternative way to read it:
    //byte* MAC = flash.readUniqueId();
    //for (byte i=0;i<8;i++)
    //{
    //  Serial.print(MAC[i], HEX);
    //  Serial.print(' ');
    //}
  }
  else
    Serial.println("SPI Flash MEM not found (is chip soldered?)...");
   
#ifdef ENABLE_ATC
  Serial.println("RFM69_ATC Enabled (Auto Transmission Control)");
#endif
}

byte ackCount=0;
uint32_t packetCount = 0;
void loop() {
  //process any serial input
  if (Serial.available() > 0)
  {
    char input = Serial.read();
    if (input == 'r') //d=dump all register values
      radio.readAllRegs();
    if (input == 'E') //E=enable encryption
      radio.encrypt(ENCRYPTKEY);
    if (input == 'e') //e=disable encryption
      radio.encrypt(null);
    if (input == 'p')
    {
      promiscuousMode = !promiscuousMode;
      radio.promiscuous(promiscuousMode);
      Serial.print("Promiscuous mode ");Serial.println(promiscuousMode ? "on" : "off");
    }
   
    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 == 'D')
    {
      Serial.print("Deleting Flash chip ... ");
      flash.chipErase();
      while(flash.busy());
      Serial.println("DONE");
    }
    if (input == 'i')
    {
      Serial.print("DeviceID: ");
      word jedecid = flash.readDeviceId();
      Serial.println(jedecid, HEX);
    }
    if (input == 't')
    {
      byte temperature =  radio.readTemperature(-1); // -1 = user cal factor, adjust for correct ambient
      byte fTemp = 1.8 * temperature + 32; // 9/5=1.8
      Serial.print( "Radio Temp is ");
      Serial.print(temperature);
      Serial.print("C, ");
      Serial.print(fTemp); //converting to F loses some resolution, obvious when C is on edge between 2 values (ie 26C=78F, 27C=80F)
      Serial.println('F');
    }
  }

  if (radio.receiveDone())
  {
    Serial.print("#[");
    Serial.print(++packetCount);
    Serial.print(']');
    Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
    if (promiscuousMode)
    {
      Serial.print("to [");Serial.print(radio.TARGETID, DEC);Serial.print("] ");
    }
    for (byte i = 0; i < radio.DATALEN; i++)
      Serial.print((char)radio.DATA[i]);
    Serial.print("   [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");
   
    if (radio.ACKRequested())
    {
      byte theNodeID = radio.SENDERID;
      radio.sendACK();
      Serial.print(" - ACK sent.");

      // When a node requests an ACK, respond to the ACK
      // and also send a packet requesting an ACK (every 3rd one only)
      // This way both TX/RX NODE functions are tested on 1 end at the GATEWAY
      if (ackCount++%3==0)
      {
        Serial.print(" Pinging node ");
        Serial.print(theNodeID);
        Serial.print(" - ACK...");
        delay(3); //need this when sending right after reception .. ?
        if (radio.sendWithRetry(theNodeID, "ACK TEST", 8, 0))  // 0 = only 1 attempt, no retries
          Serial.print("ok!");
        else Serial.print("nothing");
      }
    }
    Serial.println();
    Blink(LED,3);
  }
}

void Blink(byte PIN, int DELAY_MS)
{
  pinMode(PIN, OUTPUT);
  digitalWrite(PIN,HIGH);
  delay(DELAY_MS);
  digitalWrite(PIN,LOW);
}

Node
Code: [Select]
// Sample RFM69 sender/node sketch, with ACK and optional encryption, and Automatic Transmission Control
// Sends periodic messages of increasing length to gateway (id=1)
// It also looks for an onboard FLASH chip, if present
// RFM69 library and sample code by Felix Rusu - http://LowPowerLab.com/contact
// Copyright Felix Rusu (2015)

#include <RFM69.h>    //get it here: https://www.github.com/lowpowerlab/rfm69
#include <RFM69_ATC.h>//get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h>
#include <SPIFlash.h> //get it here: https://www.github.com/lowpowerlab/spiflash

//*********************************************************************************************
//************ IMPORTANT SETTINGS - YOU MUST CHANGE/CONFIGURE TO FIT YOUR HARDWARE *************
//*********************************************************************************************
#define NODEID        2    //must be unique for each node on same network (range up to 254, 255 is used for broadcast)
#define NETWORKID     100  //the same on all nodes that talk to each other (range up to 255)
#define GATEWAYID     1
//Match frequency to the hardware version of the radio on your Moteino (uncomment one):
#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_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!
#define ENABLE_ATC    //comment out this line to disable AUTO TRANSMISSION CONTROL
//*********************************************************************************************

#ifdef __AVR_ATmega1284P__
  #define LED           15 // Moteino MEGAs have LEDs on D15
  #define FLASH_SS      23 // and FLASH SS on D23
#else
  #define LED           9 // Moteinos have LEDs on D9
  #define FLASH_SS      8 // and FLASH SS on D8
#endif

#define SERIAL_BAUD   115200

int TRANSMITPERIOD = 150; //transmit a packet to gateway so often (in ms)
char payload[] = "123 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char buff[20];
byte sendSize=0;
boolean requestACK = false;
SPIFlash flash(FLASH_SS, 0xEF30); //EF30 for 4mbit  Windbond chip (W25X40CL)

#ifdef ENABLE_ATC
  RFM69_ATC radio;
#else
  RFM69 radio;
#endif

void setup() {
  Serial.begin(SERIAL_BAUD);
  radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW
  radio.setHighPower(); //uncomment only for RFM69HW!
#endif
  radio.encrypt(ENCRYPTKEY);
  //radio.setFrequency(919000000); //set frequency to some custom frequency

//Auto Transmission Control - dials down transmit power to save battery (-100 is the noise floor, -90 is still pretty good)
//For indoor nodes that are pretty static and at pretty stable temperatures (like a MotionMote) -90dBm is quite safe
//For more variable nodes that can expect to move or experience larger temp drifts a lower margin like -70 to -80 would probably be better
//Always test your ATC mote in the edge cases in your own environment to ensure ATC will perform as you expect
#ifdef ENABLE_ATC
  radio.enableAutoPower(-70);
#endif

  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.print("SPI Flash Init OK ... UniqueID (MAC): ");
    flash.readUniqueId();
    for (byte i=0;i<8;i++)
    {
      Serial.print(flash.UNIQUEID[i], HEX);
      Serial.print(' ');
    }
    Serial.println();
  }
  else
    Serial.println("SPI Flash MEM not found (is chip soldered?)...");

#ifdef ENABLE_ATC
  Serial.println("RFM69_ATC Enabled (Auto Transmission Control)\n");
#endif
}

void Blink(byte PIN, int DELAY_MS)
{
  pinMode(PIN, OUTPUT);
  digitalWrite(PIN,HIGH);
  delay(DELAY_MS);
  digitalWrite(PIN,LOW);
}

long lastPeriod = 0;
void loop() {
  //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:");
      uint16_t counter = 0;

      Serial.print("0-256: ");
      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.RSSI);Serial.print("]");

    if (radio.ACKRequested())
    {
      radio.sendACK();
      Serial.print(" - ACK sent");
    }
    Blink(LED,3);
    Serial.println();
  }

  int currPeriod = millis()/TRANSMITPERIOD;
  if (currPeriod != lastPeriod)
  {
    lastPeriod=currPeriod;

    //send FLASH id
    if(sendSize==0)
    {
      sprintf(buff, "FLASH_MEM_ID:0x%X", flash.readDeviceId());
      byte buffLen=strlen(buff);
      if (radio.sendWithRetry(GATEWAYID, buff, buffLen))
        Serial.print(" ok!");
      else Serial.print(" nothing...");
      //sendSize = (sendSize + 1) % 31;
    }
    else
    {
      Serial.print("Sending[");
      Serial.print(sendSize);
      Serial.print("]: ");
      for(byte i = 0; i < sendSize; i++)
        Serial.print((char)payload[i]);

      if (radio.sendWithRetry(GATEWAYID, payload, sendSize))
       Serial.print(" ok!");
      else Serial.print(" nothing...");
    }
    sendSize = (sendSize + 1) % 31;
    Serial.println();
    Blink(LED,3);
  }
}

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #3 on: January 21, 2017, 12:59:04 PM »
1.  Your second set of sketches show them being set to 433Mhz, whereas the first shows 915Mhz.  Which is it?

2.  Try disabling the cansend function in the library (just make it return "true") and then recompile.  My guess is that will work.  If so, then address the background noise issue, which is a topic unto itself.

jessethepro

  • NewMember
  • *
  • Posts: 8
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #4 on: January 21, 2017, 03:43:26 PM »
Thanks for the comments. I was trying both freqs to see if there was a difference. I set the Gateway and Node examples to 915mhz for consistency. I also set the cansend() function to return true (I am guessing cansend() is a function of the Automatic Transmission Control). I also pulled the radios to a foot apart and reconnected all of my jumper wires to ensure I have it wired correctly. Both the Gateway and Node show normal operation but no data is being received at the Gateway. The only complaint I get out of the serial interface on the Gateway is an "SPI Flash MEM not found (is chip soldered?)...". Is SPI Flash memory a requirement for the radios to work? Or for that matter, is persistent storage required? Any other suggestions would be appreciated.

Thanks,

Jesse

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #5 on: January 21, 2017, 04:10:40 PM »
Nope, you do not need flash or storage of any sort for the radios to work.  They have a chip on them which takes care of storing the FIFO and register settings for their operation.  You did solder on antennas right?  You should use 82mm for 915MHz modules.  Without the antennas not only will they not broadcast, you can harm the amplifiers.  Also, you do have the DIO0 pin on the radio connected to INT0/Pin 2 on the Arduinos right?  The library is interrupt driven and without that connection neither radio will do much of anything.

jessethepro

  • NewMember
  • *
  • Posts: 8
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #6 on: January 21, 2017, 04:32:58 PM »
Good to know I don't need persistent storage. The hookup guide I read set the antenna length to 78mm. I used 22 gauge solid core wire for the antennas and they are measured to the 78 mm. Interrupt D0 is going to pin 2 on the Arduino. I have attached a couple of photos of the Gateway board. The Node board is wired identically (same color scheme). I bent the antenna over to get the camera to focus right, but normally it is standing straight up. Again, I appreciate all the comments and look forward to hopefully getting the modules to work.

Thanks,

Jesse

https://goo.gl/photos/vsLS3YrsX1zB8zQV8
https://goo.gl/photos/2c2xGVnYXtYoWnxZ6
« Last Edit: January 21, 2017, 04:38:04 PM by jessethepro »

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #7 on: January 21, 2017, 05:29:40 PM »
Yeah, those are the correct pins from the radio and into the arduino.  Maybe your battery voltage under load is dipping below 2.4V?  I know that is a long shot but it would kill the transmission.

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #8 on: January 21, 2017, 05:45:01 PM »
Here's your problem: 
Code: [Select]
#define IS_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!

Your radio is not an RFM69HW.

jessethepro

  • NewMember
  • *
  • Posts: 8
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #9 on: January 21, 2017, 10:08:09 PM »
Through a couple of my iterations of testing, I commented out IS_RFM69HW tried to communicate with no success. Sparkfun lists the component as an RFM69HCW which comes preconfigured to a frequency (in my case its 915mhz, just caught that by the way :-) ). I do not know if the HCW version is compatible with the HW version, but I have attempted to get the radios to communicate with both options. I keep thinking I am missing something simple. I do appreciate the help and I will keep testing till the radios are operational.

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #10 on: January 21, 2017, 11:22:45 PM »
The C doesn't matter, all that matters is H or no H.  The sparkfun radio is an H, a high-powered radio, so it needs that line of code in order to set the high powered registers PA1 and PA2.

EDIT: Try adding ReadAllRegs() just prior to leaving setup so you can inspect what the registers are set to.  Also worth dumping the value of DDRB, PORTB, PINB, SPCR, SPSR, and PRR since those can jack up the radio as well.  I have some code lying around since I *just* got done fighting an issue of my own:

Code: [Select]
radio.readAllRegs();
  Serial.print("58 - ");
  Serial.print(readReg(0x58),HEX);
  Serial.print(" - ");
  Serial.print(readReg(0x58),BIN);
  Serial.print("\n5A - ");
  Serial.print(readReg(0x5A),HEX);
  Serial.print(" - ");
  Serial.print(readReg(0x5A),BIN);
  Serial.print("\n5C - ");
  Serial.print(readReg(0x5C),HEX);
  Serial.print(" - ");
  Serial.print(readReg(0x5C),BIN);
  Serial.print("\n6F - ");
  Serial.print(readReg(0x6F),HEX);
  Serial.print(" - ");
  Serial.print(readReg(0x6F),BIN);
  Serial.print("\n71 - ");
  Serial.print(readReg(0x71),HEX);
  Serial.print(" - ");
  Serial.print(readReg(0x71),BIN);
  Serial.print("\nDDRB: ");
  Serial.print(DDRB);
  Serial.print("\tPORTB: ");
  Serial.print(PORTB);
  Serial.print("\tPINB: ");
  Serial.print(PINB);
  Serial.print("\nDDRC: ");
  Serial.print(DDRC);
  Serial.print("\tPORTC: ");
  Serial.print(PORTC);
  Serial.print("\tPINC: ");
  Serial.print(PINC);
  Serial.print("\nDDRD: ");
  Serial.print(DDRD);
  Serial.print("\tPORTD: ");
  Serial.print(PORTD);
  Serial.print("\tPIND: ");
  Serial.print(PIND);
  Serial.print("\nSPSR: ");
  Serial.print(SPSR);
  Serial.print("\tSPCR: ");
  Serial.print(SPCR);
  Serial.print("\tPRR: ");
  Serial.print(PRR);
  Serial.print("\tSREG: ");
  Serial.print(SREG);
« Last Edit: January 21, 2017, 11:33:16 PM by ChemE »

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #11 on: January 21, 2017, 11:39:43 PM »
Here's your problem: 
Code: [Select]
#define IS_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!

Your radio is not an RFM69HW.

SparkFun sells the RFM69HCW so that line of code needs to be uncommented so PA1 and PA2 are set properly.  The comment should actually say:

Code: [Select]
// =========================== THIS IS VERY IMPORTANT=============================
#define IS_RFM69HW    // Does your radio have an H in the model number?  If yes leave this line, if no comment it out

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #12 on: January 22, 2017, 03:43:14 AM »
Thanks, ChemE, for correcting me.  I didn't realize there even existed an RFM69HCW.  I'll have to give that module a closer look. 

Great catch!

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #13 on: January 22, 2017, 08:55:08 AM »
No worries WhiteHare!  It is just a 16mmx16mm version of the RFM69HW that like the RFM69CW is pin compatible with the RFM12B.

jessethepro

  • NewMember
  • *
  • Posts: 8
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #14 on: January 22, 2017, 02:33:32 PM »
With reworking the code I did find a few anomalies. On the Node side, the system was blocking on the functions with SPI Flash. I took out all references to SPI Flash on both the Gateway and Node. I further cleaned out a lot of code that was not needed for the operation and streamlined the execution. Now the Node sends a 30 byte packet every 3 seconds to the Gateway without encryption or acknowledgments. The Gateway loops over recieveDone() looking for packets. I now have a high amount of confidence the packet is being sent out, but still can't seem to receive any packets at the Gateway. Lastly, I added the code from ChemE to dump the registers. I have included the updated code for both Node and Gateway and their output from their registers.

Node Registers
Transmitting at 915 Mhz...
Address - HEX - BIN
1 - 0 - 0
2 - 80 - 10000000
3 - 80 - 10000000
4 - 80 - 10000000
5 - 80 - 10000000
6 - 80 - 10000000
7 - 80 - 10000000
8 - 0 - 0
9 - 0 - 0
A - 0 - 0
B - 0 - 0
C - 0 - 0
D - 0 - 0
E - 0 - 0
F - 0 - 0
10 - C0 - 11000000
11 - C0 - 11000000
12 - 0 - 0
13 - 0 - 0
14 - 80 - 10000000
15 - 80 - 10000000
16 - 0 - 0
17 - 0 - 0
18 - C7 - 11000111
19 - C7 - 11000111
1A - C7 - 11000111
1B - C7 - 11000111
1C - 80 - 10000000
1D - 80 - 10000000
1E - 80 - 10000000
1F - 80 - 10000000
20 - 80 - 10000000
21 - 81 - 10000001
22 - 80 - 10000000
23 - 80 - 10000000
24 - 0 - 0
25 - 0 - 0
26 - C - 1100
27 - C - 1100
28 - 0 - 0
29 - 0 - 0
2A - 0 - 0
2B - 0 - 0
2C - F2 - 11110010
2D - F2 - 11110010
2E - 20 - 100000
2F - 20 - 100000
30 - 0 - 0
31 - 0 - 0
32 - 0 - 0
33 - 0 - 0
34 - 0 - 0
35 - 0 - 0
36 - 80 - 10000000
37 - 80 - 10000000
38 - 0 - 0
39 - 0 - 0
3A - 0 - 0
3B - 0 - 0
3C - 0 - 0
3D - 0 - 0
3E - 0 - 0
3F - 0 - 0
40 - 4 - 100
41 - 80 - 10000000
42 - 0 - 0
43 - 82 - 10000010
44 - C0 - 11000000
45 - C0 - 11000000
46 - C0 - 11000000
47 - C0 - 11000000
48 - 0 - 0
49 - 0 - 0
4A - 0 - 0
4B - 0 - 0
4C - C0 - 11000000
4D - C0 - 11000000
4E - 0 - 0
4F - E0 - 11100000
58 - 20 - 100000
5A - 10 - 10000
5C - C0 - 10000000
6F - C0 - 11000000
71 - 0 - 0
DDRB: 44   PORTB: 4   PINB: 12
DDRC: 0   PORTC: 0   PINC: 0
DDRD: 0   PORTD: 0   PIND: 27
SPSR: 0   SPCR: 80   PRR: 0   SREG: 194
Sending[30]: 123 ABCDEFGHIJKLMNOPQRSTUVWXYZ


Gateway Registers
Listening at 915 Mhz...
Address - HEX - BIN
1 - 80 - 10000000
2 - 4 - 100
3 - 0 - 0
4 - 0 - 0
5 - 2 - 10
6 - 4 - 100
7 - E1 - 11100001
8 - 80 - 10000000
9 - 0 - 0
A - 4 - 100
B - 0 - 0
C - 2 - 10
D - 83 - 10000011
E - 4 - 100
F - 0 - 0
10 - 3 - 11
11 - 78 - 1111000
12 - 4 - 100
13 - E - 1110
14 - 80 - 10000000
15 - A0 - 10100000
16 - 4 - 100
17 - 94 - 10010100
18 - 0 - 0
19 - 2 - 10
1A - 4 - 100
1B - 0 - 0
1C - 0 - 0
1D - 4 - 100
1E - 4 - 100
1F - 0 - 0
20 - 0 - 0
21 - 0 - 0
22 - 4 - 100
23 - 0 - 0
24 - 0 - 0
25 - 0 - 0
26 - 4 - 100
27 - 80 - 10000000
28 - 81 - 10000001
29 - D8 - 11011000
2A - 4 - 100
2B - 0 - 0
2C - 0 - 0
2D - 3 - 11
2E - 4 - 100
2F - 1 - 1
30 - 40 - 1000000
31 - 0 - 0
32 - 4 - 100
33 - 0 - 0
34 - 0 - 0
35 - 0 - 0
36 - 4 - 100
37 - 80 - 10000000
38 - 0 - 0
39 - 0 - 0
3A - 4 - 100
3B - 0 - 0
3C - 8C - 10001100
3D - 0 - 0
3E - 4 - 100
3F - 41 - 1000001
40 - D3 - 11010011
41 - 60 - 1100000
42 - 4 - 100
43 - 40 - 1000000
44 - 82 - 10000010
45 - 59 - 1011001
46 - 4 - 100
47 - 61 - 1100001
48 - F1 - 11110001
49 - 60 - 1100000
4A - 4 - 100
4B - A - 1010
4C - C3 - 11000011
4D - 70 - 1110000
4E - 4 - 100
4F - 0 - 0
58 - 28 - 101000
5A - 4 - 100
5C - E0 - 11100000
6F - 20 - 100000
71 - 0 - 0
DDRB: 44   PORTB: 4   PINB: 12
DDRC: 0   PORTC: 0   PINC: 0
DDRD: 0   PORTD: 0   PIND: 3
SPSR: 0   SPCR: 80   PRR: 0   SREG: 194

Node Code
Code: [Select]
// Sample RFM69 sender/node sketch, with ACK and optional encryption, and Automatic Transmission Control
// Sends periodic messages of increasing length to gateway (id=1)
// It also looks for an onboard FLASH chip, if present
// RFM69 library and sample code by Felix Rusu - http://LowPowerLab.com/contact
// Copyright Felix Rusu (2015)

#include <RFM69.h>    //get it here: https://www.github.com/lowpowerlab/rfm69
#include <RFM69_ATC.h>//get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h>

//*********************************************************************************************
//************ IMPORTANT SETTINGS - YOU MUST CHANGE/CONFIGURE TO FIT YOUR HARDWARE *************
//*********************************************************************************************
#define NODEID        2    //must be unique for each node on same network (range up to 254, 255 is used for broadcast)
#define NETWORKID     100  //the same on all nodes that talk to each other (range up to 255)
#define GATEWAYID     1
//Match frequency to the hardware version of the radio on your Moteino (uncomment one):
//#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_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!
//#define ENABLE_ATC    //comment out this line to disable AUTO TRANSMISSION CONTROL
//*********************************************************************************************


#define SERIAL_BAUD   115200

int TRANSMITPERIOD = 150; //transmit a packet to gateway so often (in ms)
char payload[] = "123 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char buff[20];
int sendSize=30;
boolean requestACK = false;

//RFM69_ATC radio;
RFM69 radio;

void setup() {
  Serial.begin(SERIAL_BAUD);
  radio.initialize(FREQUENCY,NODEID,NETWORKID);
  radio.setHighPower(); //uncomment only for RFM69HW!
  radio.encrypt(ENCRYPTKEY);
  //radio.setFrequency(919000000); //set frequency to some custom frequency

//Auto Transmission Control - dials down transmit power to save battery (-100 is the noise floor, -90 is still pretty good)
//For indoor nodes that are pretty static and at pretty stable temperatures (like a MotionMote) -90dBm is quite safe
//For more variable nodes that can expect to move or experience larger temp drifts a lower margin like -70 to -80 would probably be better
//Always test your ATC mote in the edge cases in your own environment to ensure ATC will perform as you expect
#ifdef ENABLE_ATC
  radio.enableAutoPower(-70);
#endif

  char buff[50];
  sprintf(buff, "\nTransmitting at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
  Serial.println(buff);

#ifdef ENABLE_ATC
  Serial.println("RFM69_ATC Enabled (Auto Transmission Control)\n");
#endif

  radio.readAllRegs();
  Serial.print("58 - ");
  Serial.print(radio.readReg(0x58),HEX);
  Serial.print(" - ");
  Serial.print(radio.readReg(0x58),BIN);
  Serial.print("\n5A - ");
  Serial.print(radio.readReg(0x5A),HEX);
  Serial.print(" - ");
  Serial.print(radio.readReg(0x5A),BIN);
  Serial.print("\n5C - ");
  Serial.print(radio.readReg(0x5C),HEX);
  Serial.print(" - ");
  Serial.print(radio.readReg(0x5C),BIN);
  Serial.print("\n6F - ");
  Serial.print(radio.readReg(0x6F),HEX);
  Serial.print(" - ");
  Serial.print(radio.readReg(0x6F),BIN);
  Serial.print("\n71 - ");
  Serial.print(radio.readReg(0x71),HEX);
  Serial.print(" - ");
  Serial.print(radio.readReg(0x71),BIN);
  Serial.print("\nDDRB: ");
  Serial.print(DDRB);
  Serial.print("\tPORTB: ");
  Serial.print(PORTB);
  Serial.print("\tPINB: ");
  Serial.print(PINB);
  Serial.print("\nDDRC: ");
  Serial.print(DDRC);
  Serial.print("\tPORTC: ");
  Serial.print(PORTC);
  Serial.print("\tPINC: ");
  Serial.print(PINC);
  Serial.print("\nDDRD: ");
  Serial.print(DDRD);
  Serial.print("\tPORTD: ");
  Serial.print(PORTD);
  Serial.print("\tPIND: ");
  Serial.print(PIND);
  Serial.print("\nSPSR: ");
  Serial.print(SPSR);
  Serial.print("\tSPCR: ");
  Serial.print(SPCR);
  Serial.print("\tPRR: ");
  Serial.print(PRR);
  Serial.print("\tSREG: ");
  Serial.print(SREG);
  Serial.println();
  //radio.encrypt(ENCRYPTKEY);
}
void loop() {
 
  //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.RSSI);Serial.print("]");

    if (radio.ACKRequested())
    {
      radio.sendACK();
      Serial.print(" - ACK sent");
    }
    Serial.println();
  }
 
  Serial.print("Sending[");
  Serial.print(sendSize);
  Serial.print("]: ");
  for(byte i = 0; i < sendSize; i++)
    Serial.print((char)payload[i]);
  radio.send(GATEWAYID, payload, sendSize);
  delay(3000);
  Serial.println();
}

Gateway Code
Code: [Select]
// Sample RFM69 receiver/gateway sketch, with ACK and optional encryption, and Automatic Transmission Control
// Passes through any wireless received messages to the serial port & responds to ACKs
// It also looks for an onboard FLASH chip, if present
// RFM69 library and sample code by Felix Rusu - http://LowPowerLab.com/contact
// Copyright Felix Rusu (2015)

#include <RFM69.h>    //get it here: https://www.github.com/lowpowerlab/rfm69
#include <RFM69_ATC.h>//get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h>      //comes with Arduino IDE (www.arduino.cc)

//*********************************************************************************************
//************ IMPORTANT SETTINGS - YOU MUST CHANGE/CONFIGURE TO FIT YOUR HARDWARE *************
//*********************************************************************************************
#define NODEID        1    //unique for each node on same network
#define NETWORKID     100  //the same on all nodes that talk to each other
//Match frequency to the hardware version of the radio on your Moteino (uncomment one):
//#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_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!
//#define ENABLE_ATC    //comment out this line to disable AUTO TRANSMISSION CONTROL
//*********************************************************************************************

#define SERIAL_BAUD   115200

  //RFM69_ATC radio;
  RFM69 radio;

bool promiscuousMode = false; //set to 'true' to sniff all packets on the same network

void setup() {
  Serial.begin(SERIAL_BAUD);
  delay(10);
  radio.initialize(FREQUENCY,NODEID,NETWORKID);
  radio.setHighPower(); //only for RFM69HW!
  //radio.encrypt(ENCRYPTKEY);
  //radio.promiscuous(promiscuousMode);
  //radio.setFrequency(919000000); //set frequency to some custom frequency
  char buff[50];
  sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
  Serial.println(buff);
   
#ifdef ENABLE_ATC
  Serial.println("RFM69_ATC Enabled (Auto Transmission Control)");
#endif
  radio.readAllRegs();
  Serial.print("58 - ");
  Serial.print(radio.readReg(0x58),HEX);
  Serial.print(" - ");
  Serial.print(radio.readReg(0x58),BIN);
  Serial.print("\n5A - ");
  Serial.print(radio.readReg(0x5A),HEX);
  Serial.print(" - ");
  Serial.print(radio.readReg(0x5A),BIN);
  Serial.print("\n5C - ");
  Serial.print(radio.readReg(0x5C),HEX);
  Serial.print(" - ");
  Serial.print(radio.readReg(0x5C),BIN);
  Serial.print("\n6F - ");
  Serial.print(radio.readReg(0x6F),HEX);
  Serial.print(" - ");
  Serial.print(radio.readReg(0x6F),BIN);
  Serial.print("\n71 - ");
  Serial.print(radio.readReg(0x71),HEX);
  Serial.print(" - ");
  Serial.print(radio.readReg(0x71),BIN);
  Serial.print("\nDDRB: ");
  Serial.print(DDRB);
  Serial.print("\tPORTB: ");
  Serial.print(PORTB);
  Serial.print("\tPINB: ");
  Serial.print(PINB);
  Serial.print("\nDDRC: ");
  Serial.print(DDRC);
  Serial.print("\tPORTC: ");
  Serial.print(PORTC);
  Serial.print("\tPINC: ");
  Serial.print(PINC);
  Serial.print("\nDDRD: ");
  Serial.print(DDRD);
  Serial.print("\tPORTD: ");
  Serial.print(PORTD);
  Serial.print("\tPIND: ");
  Serial.print(PIND);
  Serial.print("\nSPSR: ");
  Serial.print(SPSR);
  Serial.print("\tSPCR: ");
  Serial.print(SPCR);
  Serial.print("\tPRR: ");
  Serial.print(PRR);
  Serial.print("\tSREG: ");
  Serial.print(SREG);
  Serial.println();
}

byte ackCount=0;
uint32_t packetCount = 0;
void loop() {
  if (radio.receiveDone())
  {
    Serial.print("#[");
    Serial.print(++packetCount);
    Serial.print(']');
    Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
    if (promiscuousMode)
    {
      Serial.print("to [");Serial.print(radio.TARGETID, DEC);Serial.print("] ");
    }
    for (byte i = 0; i < radio.DATALEN; i++)
      Serial.print((char)radio.DATA[i]);
    Serial.print("   [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");
   
    if (radio.ACKRequested())
    {
      byte theNodeID = radio.SENDERID;
      radio.sendACK();
      Serial.print(" - ACK sent.");

      // When a node requests an ACK, respond to the ACK
      // and also send a packet requesting an ACK (every 3rd one only)
      // This way both TX/RX NODE functions are tested on 1 end at the GATEWAY
      if (ackCount++%3==0)
      {
        Serial.print(" Pinging node ");
        Serial.print(theNodeID);
        Serial.print(" - ACK...");
        delay(3); //need this when sending right after reception .. ?
        if (radio.sendWithRetry(theNodeID, "ACK TEST", 8, 0))  // 0 = only 1 attempt, no retries
          Serial.print("ok!");
        else Serial.print("nothing");
      }
    }
    Serial.println();
  }
}

jessethepro

  • NewMember
  • *
  • Posts: 8
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #15 on: January 22, 2017, 03:16:00 PM »
ChemE and WhiteHare thank you for the assistance with the Sparkfun module. I am going to give up on these modules and return them to Sparkfun and give the Adafruit modules of same hardware a try. The Adafruit modules look to have a little more engineering put into them and more stable/tested software.

Thanks,

Jesse

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #16 on: January 22, 2017, 03:31:30 PM »
In all seriousness, if you're just getting started, I suggest you start with two or three Moteino's.  Then, if you're so inclined, you can branch out from there.  It's easier getting started with known good hardware that "just works", and the Moteino's are that.

jessethepro

  • NewMember
  • *
  • Posts: 8
  • Country: us
Re: Operation Freezing on radio.send()
« Reply #17 on: January 22, 2017, 03:59:56 PM »
Thanks for the suggestion. I think I will switch to the Moteino's.