How to ensure reliable wireless data transmission with RF module and SPI on AVR128DA48?

Hey guys, In my pressure monitoring project using the AVR128DA48 microcontroller, I’m trying to transmit the pressure readings wirelessly using an RF module via SPI. However, the transmission appears to be unreliable, with frequent data loss. so far I have checked the RF module configuration and ensured proper SPI communication, and also ensured the RF module is within the effective transmission range, yet data transmission remains unreliable, with some pressure readings not being transmitted successfully. What could be causing this unreliability, and how can I ensure consistent and reliable wireless data transmission? this is my written snippet:
#include <zephyr.h>
#include <device.h>
#include <drivers/sensor.h>
#include <drivers/spi.h>

#define RF_MODULE_SPI_DEV "SPI_1"

void main(void)
{
const struct device *rf_spi_dev = device_get_binding(RF_MODULE_SPI_DEV);
struct sensor_value pressure;

if (rf_spi_dev == NULL) {
printk("Failed to bind to RF module SPI device\n");
return;
}

const struct device *bmp280 = device_get_binding(DT_LABEL(DT_INST(0, bosch_bmp280)));

while (1) {
sensor_sample_fetch(bmp280);
sensor_channel_get(bmp280, SENSOR_CHAN_PRESS, &pressure);

rf_transmit(rf_spi_dev, &pressure, sizeof(pressure));

k_sleep(K_SECONDS(5));
}
}
#include <zephyr.h>
#include <device.h>
#include <drivers/sensor.h>
#include <drivers/spi.h>

#define RF_MODULE_SPI_DEV "SPI_1"

void main(void)
{
const struct device *rf_spi_dev = device_get_binding(RF_MODULE_SPI_DEV);
struct sensor_value pressure;

if (rf_spi_dev == NULL) {
printk("Failed to bind to RF module SPI device\n");
return;
}

const struct device *bmp280 = device_get_binding(DT_LABEL(DT_INST(0, bosch_bmp280)));

while (1) {
sensor_sample_fetch(bmp280);
sensor_channel_get(bmp280, SENSOR_CHAN_PRESS, &pressure);

rf_transmit(rf_spi_dev, &pressure, sizeof(pressure));

k_sleep(K_SECONDS(5));
}
}
Solution:
Well, @Dtynin to address the problem, it's necessary to incorporate error checking and retries in order to guarantee reliable transmission. The likely cause of concern pertains to failure in verifying successful data communication by the RF module.
Jump to solution
2 Replies
Solution
Sterling
Sterling5mo ago
Well, @Dtynin to address the problem, it's necessary to incorporate error checking and retries in order to guarantee reliable transmission. The likely cause of concern pertains to failure in verifying successful data communication by the RF module.
Dtynin
Dtynin5mo ago
thanks buddy @Sterling I'll try adding them, hopefully, it should suffice.
Want results from more Discord servers?
Add your server