433 is for Asia, Europe is 868 but was my mistake.
I think I solved the problem… I changed the value in config_LORA.h to 433e6 and now works properly.
If you add the bin the github here you go:https://github.com/htcheroportugal/lora433/blob/master/lora%20433mhz.bin
now missing connect reed switch and code, maybe some member for this community can help.
I flashed this code in Emitter Board:
#include <SPI.h>
#include <LoRa.h>
#include <Wire.h>
#include "SSD1306.h"
#include "images.h"
#define SCK 5 // GPIO5 -- SX1278's SCK
#define MISO 19 // GPIO19 -- SX1278's MISnO
#define MOSI 27 // GPIO27 -- SX1278's MOSI
#define SS 18 // GPIO18 -- SX1278's CS
#define RST 14 // GPIO14 -- SX1278's RESET
#define DI0 26 // GPIO26 -- SX1278's IRQ(Interrupt Request)
#define BAND 433E6
unsigned int counter = 0;
SSD1306 display(0x3c, 21, 22);
String rssi = "RSSI --";
String packSize = "--";
String packet ;
void setup() {
pinMode(16,OUTPUT);
pinMode(2,OUTPUT);
digitalWrite(16, LOW); // set GPIO16 low to reset OLED
delay(50);
digitalWrite(16, HIGH); // while OLED is running, must set GPIO16 in high
Serial.begin(115200);
while (!Serial);
Serial.println();
Serial.println("LoRa Sender Test");
SPI.begin(SCK,MISO,MOSI,SS);
LoRa.setPins(SS,RST,DI0);
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
//LoRa.onReceive(cbk);
// LoRa.receive();
Serial.println("init ok");
display.init();
display.flipScreenVertically();
display.setFont(ArialMT_Plain_10);
delay(1500);
}
void loop() {
display.clear();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.setFont(ArialMT_Plain_10);
display.drawString(0, 0, "Sending packet: ");
display.drawString(90, 0, String(counter));
Serial.println(String(counter));
display.display();
// send packet
LoRa.beginPacket();
LoRa.print("hello ");
LoRa.print(counter);
LoRa.endPacket();
counter++;
digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
I think the code for ReedSwitch is something like that:
const int reedPin = 2;
bool switchState = HIGH;
void setup()
{
Serial.begin(9600);
pinMode(reedPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
}
void loop()
{
switchState = digitalRead(reedPin);
if (switchState == LOW)
{
Serial.println("ON");
}
else
{
Serial.println("OFF");
}
But i dont know how can do it.