Forum

RFM69 - testing exa...
 
Notifications
Clear all

RFM69 - testing example, spy mode

1 Posty
1 Users
0 Reactions
390 Widok
0
Topic starter

example arduino code

1 Answer
0
Topic starter

example spy mode code  (from-to), network 100, modify to your needs

// 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     100   // Must be the same for all nodes
#define MYNODEID      66   // 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

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

#define LED           LED_BUILTIN // LED positive pin
#define GND           D2 // LED ground pin

// Create a library object for our RFM69HCW module:

RFM69 radio;
static char sendbuffer[62];
void setup()
{
  // Open a serial port so we can send keystrokes to the module:

  Serial.begin(115200);
  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.setCS(D8);  //uncomment this if using Pro Micro
  radio.initialize(FREQUENCY, MYNODEID, NETWORKID);
  radio.setHighPower(); // Always use this for RFM69HCW

  Serial.println(" data send");  
  Serial.println(radio.RSSI);
}

void loop()
{

  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);

    Blink(LED,10);
  
  }
}

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

 

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: