LowPowerLab / RFM69

RFM69 library for RFM69W, RFM69HW, RFM69CW, RFM69HCW (semtech SX1231, SX1231H)
GNU General Public License v3.0
782 stars 379 forks source link

Trasmission time #89

Closed Slartitorto closed 6 years ago

Slartitorto commented 6 years ago

Hi, thank very much for you great job, this library is very useful. I figure out the transmission time is about 1 sec. but i think that time seems too much. Maybe I've wrong in my sketch ? The receiver see the packet as soon the led in the transmitter node became on, so there is time not useful on the transmitter maybe awaiting the and of something or some timeout ? Thanks in advance.

#include <LowPower.h>
#include <SPI.h>
#include <RFM69.h>

#define ledPin 3

#define NETWORKID     0   // Must be the same for all nodes
#define MYNODEID      2   // Trasmitter node ID
#define TONODEID      1   // Destination node ID
#define FREQUENCY   RF69_433MHZ

RFM69 radio;

// -------------------------

void setup() {
  pinMode(ledPin, OUTPUT);

  Serial.begin(57600);

  radio.initialize(FREQUENCY, MYNODEID, NETWORKID);
  radio.setHighPower();

}

// -------------------------

void loop() {
   delay(10);

   char buff[] = "123 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   byte buffLen=strlen(buff);

   long start_timer=millis();

   digitalWrite(ledPin, HIGH);
   Serial.println("Sending buffer ...");

   radio.send(TONODEID, buff, buffLen);

   digitalWrite(ledPin, LOW);
   Serial.print("Trasmission time = "); Serial.println((millis() - start_timer));
   Serial.println();

   delay(200);
}

The output is:

Sending buffer ...
Trasmission time = 1014

Sending buffer ...
Trasmission time = 1012

Sending buffer ...
Trasmission time = 1014

Sending buffer ...
Trasmission time = 1013

Sending buffer ...
Trasmission time = 1012

Sending buffer ...
Trasmission time = 1014

Sending buffer ...
Trasmission time = 1013

Sending buffer ...
Trasmission time = 1012

Sending buffer ...
Trasmission time = 1014

Sending buffer ...
JohnOH commented 6 years ago

You appear to be including the time for the Serial.print to complete in your calculation.

Slartitorto commented 6 years ago

The Serial.print take some microsec to be execute. However, I've take your suggest, trying this sketch, but the result doesn't change.

#include <LowPower.h>
#include <SPI.h>
#include <RFM69.h>

#define ledPin 3

#define NETWORKID     0   // Must be the same for all nodes
#define MYNODEID      2   // Trasmitter node ID
#define TONODEID      1   // Destination node ID
#define FREQUENCY   RF69_433MHZ

RFM69 radio;

// -------------------------

void setup() {
  pinMode(ledPin, OUTPUT);

  Serial.begin(57600);

  radio.initialize(FREQUENCY, MYNODEID, NETWORKID);
  radio.setHighPower();

}

// -------------------------

void loop() {
   delay(10);

   char buff[] = "123 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   byte buffLen=strlen(buff);

   Serial.println("Sending buffer ...");
   digitalWrite(ledPin, HIGH);

   long start_timer=millis();
   radio.send(TONODEID, buff, buffLen);
   long end_timer=millis();

   digitalWrite(ledPin, LOW);
   Serial.print("Trasmission time = ");
   Serial.println(end_timer - start_timer);
   Serial.println();

   delay(200);
}
JohnOH commented 6 years ago

I'm sorry it didn't help.

Slartitorto commented 6 years ago

Solved: wiring problem. My atmega328 had a cold welding on PD2.