CongducPham / LowCostLoRaGw

Low-cost LoRa IoT & gateway with SX12XX (SX1261/62/68; SX1272/76/77/78/79; SX1280/81), RaspberryPI and Arduino boards
694 stars 352 forks source link

Gateway not receiving Packets #207

Open aniket1002 opened 6 years ago

aniket1002 commented 6 years ago

Hello @CongducPham sir, I'm working on the Ping_pong code : `

include

// Include the SX1272

include "SX1272.h"

// IMPORTANT /////////////////////////////////////////////////////////////////////////////////////////////////////////// // please uncomment only 1 choice //

define ETSI_EUROPE_REGULATION

//#define FCC_US_REGULATION //#define SENEGAL_REGULATION ///////////////////////////////////////////////////////////////////////////////////////////////////////////

// IMPORTANT /////////////////////////////////////////////////////////////////////////////////////////////////////////// // // uncomment if your radio is an HopeRF RFM92W, HopeRF RFM95W, Modtronix inAir9B, NiceRF1276 // or you known from the circuit diagram that output use the PABOOST line instead of the RFO line

define PABOOST

///////////////////////////////////////////////////////////////////////////////////////////////////////////

// IMPORTANT /////////////////////////////////////////////////////////////////////////////////////////////////////////// // please uncomment only 1 choice

define BAND868

//#define BAND900 //#define BAND433 ///////////////////////////////////////////////////////////////////////////////////////////////////////////

ifdef ETSI_EUROPE_REGULATION

define MAX_DBM 14

elif defined SENEGAL_REGULATION

define MAX_DBM 10

elif defined FCC_US_REGULATION

define MAX_DBM 14

endif

ifdef BAND868

ifdef SENEGAL_REGULATION

const uint32_t DEFAULT_CHANNEL=CH_04_868;

else

const uint32_t DEFAULT_CHANNEL=CH_10_868;

endif

elif defined BAND900

const uint32_t DEFAULT_CHANNEL=CH_05_900;

elif defined BAND433

const uint32_t DEFAULT_CHANNEL=CH_00_433;

endif

/////////////////////////////////////////////////////////////////// // CHANGE HERE THE LORA MODE, NODE ADDRESS

define LORAMODE 1

define node_addr 8

//////////////////////////////////////////////////////////////////

// we wrapped Serial.println to support the Arduino Zero or M0

if defined SAMD21G18A && not defined ARDUINO_SAMD_FEATHER_M0

define PRINTLN SerialUSB.println("")

define PRINT_CSTSTR(fmt,param) SerialUSB.print(F(param))

define PRINT_STR(fmt,param) SerialUSB.print(param)

define PRINT_VALUE(fmt,param) SerialUSB.print(param)

define FLUSHOUTPUT SerialUSB.flush();

else

define PRINTLN Serial.println("")

define PRINT_CSTSTR(fmt,param) Serial.print(F(param))

define PRINT_STR(fmt,param) Serial.print(param)

define PRINT_VALUE(fmt,param) Serial.print(param)

define FLUSHOUTPUT Serial.flush();

endif

define DEFAULT_DEST_ADDR 1

uint8_t message[100];

int loraMode=LORAMODE;

void setup() { int e;

// Open serial communications and wait for port to open:

if defined SAMD21G18A && not defined ARDUINO_SAMD_FEATHER_M0

SerialUSB.begin(38400);

else

Serial.begin(38400);

endif

// Print a start message PRINT_CSTSTR("%s","Simple LoRa ping-pong with the gateway\n");

ifdef ARDUINO_AVR_PRO

PRINT_CSTSTR("%s","Arduino Pro Mini detected\n");

endif

ifdef ARDUINO_AVR_NANO

PRINT_CSTSTR("%s","Arduino Nano detected\n");

endif

ifdef ARDUINO_AVR_MINI

PRINT_CSTSTR("%s","Arduino MINI/Nexus detected\n");

endif

ifdef ARDUINO_AVR_MEGA2560

PRINT_CSTSTR("%s","Arduino Mega2560 detected\n");

endif

ifdef ARDUINO_SAM_DUE

PRINT_CSTSTR("%s","Arduino Due detected\n");

endif

ifdef MK66FX1M0

PRINT_CSTSTR("%s","Teensy36 MK66FX1M0 detected\n");

endif

ifdef MK64FX512

PRINT_CSTSTR("%s","Teensy35 MK64FX512 detected\n");

endif

ifdef MK20DX256

PRINT_CSTSTR("%s","Teensy31/32 MK20DX256 detected\n");

endif

ifdef MKL26Z64

PRINT_CSTSTR("%s","TeensyLC MKL26Z64 detected\n");

endif

if defined ARDUINO_SAMD_ZERO && not defined ARDUINO_SAMD_FEATHER_M0

PRINT_CSTSTR("%s","Arduino M0/Zero detected\n");

endif

ifdef ARDUINO_AVR_FEATHER32U4

PRINT_CSTSTR("%s","Adafruit Feather32U4 detected\n");

endif

ifdef ARDUINO_SAMD_FEATHER_M0

PRINT_CSTSTR("%s","Adafruit FeatherM0 detected\n");

endif

// See http://www.nongnu.org/avr-libc/user-manual/using_tools.html // for the list of define from the AVR compiler

ifdef __AVR_ATmega328P__

PRINT_CSTSTR("%s","ATmega328P detected\n");

endif

ifdef __AVR_ATmega32U4__

PRINT_CSTSTR("%s","ATmega32U4 detected\n");

endif

ifdef __AVR_ATmega2560__

PRINT_CSTSTR("%s","ATmega2560 detected\n");

endif

ifdef SAMD21G18A

PRINT_CSTSTR("%s","SAMD21G18A ARM Cortex-M0+ detected\n");

endif

ifdef SAM3X8E

PRINT_CSTSTR("%s","SAM3X8E ARM Cortex-M3 detected\n");

endif

sx1272.setCSPin(5); // Power ON the module sx1272.ON();

// Set transmission mode and print the result e = sx1272.setMode(loraMode); PRINT_CSTSTR("%s","Setting Mode: state "); PRINT_VALUE("%d", e); PRINTLN;

// enable carrier sense sx1272._enableCarrierSense=true;

// Select frequency channel e = sx1272.setChannel(DEFAULT_CHANNEL); PRINT_CSTSTR("%s","Setting Channel: state "); PRINT_VALUE("%d", e); PRINTLN;

// Select amplifier line; PABOOST or RFO

ifdef PABOOST

sx1272._needPABOOST=true; // previous way for setting output power // powerLevel='x';

else

// previous way for setting output power // powerLevel='M';

endif

// previous way for setting output power // e = sx1272.setPower(powerLevel);

e = sx1272.setPowerDBM('x'); PRINT_CSTSTR("%s","Setting Power: state "); PRINT_VALUE("%d", e); PRINTLN;

// Set the node address and print the result e = sx1272.setNodeAddress(node_addr); PRINT_CSTSTR("%s","Setting node addr: state "); PRINT_VALUE("%d", e); PRINTLN;

// Print a success message PRINT_CSTSTR("%s","SX1272 successfully configured\n");

delay(500); }

void loop(void) { uint8_t r_size; int e;

sx1272.CarrierSense();

sx1272.setPacketType(PKT_TYPE_DATA);

r_size=sprintf((char*)message, "Ping"); sx1272.sendPacketTimeoutACK(1,"TC/18.56",8); while (1) {

  PRINT_CSTSTR("%s","Sending Ping");  
  PRINTLN;

  e = sx1272.sendPacketTimeoutACK(DEFAULT_DEST_ADDR, message, r_size);

  // this is the no-ack version
  // e = sx1272.sendPacketTimeout(DEFAULT_DEST_ADDR, message, r_size);

  PRINT_CSTSTR("%s","Packet sent, state ");
  PRINT_VALUE("%d", e);
  PRINTLN;

  if (e==0)
      PRINT_CSTSTR("%s","No Pong from gw!");

  if (e==0) {
      char message[20];
      sprintf(message,"SNR at gw=%d   ", sx1272._rcv_snr_in_ack);
      PRINT_CSTSTR("%s","Pong received from gateway!");
      PRINTLN;
      PRINT_STR("%s", message);      
  }      

  PRINTLN;

  delay(10000);    

}
} `

I'm getting this on my serial monitor: capture7 and my gateway displays: image

But the ping is not received at the gateway and the gateway does not acknowledge back to the transmitter although it displays sending ping at the serial monitor. I've configured the gateway parameters like bandwidth, mode, frequency are same at the end device and the gateway. And I keep getting loopback packets when I press reset button. How can I resolve the issue?

Looking forward to your response Regards

chijiao commented 5 years ago

try set delay(10000) to delay(5000); , i'm also same issue. change delay time, same ok! you can try