Tu izgleda omane na senderu, ne posalje poruku! Probaj asinhrono:
Dodao sam deo koda da ti kaze dali je uspesno poslao poruku preko lore
PHP Code:
#include <LoRa.h>
const int buttonPin1 = 7;
const int buttonPin2 = 6;
int buttonState1 = 0;
int lastButtonState1 = 0;
int buttonState2 = 0;
int lastButtonState2 = 0;
int err;
void setup() {
Serial.begin(9600);
while (!Serial);
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
Serial.println("LoRa Sender");
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
delay(500);
}
void loop() {
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
if (buttonState1 == LOW ) {
Serial.println("Taster 1 pritisnut, šaljem: LED1_ON");
LoRa.beginPacket();
LoRa.print("LED1_ON");
err = LoRa.endPacket(true);
if (err > 0) {
Serial.println("- Message sent correctly!");
} else {
Serial.println("- Error sending message :(");
Serial.println("(- You may send a limited amount of messages per minute, depending on the signal strength");
Serial.println("- It may vary from one message every couple of seconds to one message every minute)");
}
delay(1000);
}
if (buttonState2 == LOW ) {
Serial.println("Taster 2 pritisnut, šaljem: LED1_OFF");
LoRa.beginPacket();
LoRa.print("LED1_OFF");
err = LoRa.endPacket(true);
if (err > 0) {
Serial.println("- Message sent correctly!");
} else {
Serial.println("- Error sending message :(");
Serial.println("(- You may send a limited amount of messages per minute, depending on the signal strength");
Serial.println("- It may vary from one message every couple of seconds to one message every minute)");
}
delay(1000);
}
lastButtonState1 = buttonState1;
lastButtonState2 = buttonState2;
delay(1000);
}
Dodao sam deo koda da ti kaze dali je uspesno poslao poruku preko lore