Uploaded example Sparkfun tx code to samd21 Pro RF and it sends out messages as it should, tx led flashing.
Moved it off computer to battery supply and it no longer transmits. Changed to wall supply,changed cables,reset, still not transmitting.
Moved it back to computer, works again. Flash a blink sketch and move to battery, works fine.
Reflash tx sketch and move to battery, no transmit.
It seems like it needs a kick from computer to start, very strange.
That is odd; ensure the switch is flipped toward the PTH pins/holes https://learn.sparkfun.com/tutorials/sp … e-overview
What size is the battery? Also, I believe you already did this, but…also try pressing reset with each test setup (including hooked up to PC), and maybe see if it works correctly with any particular situation?
Switch in correct position, pwr led on , I should have mentioned that.
Battery is a 5v battery pack powered by usb, also tried usb wall supply so basically the same power as computer.
Reset works normally on computer connection.
Also tried 2 different boards with same result.
When I did the last test I turned on computer (windows 10) and plugged in the board. Red light came on but tx didnot start until the computer completely finished booting.
Ok to sum up this is a Sparkfun board with a Sparkfun unaltered sketch. I have two boards with the same problem, that is when they are removed from the computer and connected to an alternate power supply via usb the tx led is not blinking. Reconnect to computer and tx led still not blinking until connection is established to arduino IDE. I am using the Sparkfun client and server examples. Yes this does not make sense and I have loaded a fresh sketch and reflashed a number of times. I am happy to make a demonstration video. I will order two new boards and see what they do. With a client and server each on its own computer these radios function normally.
These units (I need 20) will be mounted on top of center pivot irrigation systems, probably not the best place for a computer .
can you share the exact sketch you use ?
Here is the tx sketch. It is taken from Sparkfun Pro RF guide under point to point examples (client),which I reanamed “Samd21_node”.
/*Samd21 Node (Transmit)
Both the TX and RX ProRF boards will need a wire antenna. We recommend a 3" piece of wire.
This example is a modified version of the example provided by the Radio Head
Library which can be found here:
www.github.com/PaulStoffregen/RadioHeadd
*/
#include <SPI.h>
//Radio Head Library:
#include <RH_RF95.h>
// We need to provide the RFM95 module's chip select and interrupt pins to the
// rf95 instance below.On the SparkFun ProRF those pins are 12 and 6 respectively.
RH_RF95 rf95(12, 6);
int LED = 13; //Status LED is on pin 13
int packetCounter = 0; //Counts the number of packets sent
long timeSinceLastPacket = 0; //Tracks the time stamp of last packet received
// The broadcast frequency is set to 921.2, but the SADM21 ProRf operates
// anywhere in the range of 902-928MHz in the Americas.
// Europe operates in the frequencies 863-870, center frequency at 868MHz.
// This works but it is unknown how well the radio configures to this frequency:
//float frequency = 864.1;
float frequency = 915; //Broadcast frequency
void setup()
{
pinMode(LED, OUTPUT);
SerialUSB.begin(9600);
// It may be difficult to read serial messages on startup. The following line
// will wait for serial to be ready before continuing. Comment out if not needed.
while(!SerialUSB);
SerialUSB.println("RFM Client!");
//Initialize the Radio.
if (rf95.init() == false){
SerialUSB.println("Radio Init Failed - Freezing");
while (1);
}
else{
//An LED inidicator to let us know radio initialization has completed.
SerialUSB.println("Transmitter up!");
digitalWrite(LED, HIGH);
delay(500);
digitalWrite(LED, LOW);
delay(500);
}
// Set frequency
rf95.setFrequency(frequency);
// The default transmitter power is 13dBm, using PA_BOOST.
// If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
// you can set transmitter powers from 5 to 23 dBm:
// Transmitter power can range from 14-20dbm.
rf95.setTxPower(14, false);
}
void loop()
{
SerialUSB.println("Sending message");
//Send a message to the other radio
uint8_t toSend[] = "Hi there!";
//sprintf(toSend, "Hi, my counter is: %d", packetCounter++);
rf95.send(toSend, sizeof(toSend));
rf95.waitPacketSent();
// Now wait for a reply
byte buf[RH_RF95_MAX_MESSAGE_LEN];
byte len = sizeof(buf);
if (rf95.waitAvailableTimeout(2000)) {
// Should be a reply message for us now
if (rf95.recv(buf, &len)) {
SerialUSB.print("Got reply: ");
SerialUSB.println((char*)buf);
//SerialUSB.print(" RSSI: ");
//SerialUSB.print(rf95.lastRssi(), DEC);
}
else {
SerialUSB.println("Receive failed");
}
}
else {
SerialUSB.println("No reply, is the receiver running?");
}
delay(500);
}
if you do NOT connect SerialUSB, don’t use include it. Try using the following code
/*Samd21 Node (Transmit)
Both the TX and RX ProRF boards will need a wire antenna. We recommend a 3" piece of wire.
This example is a modified version of the example provided by the Radio Head
Library which can be found here:
www.github.com/PaulStoffregen/RadioHeadd
*/
#include <SPI.h>
//Radio Head Library:
#include <RH_RF95.h>
// We need to provide the RFM95 module's chip select and interrupt pins to the
// rf95 instance below.On the SparkFun ProRF those pins are 12 and 6 respectively.
RH_RF95 rf95(12, 6);
int LED = 13; //Status LED is on pin 13
int packetCounter = 0; //Counts the number of packets sent
long timeSinceLastPacket = 0; //Tracks the time stamp of last packet received
// The broadcast frequency is set to 921.2, but the SADM21 ProRf operates
// anywhere in the range of 902-928MHz in the Americas.
// Europe operates in the frequencies 863-870, center frequency at 868MHz.
// This works but it is unknown how well the radio configures to this frequency:
//float frequency = 864.1;
float frequency = 915; //Broadcast frequency
// if connected to computer, define WITHUSB, else comment out
//#define WITHUSB
void setup()
{
pinMode(LED, OUTPUT);
#ifdef WITHUSB
SerialUSB.begin(9600);
// It may be difficult to read serial messages on startup. The following line
// will wait for serial to be ready before continuing. Comment out if not needed.
while(!SerialUSB);
SerialUSB.println("RFM Client!");
#endif
//Initialize the Radio.
if (rf95.init() == false){
#ifdef WITHUSB
SerialUSB.println("Radio Init Failed - Freezing");
#endif
while (1);
}
else{
//An LED inidicator to let us know radio initialization has completed.
#ifdef WITHUSB
SerialUSB.println("Transmitter up!");
#endif
digitalWrite(LED, HIGH);
delay(500);
digitalWrite(LED, LOW);
delay(500);
}
// Set frequency
rf95.setFrequency(frequency);
// The default transmitter power is 13dBm, using PA_BOOST.
// If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
// you can set transmitter powers from 5 to 23 dBm:
// Transmitter power can range from 14-20dbm.
rf95.setTxPower(14, false);
}
void loop()
{
#ifdef WITHUSB
SerialUSB.println("Sending message");
#endif
//Send a message to the other radio
uint8_t toSend[] = "Hi there!";
//sprintf(toSend, "Hi, my counter is: %d", packetCounter++);
rf95.send(toSend, sizeof(toSend));
rf95.waitPacketSent();
// Now wait for a reply
byte buf[RH_RF95_MAX_MESSAGE_LEN];
byte len = sizeof(buf);
if (rf95.waitAvailableTimeout(2000)) {
// Should be a reply message for us now
if (rf95.recv(buf, &len)) {
#ifdef WITHUSB
SerialUSB.print("Got reply: ");
SerialUSB.println((char*)buf);
//SerialUSB.print(" RSSI: ");
//SerialUSB.print(rf95.lastRssi(), DEC);
#endif
}
else {
#ifdef WITHUSB
SerialUSB.println("Receive failed");
#endif
}
}
else {
#ifdef WITHUSB
SerialUSB.println("No reply, is the receiver running?");
#endif
}
delay(500);
}
Hi, flashed your sketch, did not transmit on computer, did not transmit off computer.
Thanks. I think the issue is related to the usage of SerialUSB in your sketch AND in the library.
In the sketch setup, with 'while(!SerialUSB); ’ it waits for the USB to be available. But when you do not connect to a PC it waits forever. Hence I included the “ifdef” to NOT expect a SerialUSB and remove all the print-statements. However quickly looking at the Radio head library, I see that it can also send a message to Serial. If that serial is not initialized it will ‘hang’ as well.
Try in your original sketch to replace ‘while(!SerialUSB);’ with a delay(2000); You might still miss the first println statement(s), when connected to a PC but maybe it works.
Else try to add to a standard BLINK example some SerialUSB code and see whether it blink when connected or not connected to a PC.
replace ‘while(!SerialUSB);’ with a delay(2000); -working connected, not working off comp
blink with usb print - working connected, not working off comp
plain blink - working on and off comp
So I have a glaring question, does your board work? What is different about my setup?(my library is R.H. ver 1.89)
I used to have a SAM21D dev breakout board, but I damaged it a couple of months ago with a project and still need to order a replacement. I have tried my SAM51DThing Plus and MM but both are using Serial and not SerialUSB. Both of them continue to work whether or not connected to the PC and power is provided with a battery. Maybe others can try…
Thanks for your help Paul.
I have just ordered the replacement. Expect it to arrive before the weekend and will try it if others have not tried it before…
Hello, well I have got this thing working. I put a blinky function in the loop to see if by chance the sketch ever made it to that point and it did. This means the tx might very well be working and it is just the tx led that is not working. I incorrectly assumed that with no tx led that the tx was not working (the tx led worked on the computer). The tx radio is now functioning without being tethered to the computer. I don’t really care that the tx led works or not, but the led in the loop now serves as a tx led. Paul was right about the serial stuff, that had to be taken out as well. Now for some range testing.