Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting lora failed #689

Open
Tad12923 opened this issue Apr 6, 2024 · 2 comments
Open

Starting lora failed #689

Tad12923 opened this issue Apr 6, 2024 · 2 comments

Comments

@Tad12923
Copy link

Tad12923 commented Apr 6, 2024

I am new to lora and arduino so I just tried out this code and schematic online but it keep saying starting lora failed
Here's the code

#include <SPI.h>
#include <LoRa.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <DHT.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET LED_BUILTIN // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define DHTPIN 0 //pin where the dht11 is connected
#define ss 15
#define rst 16
#define dio0 2
int counter = 0;

DHT dht(DHTPIN, DHT11);
void setup()
{
Serial.begin(115200);
dht.begin();

// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}

while (!Serial);
Serial.println("LoRa Sender");
LoRa.setPins(ss, rst, dio0);
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
delay(100);
while (1);
}

display.display();
delay(2);
display.clearDisplay();
}

void loop()
{
float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(h) || isnan(t))
{
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" degrees Celcius, Humidity: ");
Serial.println(h);
Serial.println();
Serial.print("Sending packet: ");
Serial.println(counter);

display.clearDisplay();
display.setTextSize(2); // Normal 1:1 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(0,0); // Start at top-left corner
display.print(F("Pkt No:"));
display.print(counter);

display.setCursor(0,20);
display.print("Tem:");
display.print(t);
display.print("C");

display.setCursor(0,40);
display.print("Hum:");
display.print(h);
display.print("%");
display.display();

// send packet
LoRa.beginPacket();
LoRa.print(F("Pkt No:"));
LoRa.println(counter);

LoRa.print("Temp: ");
LoRa.print(t);
LoRa.println("°C");

LoRa.print("Hum: ");
LoRa.print(h);
LoRa.print("%");
LoRa.println("");

LoRa.endPacket();

counter++;

delay(3000);
}
IMG_20240407_022118
I am using esp8266 node MCU v3 and lora-ra2

@CodingMommy
Copy link

Sounds silly but have you connected a 433mhz suitable antenna to the LoRa module?

@sercero
Copy link

sercero commented May 19, 2024

The antenna issue is important, without the antenna you won't be able to transmit.
But "lora failed" is not an antenna problem, rather something wrong with the module most likely the connection.

Are you powering the Ra-02 module from the NodeMCU?

You should use an external power supply because the module can draw 200mA of power.

Check the docs: https://docs.ai-thinker.com/en/lora/man

Another thing: if things are not working you should simplify your setup and just connect the NodeMCU to the Ra-02 module remove the display and DHT sensor for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants