limiting unwanted radio signal on my lora receiver

Hi I am very new to programming but getting the hang of it , 12 moths ago i could barely get an arduino to even turn on

today i have setup up a lora on promini and it will send some text to my receiver also a promini

the receiver has a oled and an alarm fitted to it so when the signal comes from the TX it will display on screen the message and it will set off an alarm , i am doing all of this with example code , melded into my plan to use it , it all works fine , BUT , when there is no signal for a while the oled starts to accumulate random characters on the screen and will eventually fill the screen , when a signal comes through from my transmitter the screen returns to normal and displays the current message .

Also with some of the unwanted signals will sound the alarm . this is definitely not wanted.

So I want to capture some info from my transmissions by the receiver and compare it to a known number or code and the receiver can then reject the unwanted signals .

Can someone give me a hint on how to capture and the code eg 123 from my tx .

I can tell you the code comes through as individual letters and numbers with a comma inbetween and to read it i have to use char(lora.read) etc, what i am doing now is capturing the lora.read as an int
and then serial.print ((char) message) and this prints to the oled 1 character at a time .
So i am thinking i should be able to capture part of the message that is constant and compare it a saved ,message on the receiver. however i have been unable find how to do this in all of my searches .can someone point me in the right direction please . and thanks .

RonaldJKirby:
Can someone give me a hint on how to capture and the code eg 123 from my tx .

Make some changes to the code that you have not posted.

/* *******************************************
the current July sketch 31.07.19


*/
int FIRMWARE = 731;// 31 july 2019 WORKING OK
#include <SPI.h>
#include <LoRa.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
int message; // this it capture message from tx
int newMessage;
int lastmessage;
int prevmessage;
int capt ;
#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 -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

//#define NUMFLAKES 10 // Number of snowflakes in the animation example

#define LOGO_HEIGHT 16
#define LOGO_WIDTH 16
static const unsigned char PROGMEM logo_bmp[] =
{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000 };
int btnPin = A0;
int LedPin = 4;
int FetPin = 3;

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

pinMode (btnPin,INPUT);
pinMode (LedPin,OUTPUT);
pinMode (FetPin,OUTPUT);
digitalWrite (LedPin, LOW);

while (!Serial);

if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
// Show initial display buffer contents on the screen --
// the library initializes this with an Adafruit splash screen.
display.setTextSize(2); // Normal 1:1 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(0, 0); // Start at top-left corner
display.cp437(true); // Use full 256 char 'Code Page 437' font

delay(100);
// Clear the buffer
display.clearDisplay();
// Draw a single pixel in white
display.drawPixel(10, 10, WHITE);

// Show the display buffer on the screen. You MUST call display() after
// drawing commands to make them visible on screen!
display.display();
delay(10);

// display.display() is NOT necessary after every single drawing command,
// unless that's what you want...rather, you can batch up a bunch of
// drawing operations and then update the screen all at once by calling
// display.display(). These examples demonstrate both approaches...

// Invert and restore display, pausing in-between
// display.invertDisplay(true);
// delay(1000);
// display.invertDisplay(false);
// delay(1000);

// testanimate(logo_bmp, LOGO_WIDTH, LOGO_HEIGHT); // Animate bitmaps

Serial.println("LoRa Receiver");
display.setTextSize(2); // Normal 1:1 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(0, 0); // Start at top-left corner
display.cp437(true); // Use full 256 char 'Code Page 437' font
//ALARM TESTING
delay(100); // Pause for 1 seconds
display.print (" FIRMWARE No ");
display.println (FIRMWARE);
display.display();
delay(1000);
display.print (" LED TEST ");
display.display();
digitalWrite (LedPin,LOW);
delay (2000);

display.clearDisplay();
delay(500);
display.print ("SIREN TEST ");
display.display();

digitalWrite (FetPin,HIGH);
delay(3000);
digitalWrite (FetPin,LOW);
digitalWrite (LedPin,HIGH);
display.clearDisplay();

display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(0, 0); // Start at top-left corner
display.cp437(true); // Use full 256 char 'Code Page 437' font

display.println (" Listening");
display.display();
delay(500);
if (!LoRa.begin(923E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
}

void loop() {

digitalWrite (LedPin,HIGH);
delay(10);
digitalWrite (FetPin,LOW);
delay(10);
display.setCursor(0,00);
display.setTextColor(WHITE);
display.setTextSize(2);
// try to parse packet
display.clearDisplay();
delay(10);
int packetSize = LoRa.parsePacket();
if (packetSize) {

// read packet
while (LoRa.available()) {

newMessage =((char)LoRa.read());
// Serial.print(message);
capt = newMessage;
Serial.print("capt =");
Serial.print(capt);

digitalWrite (LedPin,LOW);
digitalWrite (FetPin,HIGH);
delay (10);
//changes it here reading the char of lora
// message =((char)LoRa.read());

delay(5);
display.print ((char)newMessage);
display.display();
delay(5);

message = newMessage;
if (newMessage >0){getlastmessage();}

newMessage = 0;

delay(5);

}

// print RSSI of packet
display.setCursor(0,55);// starts bottom left
display.setTextSize(1);
display.print(" SIGNAL ");
display.print(LoRa.packetRssi());
display.print(" db ");
display.display();
// delay(10);
display.clearDisplay();
delay(10);
// display.invertDisplay(true);
// delay(1000);
// display.invertDisplay(false);
delay(10);

}

}

void testdrawbitmap(void) {
display.clearDisplay();

display.drawBitmap(
(display.width() - LOGO_WIDTH ) / 2,
(display.height() - LOGO_HEIGHT) / 2,
logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);
display.display();
delay(5000);
}

void getlastmessage () {

prevmessage = message;
delay(5);
lastmessage = prevmessage ;

delay(5);
//Serial.print("prevmessage ");
// Serial.print((char)prevmessage);
//Serial.println("");
// delay(5);

Serial.print(" lastmessage ");
Serial.print((char)lastmessage);
Serial.println("");
delay(5);
//Serial.print("message ");
//Serial.print((char)message);
//Serial.println("");
//delay(5);

}

just pics of what i am getting

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

ops images.


Tom... :slight_smile:

Hi,

Also with some of the unwanted signals will sound the alarm . this is definitely not wanted.

How will unwanted signals trigger the alarm?
Where will the unwanted signals come from.

I hope you send a character or word from the Lora unit and only trigger the alarm if that character or word is received and decoded.
The only thing that would trigger your alarm is your Lora Tx.

Tom... :slight_smile:

Hi Tom,

the receiver is set to 923mhz but it has a wide range because of spread spectrum there is no mechanism to limit what it receives so like any radio it is open to interference
i have a spectrum analyser and if i set it to 25 mhz above and below there are signals all around the core frequency and sometime even on it and occasionally they are long enough to activate the the beeper .

so yes it gets through the levels are usually less then -110db but lora receivers are usually capable of -130db

i am thinking i should be able to capture the first 3 characters and use them to filter out unwanted signals

so my "capt" int does that but i just dont quite get how to get the first 3 chars and use them in a if statement

eg if (first three digits = saved code on Receiver ){ then do this }

else {}

ill also include oled screen jpg

I hope you send a character or word from the Lora unit and only trigger the alarm if that character or word is received and decoded.
The only thing that would trigger your alarm is your Lora Tx.

i think this is the question i'm asking ?

You dont say which library you are using (its helpful to say) but if you think 'interference' is the problem then you would reduce the chances of 'interference' causing false packets to be received by a factor of 65536 if you enabled CRC on packets.

Your code is good for a new-user, but I suspect you can find better ways to handle the data.

Make a more complex message than a single character - which includes the ‘sender address’, and possibly a check value.
Only decode those messages from senders you know.

The RadioHead libraries fully support ReliableDatagram messages which may be better suited to a security application.

hi i think i have a fix

by modifying this part of sketch

int packetSize = LoRa.parsePacket();
if (packetSize) {

to

int packetSize = LoRa.parsePacket();
if (packetSize >=27) {

this measures the size of packet my minimum packetsize is 27 with my full transmitter code

so i have done this and am now waiting for a fail , heres hoping

Well definitely better but still the bit of interference getting through. So limiting the size of the packet helped,
I have looked at crc and datagram , but i dont understand them at this stage . I dont want to make handshake between receiver and transmitter. So that is why i am looking at the packets themselves .