pinMode( RFM69_RST, OUTPUT );
digitalWrite( RFM69_RST, HIGH); // RESET
delay( 100 );
digitalWrite( RFM69_RST, LOW); // ~RESET
delay( 100 );
pinMode( RFM69_RST, OUTPUT );
digitalWrite( RFM69_RST, HIGH); // RESET
delay( 100 );
pinMode( RFM69_RST, INPUT );
delay( 100 );
// rf69_client.pde
// -*- mode: C++ -*-
#include <SPI.h>
#include <RH_RF69.h>
#define RFM69_RST 5
#define RFM69_EN 6
#define RFM69_SS 8
#define RFM69_IRQ 7
#define TFT_CS 10
// Singleton instance of the radio driver
// Want ( SS pin, IRQ pin )
//digitalWrite( RFM69_EN, HIGH); // Enable
RH_RF69 rf69(RFM69_SS, RFM69_IRQ );
void setup()
{
pinMode( RFM69_RST, OUTPUT );
digitalWrite( RFM69_RST, HIGH); // RESET
delay( 100 );
// pinMode( RFM69_RST, INPUT ); // Doesn't work
digitalWrite( RFM69_RST, LOW); // Works
delay( 100 );
pinMode( RFM69_EN, OUTPUT );
digitalWrite( RFM69_EN, HIGH); // Enable
pinMode( TFT_CS, OUTPUT );
digitalWrite( TFT_CS, HIGH ); // TFT Chip select
Serial.begin(115200);
delay( 1000 );
Serial.printf( "Start\n" );
delay( 1000 );
if (!rf69.init())
Serial.println("init failed");
Serial.printf( "Init() Successful\n" ); delay( 1000 );
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
// No encryption
if (!rf69.setFrequency(915.0))
Serial.println("setFrequency failed");
// If you are using a high power RF69, you *must* set a Tx power in the
// range 14 to 20 like this:
rf69.setTxPower(20);
// The encryption key has to be the same as the one in the server
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
rf69.setEncryptionKey(key);
//rf69.setModemConfig( RH_RF69::GFSK_Rb55555Fd50 );
Serial.println( "Init-ed" );
}
void loop()
{
Serial.print("Sending to rf69_server ");
Serial.println( millis() / 1000 );
// Send a message to rf69_server
uint8_t data[] = "Hello Teensy World!";
rf69.send(data, sizeof(data));
Serial.println("Waiting for sent");
rf69.waitPacketSent();
Serial.println("Sent. Waiting for reply");
// Now wait for a reply
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf69.waitAvailableTimeout(500))
{
// Should be a reply message for us now
if (rf69.recv(buf, &len))
{
Serial.print("got reply: ");
Serial.println((char*)buf);
}
else
{
Serial.println("recv failed");
}
}
else
{
Serial.println("No reply, is rf69_server running?");
}
delay(1000);
}
printRegisters();
0 0
1 4
2 0
3 1A
4 B
...
// Perform a hardware reset per davidthings. The reset pin on the RFM69HCW is set to Teensy 3.2 digital pin 6
pinMode(6, OUTPUT);
digitalWrite(6, HIGH); //RESET
delay( 100);
digitalWrite(6, LOW); // ~RESET
delay(100);
// end of reset;
// Previously added delay may be unnecessary now:
while (!Serial && (millis() <= 8000));
Serial.println("Hello World");
Serial.println("rf69_server set up complete.");
// End of my addition
pinMode(6, OUTPUT);
digitalWrite(6, HIGH); //RESET
delayMicroseconds(150);
pinMode(6, INPUT); // ~RESET
delay(100);
// end of reset;
By default the constructor is called with interruptPin=2, just to be certain, DIO0 of the RFM radio module was wired to Pin 2 on the Teensy? That pin is used to read whether the radio has finished transmission or has received anything.Uncommented line RH_RF69 rf69(15, 16); because I wasn't sure if this referred to any Teensy-compatible breakout board or PJRC's proprietary one.
- Downloaded the most recent RadioHead library files from www.airspace.com/mikem/aduino/RadioHead
- Removed the RadioHead library files from c:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\RadioHead
- ...
#include "RFM69.h"
#include <SPI.h>
#define networkID 1 //same for all nodes
#define SENDERID 2 //This node id
#define TARGETID 1 // to receiving node
#define freqBand RF69_915MHZ
#define ENCRYPT false //set to true for encryption
#define ENCRYPTKEY "sampleEncryptKey" //all nodes must have the same
#define ACKrequested false //set to true for acknowledgement
#define _isRFM69HW // comment out for RFM69W
#define LED 15
#define SERIAL_Baud 115200
//for Teensy-LC
#define RF69_RST 9
#define RF69_CS 10
#define RF69_IRQ_pin 2
#define RF69_IRQ_NUM 10
RFM69 radio;
void setup()
{
// put your setup code here, to run once:
while (!Serial);
Serial.begin(9600);
Serial.println("RFM69HCW ready");
//Reset the RFM module
pinMode(RF69_RST,OUTPUT);
digitalWrite(RF69_RST,HIGH);
delay(100);
digitalWrite(RF69_RST,LOW);
delay(100);
radio.initialize(freqBand, SENDERID, networkID);
radio.setHighPower();
radio.setPowerLevel(31); //power level ranges from 0 (5dBm)
/* if (ENCRYPT)
radio.encrypt(ENCRYPTKEY);*/
}
void loop()
{
static char sendbuffer[62];
static int sendlength = 0;
if (Serial.available() > 0)
{
char input = Serial.read();
if (input != '\r')
{
sendbuffer[sendlength] = input;
sendlength++;
}
if ((input =='\r') || (sendlength == 61))
{
Serial.print("sending to node");
Serial.print(SENDERID,DEC);
for (byte i=0; i < sendlength; i++)
Serial.print(sendbuffer[i]);
Serial.println("]");
if (ACKrequested)
{
if (radio.sendWithRetry(TARGETID, sendbuffer, sendlength))
Serial.println("ACK received");
else
Serial.println("No ACK");
}
else
{
radio.send(TARGETID, sendbuffer, sendlength);
}
sendlength = 0;
digitalWrite(LED,HIGH);
delay(20);
digitalWrite(LED,LOW);
delay(20);
}
}
if (radio.receiveDone())
{
Serial.print("received from node");
Serial.print(SENDERID, DEC);
Serial.print("message [");
for (byte i= 0; i < radio.DATALEN; i++)
Serial.print((char)radio.DATA[i]);
Serial.print("],RSSI");
Serial.println(radio.RSSI);
if (radio.ACKRequested())
{radio.sendACK();
Serial.println("ACK sent");
}
digitalWrite(LED,HIGH);
delay(20);
digitalWrite(LED,LOW);
delay(20);
}
}
With SCK on p13 the LED will flash when there is any transmission. No flash - then no transfer is happening. LED will normally be off when no activity.As for my onboard led, I just noticed that the LC that receives (no TX) has the led lit, but the other LC (TX, no RX) does not. Since I'm using that pin as SCK, which one is suspect?
As I read that you have multiple units connected and in the case of Teensy you can't select which one downloads? Try TYQT - You can push button from GUI or have it replace TeensyDuino and it will allow selection of the device from a given IDE instance. Very flexible and feature filled and a great Serial Monitor too that can run multiple copies for multiple devices....
- always able to reprogram without finding other boards
Good news on seeing it work.
With SCK on p13 the LED will flash when there is any transmission. No flash - then no transfer is happening. LED will normally be off when no activity.
if (digitalRead(SENDER_DETECT_PIN) == LOW){
Serial.println("Going Receiver!");
receiver(); // this function never returns and contains an infinite loop.
} else {
Serial.println("Going sender!");
sender(); // this function never returns and contains an infinite loop.
}
@iwanders - I ordered your board from https://pcbs.io/search (that link goes to the shared boards page)
...