Giter VIP home page Giter VIP logo

sx127x's Introduction

PlatformIO Registry Component Registry Quality Gate Status main

About

Library to work with semtech sx127x chips.

Features

There are several similar libraries exist, but this one is much better:

  • LoRa, FSK and OOK modulations
  • Support for resume from deep sleep. Most of libraries re-init the chip upon the startup and erase everything that was received previously. This library provides granular initialization functions. See examples/receive_lora_deepsleep/main/main.c for more info.
  • Written in C. It is so much easier to integrate with another C project. But also possible to use from C++ project.
  • Doesn't have external dependencies. This library is based on C99 standard.
  • Can work with 2 or more modules connected to the same SPI bus.
  • No busy loops for handling RX and TX events. See examples on how to configure and handle interrupts.
  • Good documentation.
  • Can be used on ESP32 or RaspberryPI or any other linux with GPIO pins.
  • debug registers

This library supports all standard LoRa features:

  • RX/TX
  • CAD (Channel activity detection). Can be used to reduce power consumption in RX mode.
  • TX with +20dbm power
  • Explicit and implicit headers
  • Granular sx127x register configuration

And FSK/OOK features:

  • RX/TX
  • Short messages and extra long messages (up to 2047 bytes). For messages more than 62 bytes digital pins DIO1 and DIO2 must be wired up and configured properly.
  • CRC, Encoding, RSSI, address filtering, AFC and syncword configurations
  • Fixed and variable packet formats
  • Periodic beacons

How to use

esp-idf

Clone this repository somewhere, e.g.:

cd ~/myprojects/esp
git clone https://github.com/dernasherbrezon/sx127x.git

Add path to components:

set(EXTRA_COMPONENT_DIRS /home/user/myprojects/esp/sx127x)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(my-esp-project)

platformio

Add the following dependency to platformio.ini:

lib_deps = dernasherbrezon/sx127x

Linux

Linux version depends on kernel SPI driver only. Make sure it is enabled. Clone this repository somewhere, e.g.:

cd ~/myprojects/esp
git clone https://github.com/dernasherbrezon/sx127x.git

Add subdirectory:

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/sx127x)
target_link_libraries(my_application sx127x)

Custom architecture

It is possible to use this library in any other microcontroller architecture. To do this several steps are required.

  1. Implement functions to work via SPI. Interface is defined in include/sx127x_spi.h and put implementation somewhere inside your project.
  2. Clone this library into your project
  3. Connect all things together in your application's cmake file:
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/sx127x/include)
add_library(sx127x STATIC
        "${CMAKE_CURRENT_SOURCE_DIR}/sx127x/src/sx127x.c"
        "${CMAKE_CURRENT_SOURCE_DIR}/src/sx127x_custom_spi_implementation.c")
target_link_libraries(my_application sx127x)

Functions

All functions follow the same format:

sx127x_(modulation)_(rx or tx or empty)_(set or get)_(parameter)

Where:

  • modulation - can be "lora", "fsk" or "ook" or "fsk_ook" or empty. If empty, then applicable for all modulation types
  • rx or tx - some functions specific for rx or tx. If empty, then applicable for both
  • set or get - normally functions operate over sx127x registers - either set or get them

Examples

examples folder contains the following examples:

  • receive_lora - RX in LoRa mode and explicit header. Uses CAD to quickly detect presence of the message and switch into RX mode.
  • receive_lora_deepsleep - RX in LoRa mode while in the deep sleep
  • receive_lora_implicit_header - RX in LoRa mode and implicit header (without header)
  • receive_lora_raspberrypi - RX in LoRa mode on RaspberryPI via GPIO pins and onboard SPI. Tested on module RA-02
  • receive_fsk - RX in FSK mode. Variable packet length, NRZ encoding, CRC, AFC on.
  • receive_fsk_filtered - RX in FSK mode where only messages with NODE address 0x11 and Broadcast NODE address 0x00 are accepted. Variable packet length, NRZ encoding, CRC, AFC on.
  • receive_fsk_fixed - RX in FSK mode. Accepted packets with fixed packet length - 2047 bytes (max possible), NRZ encoding, CRC, AFC on.
  • receive_fsk_raspberry - RX in FSK mode on RaspberryPI via GPIO pins and onboard SPI. Variable packet length, NRZ encoding, CRC, AFC on.
  • receive_ook - RX in OOK mode. Variable packet length, NRZ encoding, CRC, AFC on.
  • transmit_lora - TX in LoRa mode and explicit header. Several messages of different sizes and at all supported power levels
  • transmit_lora_implicit_header - TX in LoRa mode and implicit header (without header)
  • transmit_lora_raspberrypi - TX messages using LoRa mode from RaspberryPI. Tested on module RA-02
  • transmit_fsk - TX in FSK mode. Variable packet length, NRZ encoding, CRC, AFC on. Sending several messages: small 2 byte, messages that can fit into FIFO fully, max messages for variable packet type - 255 bytes and same messages, but for node address 0x11 and 0x00.
  • transmit_fsk_fixed - TX in FSK mode. Fixed packet length - 2047 bytes, NRZ encoding, CRC, AFC on.
  • transmit_ook - TX in OOK mode. Variable packet length, NRZ encoding, CRC, AFC on. Sending several messages: small 2 byte, messages that can fit into FIFO fully, max messages for variable packet type - 255 bytes and same messages, but for node address 0x11 and 0x00.
  • temperature - Constantly read raw temperature value from the internal sensor. Must be calibrated first using well-known temperature. Available in FSK mode.

Tests

There are several unit tests in the test folder. They can be executed on any host machine using the commands below:

cd test
mkdir build
cd build
cmake ..
make test

Integration tests

Integration tests can verify communication between real devices in different modes. Tests require two LoRa boards connected to the same host. It is possible to test on any other boards by overriding pin mappings in test/test_app/main.c. By default tests assume transmitter and receiver is TTGO lora32.

Before running tests from ESP-IDF make sure pytest is installed.

Run the following command to test:

cd test/test_app
idf.py build
pytest --target esp32 --port="/dev/ttyACM0|/dev/ttyACM1" pytest_*

sx127x's People

Contributors

dernasherbrezon 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

Watchers

 avatar  avatar  avatar  avatar

sx127x's Issues

Error: SPI bus already initialized.

When trying to use this code on the esp32c3 mini chip, the version number used was esp-id5.0,f and the corresponding interface was modified.
)XRM826@M4L9`1Y(@)FM L4
EHX4 @S4TN_5XITTNJZBJUJ

lora transmit example issue

Doing everything according to instructions for platformio, after flashing the code i go to monitor and see my esp32 board reboots continuously with this error -
ESP_ERROR_CHECK failed: esp_err_t 0x10a (ESP_ERR_INVALID_VERSION) at 0x400d112d
file: "src/main.c" line 85
func: app_main
expression: sx127x_create(spi_device, &device)

[request] configure chip select pin on Linux

I have multiple devices on my SPI bus (on QCA9533), and need to assign a CS line to each. In the rpi example the code mentions spidev0.0 has this standard on GPIO8, where should I define the pin in my case?
Or should I pull this pin up before running this code?

Running on ESP32C6

Hello again,
I'm attempting to execute code on my ESP32, but I encounter an error. It appears after flashing when I open the serial terminal.
image

FIFO Problem

My received frames are always truncated of the first byte.
This is because you remove the first byte, considering it's only the packet_length stored on it in the case of VARIABLE.

In my implementation, my first byte contain not only the packet_lenght and other flags on it.

[RESOLVED] Unsynchronized frames

How can this be explained ?
The RAW are followed by my own decoder (Look at the recurrent (but wrong) pattern)
The FSK packet are VARIABLE, no CRC check
Synchro & preamble are fine
Doesnt Work : (Only CONTINOUS)
ESP_ERROR_CHECK(sx127x_set_opmod(SX127x_MODE_RX_SINGLE, SX127x_MODULATION_FSK, device));
Maybe configuring the main part ? :

  while (1) {
    vTaskDelay(

Or clear the FIFO in ? :

void handle_interrupt_task(void *arg) {
  while (1) {
    vTaskSuspend(NULL);
    // vTaskDelay(pdMS_TO_TICKS(10)); // Wait 10 millis
    sx127x_handle_interrupt((sx127x *)arg);
  }
}
I (00:08:42.011) sx127x_RAW: f3 ff 7e fc ff 6f ff f9 ff 77 f7 ff fd 9b fe fe 
I (00:08:42.012) sx127x_RAW: fe bc af fd fb ff bf bf f7 cd ff ff e9 ff ed fe
I (00:08:42.016) sx127x_RAW: 79 e7 ff f7 7f e7 fc ed 
7089FB3F1062FB3F0000000040000000000000000000000000000000F1000000745FFB3F40000000
I (00:09:07.291) sx127x_RAW: ff f5 f2 73 ef d5 f7 77 3e e7 7b 5b 7b ff ba f3 
I (00:09:07.292) sx127x_RAW: eb 7d 9e 97 e0 ef e7 b8 f8 cd f4 cc 37 fb f6 cf
I (00:09:07.296) sx127x_RAW: 79 b5 be fb e7 df 7b fe 
3F1062FB3F0000000040000000000000000000000000000000DB000000745FFB3F40000000106AFB
I (00:09:24.291) sx127x_RAW: fe ff 9f 8c fd 7b 7b be d0 f3 fe 23 73 5f fa 8f 
I (00:09:24.291) sx127x_RAW: cb e7 e7 ce 16 4a 54 0d 03 0d 0f be e4 77 ee 8f
I (00:09:24.295) sx127x_RAW: 57 ff 6c c3 ea fe cf f5
62FB3F0000000040000000000000000000000000000000F9000000745FFB3F40000000106AFB3FAD
I (00:10:07.601) sx127x_RAW: 94 81 18 5a f4 65 45 f7 4c 10 24 21 43 50 10 04 
I (00:10:07.601) sx127x_RAW: 41 2e 45 9f 9f df ff ff ff ff ff ff ff ff f5 d5
I (00:10:07.606) sx127x_RAW: 55 55 55 55 55 55 55 55 
FB3F1062FB3F000000004000000000000000000000000000000095000000745FFB3F40000000106A

Any plans to support SX126x modules?

sx1272 and sx1262 are often interchanged and unfortunately, I haven't seen a library that supports both except RadioLib.

Also, are you planning to implement a transport layer on top of the physical layer as it's done in RadioHead (device-to-device communication in a network, encryption, send failure notification and handling via retry)?

Problem with continuous transmission

I could not resolve a problem with transmitting messages continuously.

I have a task which has a queue and other tasks can send packet for transmission.

Expected behaviour

Transmitting every single packet.

Actual behaviour

It transmits every 3rd-4th packet when a task sending packets every 50ms and I have to always set back the mode to SX127x_MODE_RX_CONT to send the packets.

Code:

#include "lora.h"

static const char TAG[] = "LoRa";

// device can only be accessed by one task or interrupt at a time
SemaphoreHandle_t xLoraMutex;
// Rx buff mutex is not needed because the rx_callback dispatches the tasks
// TX buffer is not needed because the task will send data when it receives a packet from queue
QueueHandle_t lora_tx_queue;
SemaphoreHandle_t xLoraTXQueueMutex;
sx127x *lora_device;
spi_device_handle_t lora_spi_device;
TaskHandle_t lora_interrupt_handler;
// When a packet needs to be sent, only put in the rx buffer
// The sender task sends the packets
TaskHandle_t lora_packet_sender_handler;
LoRa_Packet lora_rx_buff[20];

uint16_t lora_calc_header_crc(LoRa_Packet_Header* header){
    uint8_t header_arr[5] = {header->src_device_addr, header->dest_device_addr,
                             header->num_of_packets, header->packet_num,
                             header->payload_size};

    return crc16_be(0, header_arr, 5);
}

uint16_t lora_calc_packet_crc(LoRa_Packet_Payload* payload, uint8_t payload_length){
    return crc16_be(0, payload->payload, payload_length);
}

void lora_display_packet(LoRa_Packet* packet_to_display){
    printf("Printing packet...\n");
    printf("\tHeader:\n");
    printf("\t\tSource device address: %d\n", packet_to_display->header.src_device_addr);
    printf("\t\tDestination device address: %d\n", packet_to_display->header.dest_device_addr);
    printf("\t\tPacket number: %d\n", packet_to_display->header.packet_num);
    printf("\t\tPayload size: %d\n", packet_to_display->header.payload_size);
    printf("\t\tHeader CRC: %d\n", packet_to_display->header.payload_size);
    printf("\tPayload:\n");
    printf("\t\t");
    for (uint8_t i = 0; i < packet_to_display->header.payload_size; i++) {
        printf("%#X ", packet_to_display->payload.payload[i]);
    }

    printf("\tPayload CRC:\n");
    printf("\t\t%d\n", packet_to_display->payload.payload_crc);
}

void IRAM_ATTR lora_handle_interrupt_fromisr(void *arg)
{
    xTaskResumeFromISR(lora_interrupt_handler);
}

void init_lora(spi_device_handle_t* spi_device, sx127x* lora_dev) {
    spi_device_interface_config_t dev_cfg = {
            .clock_speed_hz = 100000,
            .spics_io_num = LORA_SS_PIN,
            .queue_size = 16,
            .command_bits = 0,
            .address_bits = 8,
            .dummy_bits = 0,
            .mode = 0
    };

    ESP_ERROR_CHECK(spi_bus_add_device(LORA_SPI_HOST, &dev_cfg, spi_device));
    ESP_ERROR_CHECK(sx127x_create(*spi_device, &lora_dev));
    ESP_ERROR_CHECK(sx127x_set_opmod(SX127x_MODE_SLEEP, lora_dev));
    ESP_ERROR_CHECK(sx127x_set_frequency(437200012, lora_dev));
    ESP_ERROR_CHECK(sx127x_reset_fifo(lora_dev));
    ESP_ERROR_CHECK(sx127x_set_opmod(SX127x_MODE_STANDBY, lora_dev));
    ESP_ERROR_CHECK(sx127x_set_bandwidth(SX127x_BW_125000, lora_dev));
    ESP_ERROR_CHECK(sx127x_set_implicit_header(NULL, lora_dev));
    ESP_ERROR_CHECK(sx127x_set_modem_config_2(SX127x_SF_7, lora_dev));
    ESP_ERROR_CHECK(sx127x_set_syncword(18, lora_dev));
    ESP_ERROR_CHECK(sx127x_set_preamble_length(8, lora_dev));
    sx127x_set_tx_callback(tx_callback, lora_dev);
    sx127x_set_rx_callback(rx_callback, lora_dev);

    ESP_ERROR_CHECK(sx127x_set_opmod(SX127x_MODE_RX_CONT, lora_dev));
    ESP_ERROR_CHECK(sx127x_set_pa_config(SX127x_PA_PIN_BOOST, 4, lora_dev));

    BaseType_t task_code = xTaskCreatePinnedToCore(handle_interrupt_task, "handle interrupt", 8196, lora_dev, 100, &lora_interrupt_handler, xPortGetCoreID());
    if (task_code != pdPASS)
    {
        ESP_LOGE(TAG, "can't create task %d", task_code);
        sx127x_destroy(lora_dev);
        return;
    }

    ESP_ERROR_CHECK(gpio_set_direction((gpio_num_t)LORA_DIO0_PIN, GPIO_MODE_INPUT));
    ESP_ERROR_CHECK(gpio_pulldown_en((gpio_num_t)LORA_DIO0_PIN));
    ESP_ERROR_CHECK(gpio_pullup_dis((gpio_num_t)LORA_DIO0_PIN));
    ESP_ERROR_CHECK(gpio_set_intr_type((gpio_num_t)LORA_DIO0_PIN, GPIO_INTR_POSEDGE));
    ESP_ERROR_CHECK(gpio_install_isr_service(0));
    ESP_ERROR_CHECK(
            gpio_isr_handler_add((gpio_num_t) LORA_DIO0_PIN, lora_handle_interrupt_fromisr, (void *) lora_dev));

    xLoraMutex = xSemaphoreCreateMutex();
    xLoraTXQueueMutex = xSemaphoreCreateMutex();
    lora_tx_queue = xQueueCreate(50, sizeof(LoRa_Packet*));
    BaseType_t sender_task_code = xTaskCreatePinnedToCore(lora_packet_sender_task, "PacketSenderTask", 5120, lora_dev, 2, &lora_packet_sender_handler, 1);
    if (sender_task_code != pdPASS)
    {
        ESP_LOGE(TAG, "can't create sender task %d", task_code);
        sx127x_destroy(lora_dev);
        return;
    }
}

void handle_interrupt_task(void *arg)
{
    while (1)
    {
        vTaskSuspend(NULL);
        sx127x_handle_interrupt((sx127x *)arg);
    }
}

void tx_callback(sx127x *device)
{
    ESP_LOGI(TAG, "transmitted");
}


void rx_callback(sx127x *device) {
    uint8_t *data = NULL;
    uint8_t data_length = 0;
    esp_err_t code = sx127x_read_payload(device, &data, &data_length);
    if (code != ESP_OK) {
        ESP_LOGE(TAG, "can't read %d", code);
        return;
    }
    if (data_length == 0) {
        // no message received
        return;
    }
    uint8_t payload[514];
    const char SYMBOLS[] = "0123456789ABCDEF";
    for (size_t i = 0; i < data_length; i++) {
        uint8_t cur = data[i];
        payload[2 * i] = SYMBOLS[cur >> 4];
        payload[2 * i + 1] = SYMBOLS[cur & 0x0F];
    }
    payload[data_length * 2] = '\0';

    int16_t rssi;
    ESP_ERROR_CHECK(sx127x_get_packet_rssi(device, &rssi));
    float snr;
    ESP_ERROR_CHECK(sx127x_get_packet_snr(device, &snr));
    int32_t frequency_error;
    ESP_ERROR_CHECK(sx127x_get_frequency_error(device, &frequency_error));

    ESP_LOGI(TAG, "received: %d %s rssi: %d snr: %f freq_error: %ld", data_length, payload, rssi, snr, frequency_error);
}

void lora_packet_sender_task(void* pvParameters) {
    sx127x* lora_dev = (sx127x*) pvParameters;
    LoRa_Packet packet_to_send;
    // Optimization: if there are messages which has packet left to send
    // the program does not set the LoRa mode back to receiving until every message has been sent
    // which is indicated by the 0 value
    uint8_t messages_unfinished = 0;
    uint8_t mode = SX127x_MODE_RX_CONT;
    uint8_t lora_mutex_is_held_by_task = 0;
    while (1) {
        if( xQueueReceive(lora_tx_queue, &packet_to_send, 1000) == pdPASS )
        {
            if ( lora_mutex_is_held_by_task || xSemaphoreTake(xLoraMutex, portMAX_DELAY) == pdTRUE) {
                lora_mutex_is_held_by_task = 1;
                if (mode != SX127x_MODE_TX) {
                    ESP_ERROR_CHECK(sx127x_set_opmod(SX127x_MODE_TX, lora_dev));
                    //vTaskDelay(50 / portTICK_PERIOD_MS);
                    ESP_LOGI("LoRa", "Device set to tx...");
                    mode = SX127x_MODE_TX;
                }

                //lora_display_packet(&packet_to_send);

                // TODO: Put a while (spi_device_is_polling_transaction(spi)) here to
                // check when the spi bs is available
                // otherwise the lora_send_packet will throw spi error
                //lora_display_packet(&packet_to_send);

                //ESP_ERROR_CHECK(lora_send_packet(lora_dev, &packet_to_send));
                tx_callback(lora_dev);
                // Indicating the last packet of the message
                if (packet_to_send.header.packet_num == packet_to_send.header.num_of_packets - 1 &&
                    packet_to_send.header.num_of_packets != 1) {
                    messages_unfinished--;
                }

                // Indicating start of the message
                if (packet_to_send.header.packet_num == 0 && packet_to_send.header.num_of_packets != 1) {
                    messages_unfinished++;
                }

//                // Indicating all messages has been sent
//                if (messages_unfinished == 0) {
//                    ESP_ERROR_CHECK(sx127x_set_opmod(SX127x_MODE_RX_CONT, lora_dev));
//                    mode = SX127x_MODE_RX_CONT;
//                    xSemaphoreGive(xLoraMutex);
//                    lora_mutex_is_held_by_task = 0;
//                }

            }
        } else { // if packet are not received for a long period of time, reset state
            if (mode != SX127x_MODE_RX_CONT) {
                ESP_ERROR_CHECK(sx127x_set_opmod(SX127x_MODE_RX_CONT, lora_dev));
                ESP_LOGI("LoRa", "LoRa set back to rx");
                mode = SX127x_MODE_RX_CONT;
            }

            if (lora_mutex_is_held_by_task == 1) {
                xSemaphoreGive(xLoraMutex);
                lora_mutex_is_held_by_task = 0;
            }
        }
    }
}


// Calculates CRC and sends packet
uint8_t lora_send_packet(sx127x *lora_dev, LoRa_Packet* packet){
    uint8_t data[255];
    memset(&data[0], packet->header.src_device_addr, sizeof(uint8_t));
    memset(&data[1], packet->header.dest_device_addr, sizeof(uint8_t));
    memset(&data[2], packet->header.num_of_packets, sizeof(uint8_t));
    memset(&data[3], packet->header.packet_num, sizeof(uint8_t));
    memset(&data[4], packet->header.payload_size, sizeof(uint8_t));
    memcpy(&data[7], packet->payload.payload, packet->header.payload_size);
    memset(&data[7 + packet->header.payload_size], packet->payload.payload_crc, sizeof(uint16_t));
    ESP_ERROR_CHECK(sx127x_set_for_transmission(data, packet->header.payload_size + sizeof(LoRa_Packet_Header) + sizeof(uint16_t), lora_dev));
    ESP_ERROR_CHECK(sx127x_set_opmod(SX127x_MODE_TX, lora_dev));
    //uint8_t res = sx127x_set_for_transmission((uint8_t*) "asdasd", 6, lora_dev);
    ESP_LOGI(TAG, "Sent packet...");
    return 0;
}

uint8_t lora_send_message(uint8_t src_addr, uint8_t dest_addr, uint8_t* message, uint8_t message_len) {
    LoRa_Packet* lora_packets_buff;

    uint8_t num_of_full_packets = message_len / LORA_PAYLOAD_MAX_SIZE;
    uint8_t remaining_packet_size = message_len % LORA_PAYLOAD_MAX_SIZE;

    uint8_t num_of_packets = num_of_full_packets;
    if (remaining_packet_size != 0) {
        num_of_packets++;
    }

    lora_packets_buff = (LoRa_Packet*) malloc(sizeof(LoRa_Packet) * num_of_packets);
    if (lora_packets_buff == NULL) {
        ESP_LOGE(TAG, "Unable to allocate memory for packets.");
        return MESSAGE_NOT_ENOUGH_MEMORY;
    }

    for (uint8_t i = 0; i < num_of_packets; i++){
        LoRa_Packet packet;
        if (message_len / LORA_PAYLOAD_MAX_SIZE == 0) {
            memcpy(packet.payload.payload, &(message[i * LORA_PAYLOAD_MAX_SIZE]), remaining_packet_size);
            packet.header.payload_size = remaining_packet_size;
        } else {
            memcpy(packet.payload.payload, &(message[i * LORA_PAYLOAD_MAX_SIZE]), LORA_PAYLOAD_MAX_SIZE);
            packet.header.payload_size = LORA_PAYLOAD_MAX_SIZE;
        }

        packet.header.src_device_addr = src_addr;
        packet.header.dest_device_addr = dest_addr;
        packet.header.num_of_packets = num_of_packets;
        packet.header.packet_num = i;
        lora_calc_packet_crc(&(packet.payload), packet.header.payload_size);
        lora_calc_header_crc(&(packet.header));
        message_len -= LORA_PAYLOAD_MAX_SIZE;

        // Do not send immediately, needed to cache the whole message for the networking
        // and error correcting part
        lora_packets_buff[i] = packet;

        xQueueSend(lora_tx_queue, (void*) &packet, portMAX_DELAY);

    }
    free(lora_packets_buff);

    return MESSAGE_OK;
}

(It is not finished, but should trasmit...)

Packet sender task:

void network_temporary_controller_task(void* pvParameters) {
    Network_Device_Context* device_to_send = get_device_from_arp(&device_container, 0x01);
    if (device_to_send == NULL) {
        ESP_LOGI("network", "Device not in arp.");
    } else {
        ESP_LOGI("network", "Device in arp.");
    }

    device_to_send->tx_secret_message = (uint8_t*) malloc(3 * sizeof(uint8_t));
    if (device_to_send->tx_secret_message == NULL) {
        ESP_LOGI("network", "Out of memory temp.");
    }

    device_to_send->tx_secret_message_size = 3 * sizeof(uint16_t);
    uint16_t thr_raw_val;
    uint16_t joystick_x_raw_val;
    uint16_t joystick_y_raw_val;

    while (1) {
        vTaskDelay(50 / portTICK_PERIOD_MS);
        if (xSemaphoreTake(joystick_semaphore_handle, portMAX_DELAY) == pdTRUE) {
            adc2_get_raw(JOYSTICK_X_AXIS_ADC_CHANNEL, ADC_WIDTH, &joystick_x_raw_val);
            adc2_get_raw(JOYSTICK_Y_AXIS_ADC_CHANNEL, ADC_WIDTH, &joystick_y_raw_val);
            memset(&device_to_send->tx_secret_message[0], joystick_x_raw_val, sizeof(uint16_t));
            memset(&device_to_send->tx_secret_message[2], joystick_y_raw_val, sizeof(uint16_t));
            xSemaphoreGive(joystick_semaphore_handle);
        }


        adc2_get_raw(ADC_CHANNEL, ADC_WIDTH, &thr_raw_val);

        memset(&device_to_send->tx_secret_message[4], thr_raw_val, sizeof(uint16_t));
        deconstruct_message_into_packets(device_to_send);

        // problem with deconstruct fn
        //display_packet(&device_to_send->packet_tx_buff[0]);

        set_packets_for_tx(device_to_send, &lora_tx_queue);

    }
}

Compiling on ESP32C6 board

Hello,

I am using the example present in the repo to make my project, when I compile to the ESP32 board it works. However, when I try on my C6 I receive the following error:

image

I am using the espidf environment in vscode.

Not receiving any signal (868MHz FSK)

I have a small ESP-IDF Project for a Lilygo T3 S3 board (SX1276). I'm trying to receive data from Ecowitt WH51 sensors (868MHz FSK, various sources claim 868.35MHz should be used for best results). I started with the "receive_fsk" example in this repo and I replaced HSPI_HOST with SPI2_HOST (per #12 (comment)). I set the GPIO pins like they are in Lilygo's LoRa example projects for this board model, the project builds and runs. The 868MHz antenna (came with the board) is installed and my WH51 is right next to it.

I have tried all sorts of setting combinations, but I don't seem to get any signal at all. The sensor regularly blinks signifying that a reading was sent, but nothing seems to be received by the board. I have two of the Lilygo boards and they talk fine to each other when I tested them with Meshtastic so I'm fairly confident it's not a hardware issue. Any ideas on what settings to try / tips on how to troubleshoot further?

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.