Code Monkey home page Code Monkey logo

lora's Introduction

Hi! 👋🏻

Welcome to my GitHub Home Page!

I'm Salman, a hardware and electronics engineer at Bayan, and I hold a degree in electrical engineering from Amirkabir University of Technology.

I specialize in high-speed PCB design, embedded systems, control systems and electronics. Here you'll find my work, projects, and open-source contributions.

Feel free to contact me for questions, collaborations, or exciting opportunities. Let's connect, create, and innovate together!

E-Mail Telegram LinkedIn Twitter

General Stats

 

Some of My Notable Repositories

⭐ Most Starred

⚡ STM32 (HAL based) Libraries

⚡ Arduino Libraries

🔧 PCB Design Assets

📖 Academic Works

👨🏻‍💻 Personal Projects

👨🏻‍🏫 Code of The Courses That I Presented

Star History

lora's People

Contributors

iotthinks avatar smotlaq avatar texx00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

lora's Issues

Support for MSPM0 Microcontroller

I would like to implement this library on the MSPM0 microcontroller using CCStudio. Could you please provide guidance or support on how to adapt this library for use with the MSPM0 board? Specifically, I need help with the following:

Platform Definitions: How can I define the MSPM0 platform correctly in the library?
Integration Steps: Are there any specific steps or modifications needed to integrate the library with CCStudio and the MSPM0 microcontroller?
Example Code: If possible, could you provide an example code snippet demonstrating how to initialize and use the library with the MSPM0 microcontroller?

Transmitting right after reading data

Hi, I wanted to respond to the data I just received.
I'm using external interrupt from DIO0 and there I'm receiving the data but when I'm trying to transmit data right after that it somehow breaks. It doesn't even go into exti callback anymore. Is it somthing you tried yet?
Here is my callback

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
	HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,GPIO_PIN_RESET);
	if(GPIO_Pin == GPIO_PIN_14)
	{
		LoRa_receive(&myLoRa, read_data, 128);
		if(strstr(read_data,myIDcode))
		{
			sprintf(send_data, "received packet no.: %d",read_data[2]);
			//LoRa_transmit(&myLoRa, send_data, 128, 500);		
		}
	}
	HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,GPIO_PIN_SET);
}

Failed to receive LoRa packets with SF 12

Hi all,
I have tested to send packet from Sandeep's Arduino LoRa (ESP32) to SMotlag's LoRa (STM32).
When SF = 7, STM32 can receive packets from ESP32.
However, when SF=12, then STM32 does not receive packets from ESP32.

Compare the set Spreading Factor function, I guess this library misses the part to set LDO (Low data optimization).
This library
https://github.com/SMotlaq/LoRa/blob/master/LoRa/LoRa.c#L184

Sandeep's library
https://github.com/sandeepmistry/arduino-LoRa/blob/master/src/LoRa.cpp#L573

RadioLib's library
https://github.com/jgromes/RadioLib/blob/master/src/modules/SX127x/SX1278.cpp#L188

Have you tested the receiving with SF12?
Thanks a lot.

DIO request

Does the library now support receive on interrupt now?

Thank you for your great work

LoRa cannot init

Hi There,

I am trying to use your LoRa library for NUCLEO-G431KB and I always got the ERROR 404.
I checked all the wiring which are correct.

Any suggestion?

Thanks in advance

Compatibility with 915MHz SX1276

I'm using the library in a project with a 915MHz SX1276. The initialization of the module went smoothly and I'm already receiving a message saying that the LoRa module is ready for use.
However, I'm having problems transmitting. The transmitter manages to send the signal via the LoRa_transmit command, and gets a return = 1. But the receiver doesn't receive the packet.

Why is this happening? I've configured it according to the Readme example and I've also used HAL_GPIO_EXTI_Callback in case the interrupt on the DIO pin happens.

Captursdfggsdfdfgsar

RX Code:

void setup(){
	DEBUG_PRINT("Starting...\r\n");

	  // SX1276 compatible module connected to SPI1, NSS pin connected to GPIO with label LORA_NSS
	myLoRa = newLoRa();

	myLoRa.CS_port         = NSS_GPIO_Port;
	myLoRa.CS_pin          = NSS_Pin;
	myLoRa.reset_port      = LORA_RST_GPIO_Port;
	myLoRa.reset_pin       = LORA_RST_Pin;
	myLoRa.DIO0_port       = DIO_GPIO_Port;
	myLoRa.DIO0_pin        = DIO_Pin;
	myLoRa.hSPIx           = &hspi1;

	myLoRa.frequency             = 915;             // default = 433 MHz
	myLoRa.spredingFactor        = SF_7;            // default = SF_7
	myLoRa.bandWidth             = BW_250KHz;       // default = BW_125KHz
	myLoRa.crcRate               = CR_4_8;          // default = CR_4_5
	myLoRa.power                 = POWER_17db;      // default = 20db
	myLoRa.overCurrentProtection = 130;             // default = 100 mA
	myLoRa.preamble              = 10;              // default = 8;

	if(LoRa_init(&myLoRa) == LORA_OK){
		DEBUG_PRINT("LoRa Ready\r\n");
	}else DEBUG_PRINT("Error in LoRa connection\r\n");

	LoRa_startReceiving(&myLoRa);

      HAL_GPIO_WritePin(GPIOB, DEBUG_LED_Pin, GPIO_PIN_SET);
	  I2C_Scan();
	  HAL_GPIO_WritePin(GPIOB, K_Pin, GPIO_PIN_RESET);
	  HAL_Delay(100);
	  HAL_GPIO_WritePin(GPIOB, K_Pin, GPIO_PIN_SET);
	  HAL_Delay(1000);
	  HAL_GPIO_WritePin(GPIOB, K_Pin, GPIO_PIN_RESET);

	  //HAL_Delay(10000);
	  DEBUG_PRINT("Started!\r\n");
}

void loop(){
	char msg[64];
	uint8_t received_data[12];
	uint8_t packet_size = 0;
	packet_size = LoRa_receive(&myLoRa, received_data, 12);

	snprintf(msg, sizeof(msg), "Res %s\r\n", received_data);
	DEBUG_PRINT(msg);
}

void ShowSerialData(void)
{
  uint8_t data;
  while (__HAL_UART_GET_FLAG(&huart2, UART_FLAG_RXNE) != RESET) // Verifica se há dados disponíveis no UART3
  {
    HAL_UART_Receive(&huart2, &data, 1, HAL_MAX_DELAY); // Lê um byte do UART3
    HAL_UART_Transmit(&huart1, &data, 1, HAL_MAX_DELAY); // Envia o byte lido para o UART1
  }
  HAL_Delay(1000); // Espera por 1 segundo
}

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){
	if(GPIO_Pin == DIO_Pin){
		LoRa_receive(&myLoRa, rxBuffer, 120);
		DEBUG_PRINT("RECIEVED!\r\n");
	}
	DEBUG_PRINT("Call!\r\n");
}

TX Code:

void setup() {
	DEBUG_PRINT("Setup...\r\n");
	I2C_Scan();
	DEBUG_PRINT("\r\n");

	myLoRa = newLoRa();

	myLoRa.CS_port         = NSS_GPIO_Port;
	myLoRa.CS_pin          = NSS_Pin;
	myLoRa.reset_port      = LoRa_RST_GPIO_Port;
	myLoRa.reset_pin       = LoRa_RST_Pin;
	myLoRa.DIO0_port       = DIO_GPIO_Port;
	myLoRa.DIO0_pin        = DIO_Pin;
	myLoRa.hSPIx           = &hspi1;

	myLoRa.frequency             = 915;             // default = 433 MHz
	myLoRa.spredingFactor        = SF_7;            // default = SF_7
	myLoRa.bandWidth             = BW_250KHz;       // default = BW_125KHz
	myLoRa.crcRate               = CR_4_8;          // default = CR_4_5
	myLoRa.power                 = POWER_17db;      // default = 20db
	myLoRa.overCurrentProtection = 130;             // default = 100 mA
	myLoRa.preamble              = 10;              // default = 8;

	if(LoRa_init(&myLoRa) == LORA_OK){
		DEBUG_PRINT("LoRa Ready\r\n");
	}else DEBUG_PRINT("Error in LoRa connection\r\n");

	if (KX122_Init(&hspi2) != HAL_ERROR)
		DEBUG_PRINT("KX122 Ready\r\n");
	else
		DEBUG_PRINT("Error in KX122 connection\r\n");

	if (MCP9808_Init(&hi2c1) != HAL_ERROR)
		DEBUG_PRINT("MCP9808 Ready\r\n");
	else
		DEBUG_PRINT("Error in MCP9808 connection\r\n");

	if (MAX17048_Init(&hi2c1) != HAL_ERROR)
		DEBUG_PRINT("MAX17048 Ready\r\n");
	else
		DEBUG_PRINT("Error in MAX17048 connection\r\n");

	if (FRAM_Init(&hi2c1) != HAL_ERROR)
		DEBUG_PRINT("FRAM Ready\r\n");
	else
		DEBUG_PRINT("Error in FRAM connection\r\n");

	DEBUG_PRINT("Ready!\r\n");

	if(KX122_CheckCommunication(&hi2c1) != HAL_ERROR)
		DEBUG_PRINT("WHO I AM KX122 Ready\r\n");

	FRAM_InitMetadata(&metadata);

	package_factor = 3
			* ceil((float) (SAMPLES) / (float) TRANSMISSION_DATA_PACKAGE);
	data_sender_period = round(
			1000 * ((float) DATA_TRANSMISSION_PERIOD / (float) package_factor));

	acc_sample_factor = floor((float) ACC_DATA_RATE / (float) SAMPLES);
	sampling_period_us = round(1000000 * (1.0 / (float) SAMPLES)); //488.28
	//sampling_period_us = round(1000000 * (1.0 / (float) ACC_DATA_RATE));
	//sampling_period_us *= acc_sample_factor;

	DEBUG_PRINT("package_factor:\r\n");
	printFloat(package_factor);
	DEBUG_PRINT("data_sender_period:\r\n");
	printFloat(data_sender_period);
	DEBUG_PRINT("sampling_period_us:\r\n");
	printFloat(sampling_period_us);
	DEBUG_PRINT("acc_sample_factor:\r\n");
	printFloat(acc_sample_factor);
	DEBUG_PRINT("\r\n");

	sizeInBytes = FRAM_MEMORY_SIZE;
	writeVibrationInformation();
}

void loop() {
	//HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_SET);

	//HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET);

	char*  send_data;
	send_data = "Hello world!";
	if(LoRa_transmit(&myLoRa, (uint8_t*)send_data, 12, 100) == 1){
		DEBUG_PRINT("Success!\r\n");
	}else DEBUG_PRINT("Fail!\r\n");
	DEBUG_PRINT("Sanded!\r\n");
	HAL_Delay(5000);writeVibrationInformation();
}

Captursdfggsdfdsfgdfgsar

Constructor:

int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_I2C1_Init();
  MX_SPI1_Init();
  MX_USART1_UART_Init();
  MX_USART2_UART_Init();
  /* USER CODE BEGIN 2 */
  setup();
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
	  loop();
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

Testing RA-02 SX1278 module with STM32L031

I am trying to get this example project working on the STM32L031 development board:
https://www.st.com/en/evaluation-tools/nucleo-l031k6.html

I cannot fully understand how am I intended to test this. I have 2 identical STM32L031 devices and connected each STM32L031 to the RA-02 SX1278 lora module.

One is running LoRa transmit code:

  while (1)
  {
	  char*  send_data;
	  send_data = "Hello!";
	  if(LoRa_transmit(&myLoRa, (uint8_t*)send_data, 6, 100) == 1){
		  printf("Transmit ok \n");
	  }
		else{
			printf("Transmit failed \n");
		}
		HAL_Delay(1500);
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }

The other is running receive code:

  LoRa_startReceiving(&myLoRa);
  uint8_t received_data[10];
  uint8_t packet_size = 0;
  while(1){
    packet_size = LoRa_receive(&myLoRa, received_data, 10);
    if(packet_size > 0 ){
    	printf("received data = %s \n",received_data);
    }
    HAL_Delay(500);
  }

The logs side by side:
image

Is that the expected behaviours of this library?
How to ensure I receive the correct data?
Is it normal that it fails to transmit every now and then?

Does the library work with SX1276 chip?

Am using an lilygo t- beam board to transmit data to stm32f103c8 interfaced with rfm95 lorawan module(sx1276 chip) and it does not work while following keenly your tutorial video and using DIO0 and EXTI Callback function.
When i use the stm32 and rfm95 module for transmit, with the esp32 as receiver, it works well.
For the esp32 am using the Arduino LORA library by Sandeep Mistry.

STM32F407G-DISC1

Hello,

I have STM32F407G-DISC1 board and LoRa E32 433T20D. I want to communicate LoRa with F407. Is this library work with F407. Has anyone tried?

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.