Comments (15)
I will run your code on my hardware as soon as possible and tell you the result.
Sounds good. Please let me know if you are able to reproduce the issue at all. :)
from lora.
I will try to receive using EXT interrupt and post back the results
from lora.
Hello
Using char*
without memory allocation is not recommended.
Please use char*
as array and use sprintf
and snprintf
functions like this:
char send_data[20];
snprintf(send_data, 6, "Hello!");
LoRa_transmit(&myLoRa, (uint8_t*)send_data, 6, 100);
I think this should solve your problem.
from lora.
@SMotlaq I have updated the transmitter code as you have suggested but im afraid not much changed. I believe issue lies in the receiver code. Something is not right.
The receiver is constantly printing garbage even when I dont have transmitter powered.
from lora.
Please send me your project and codes
[email protected]
from lora.
@SMotlaq
I can share my project through here. You access it via my github:
https://github.com/krupis/Lora-STM32
All you need to do is to update :
// 0 - receiver mode
// 1 - transmitter mode
#define MODA_LORA 0
depending on which mode you want to program the device
Additionally, I have put a scope on the DIO0 pin on the receiver device. It is never triggered but on the console it prints the received garbage data. Does your receiver code utilize DIO0 rx interrupt?. I was under the impression that data received should only be printed when the RX interrupt is triggered.
On my STM32, the DIO0 is configured as input pin and is pulled down. (You can check my CubeMX configuration)
from lora.
Have you checked what value LoRa_init() function returns?
from lora.
Have you checked what value LoRa_init() function returns?
Yes. I have added the following to my code:
LoRa_reset(&myLoRa);
uint16_t lora_ret = LoRa_init(&myLoRa);
printf("Lora return value = %u \n",lora_ret);
and the result:
Lora return value = 200
Starting RX mode
from lora.
If it would be helpful, I can connect logic analyzer to SPI pins and check what happens
from lora.
1- Please reset the buffer first, using memset
to check that we get any packet or not:
uint8_t received_data[10];
memset(received_data, NULL, 10);
2- Also please send a variable data from sender. For example "Hello 1", "Hello 2", ...
3- Print the exact values of the received_data
. Not the character or ASCII.
from lora.
@SMotlaq
I have modified my receiver code as following:
if(MODA_LORA == 0){
printf("Starting RX mode \n");
LoRa_startReceiving(&myLoRa);
uint8_t received_data[10];
memset(received_data, NULL, 10);
uint8_t packet_size = 0;
while(1){
packet_size = LoRa_receive(&myLoRa, received_data, 10);
if(packet_size > 0 ){
for(int i = 0; i<packet_size;i++){
printf("received data[i] = %u \n",i,received_data[i]);
}
}
memset(received_data, NULL, 10); // Clear the received data buffer after it is received
packet_size = 0; // set packet size to 0 after receiving data.
HAL_Delay(500);
}
}
and my transmitter code as following:
else if(MODA_LORA == 1){
printf("Starting TX mode \n");
while (1)
{
char send_data[20];
for (int i = 0; i < 100; i++)
{
snprintf(send_data, 20, "test%d", i); // puts string into buffer
printf("String to send = %s and length =%u \n", send_data,strlen(send_data)); // outputs so you can see it
if(LoRa_transmit(&myLoRa, (uint8_t*)send_data, 6, 100) == 1){
printf("Transmitting %s successful \n",send_data);
}
else{
printf("Transmit failed \n");
}
HAL_Delay(2000);
}
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
}
As you can see lora receiver receives strange data. This data is being does not have anything to do with my lora transmitter since it will keep receiving:
received data[i] = 0
received data[i] = 1
received data[i] = 2
received data[i] = 3
received data[i] = 4
received data[i] = 5
received data[i] = 6
received data[i] = 7
received data[i] = 8
received data[i] = 9
Even when my transmsitter is powered OFF.
I have updated my git repository for this project if you want to have a look at the latest code.
from lora.
I will run your code on my hardware as soon as possible and tell you the result.
from lora.
@SMotlaq
I have recently watched your Youtube video regarding this library.
I have noticed a few comments:
Perhaps my issue is related to this?
In my case, NVIC settings are as following
from lora.
@SMotlaq
Additionally, I do not fully understand whether DIO0 signal is set high or low when message is received? Could you confirm whether it is active LOW or active HIGH? I havent been able to find this information
from lora.
When the module receives a valid LoRa packet, it changes the DIO0 from LOW to HIGH (I don't know how long this pin stays HIGH). You can enable an EXTI in the rising edge mode to detect arriving packets.
You didn't use interrupts in your code, so I don't think that is the reason of your problem. But you can test it. The polling mode is not recommended. It's better than using interrupts.
from lora.
Related Issues (10)
- Missing CRC activation/deactivation option HOT 1
- Failed to receive LoRa packets with SF 12 HOT 9
- Support for MSPM0 Microcontroller HOT 1
- DIO request HOT 1
- Hello!Can it be implemented in FreeRTOS? HOT 15
- Transmitting right after reading data HOT 5
- STM32F407G-DISC1 HOT 3
- LoRa cannot init HOT 2
- what is LEVEL1_Pin LEVEL2_Pin LEVEL3_Pin LEVEL4_Pin HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lora.