sandeepmistry / arduino-LoRa

An Arduino library for sending and receiving data using LoRa radios.
MIT License
1.61k stars 621 forks source link

My receiver stuck at ''LoRa Initializing OK'' #587

Open Snapp96 opened 1 year ago

Snapp96 commented 1 year ago

Hi, I have a problem to produced output. Code for receiver stuck at "LoRa Initializing Ok" receiver side I am using ESP32 Doit Devkit v1. Below is my code for receiving

`#include

include

//define the pins used by the transceiver module

define ss 5

define rst 14

define dio0 2

void setup() { //initialize Serial Monitor Serial.begin(115200); while (!Serial) ; Serial.println("LoRa Receiver");

//setup LoRa transceiver module LoRa.setPins(ss, rst, dio0);

if (!LoRa.begin(433E6)) { Serial.println("Starting LoRa failed!"); delay(100); while (1) ; }

LoRa.setSyncWord(0xF3); Serial.println("LoRa Initializing OK!"); }

void loop() { //Serial.print("Masuk Loop '"); //String LoRaData; int packetSize = LoRa.parsePacket(); if (packetSize) { // received a packet Serial.println(""); Serial.println("..................................."); Serial.print("Received packet '");

// read packet
while (LoRa.available()) {
  char incoming = (char)LoRa.read();
  if (incoming == 'c')
 // LoRaData = LoRa.readString();
  //Serial.print(LoRaData);
  {
    Serial.print("Error");
  }
  else
  {
    Serial.print(incoming);
  }
}
print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());

} }`

This is for sender

`#include

include

include

define DHT22_PIN A0 // DHT 22 (AM2302) - pin used for DHT22

define ss 10

define rst 9

define dio0 2

int counter = 0;

dht DHT;

float humidity; //Stores humidity value float temperature; //Stores temperature value

int measurePin = A5; int ledPower = 4;

float voMeasured = 0; float calcVoltage = 0; float dustDensity = 0;

// Set the typical output voltage in Volts when there is zero dust. float VNoDust = 0.6;

// Use the typical sensitivity in units of V per 100ug/m3. float K = 0.5;

void setup() { Serial.begin(9600);

while (!Serial); Serial.println("LoRa Sender");

LoRa.setPins(ss, rst, dio0); // If the initialization of the LoRa module fails, the code is suspended in a perpetual while loop if (!LoRa.begin(433E6)) { Serial.println("Starting LoRa failed!"); delay(100); while (1); }

// If successful, we set a unique communication key (Syncword) // We also set the power of the Lora radio to the maximum LoRa.setSyncWord(0xF3); LoRa.setTxPower(20); Serial.println("LoRa Initializing OK!"); delay(2000); }

void loop() {

//Read data from DHT22 and store it to variables humidity and temperature int chk = DHT.read22(DHT22_PIN); humidity = DHT.humidity; temperature = DHT.temperature;

// Turn on the dust sensor LED by setting digital pin LOW. digitalWrite(ledPower, LOW);

// Wait 0.28ms before taking a reading of the output voltage delayMicroseconds(280);

// Record the output voltage. This operation takes around 40 microseconds. voMeasured = analogRead(measurePin); delayMicroseconds(40);

// Turn the dust sensor LED off by setting digital pin HIGH. // LED should be pulsed on once every 10ms, so wait for the remainder of the 10ms cycle // 10000 - 280 - 40 = 9680 microseconds. digitalWrite(ledPower, HIGH); delayMicroseconds(9680);

calcVoltage = voMeasured (5.0 / 1024); //dustDensity = (calcVoltage-VNoDust)100/K; dustDensity = (calcVoltage*0.17)-0.1;

if (dustDensity < 0) { dustDensity = 0.00; }

// Print Voltage measured, Voltage Calculated, Dust Density, Humidity, Temperature Serial.print("Sending packet: ");

// send packet LoRa.beginPacket();

LoRa.print("Sending packet: "); LoRa.print(counter); LoRa.print(","); LoRa.print(voMeasured); LoRa.print(","); LoRa.print(calcVoltage); LoRa.print(","); LoRa.print(dustDensity); LoRa.print(","); LoRa.print(humidity); LoRa.print(","); LoRa.print(temperature);

Serial.print(counter); Serial.print(","); Serial.print(voMeasured); Serial.print(","); Serial.print(calcVoltage); Serial.print(","); Serial.print(dustDensity); Serial.print(","); Serial.print(humidity); Serial.print(","); Serial.println(temperature); Serial.print("");

counter++;

delay(1000); }`

Esp32_LoRa_bb Final Year Project_bb.pdf

IoTThinks commented 1 year ago

To test using the example code first.