HTCC-AB02 receiver always dies after a few hours

HTCC-AB02 Receiver dies after a few hours

Hi,

I’ve got a few HTCC-AB02 boards. The one I use for transmitting works as intended, sending sensor status about 30 times per minute, around 50 bytes at a time. But I’m struggling to write stable code for the boards I use for receiving. I’m trying to use one board as a bridge that listens to the LoRa signals and writes everything to the serial connection. A Linux box then stores the messages.

What I currently have is based on the examples (https://github.com/HelTecAutomation/CubeCell-Arduino/blob/master/libraries/LoRa/examples/LoRaBasic/LoRaReceiver/LoRaReceiver.ino). I’ve only changed the frequency to 433 MHz and BUFFER_SIZE to 60 bytes and set the LED to alternate its color, to be able to see whether the board still works. The problem is that the receiver hangs after a random time, usually after less than 8 hours. I have no idea what part of the code hangs, but after hanging, the led stops alternating its color and nothing is printed to the serial connection anymore.

I’ve tried multiple HTCC-AB02 boards. They hang regardless of whether they are connected to my Linux server or directly to a power supply. In all cases, I’m using USB to power the devices. The boards are new and I haven’t soldered anything to them.

Where could the problem be? Am I missing something obvious? Is the problem related to interrupt handling? I’m sure someone successfully uses a HTCC-AB02 to receive signals and forward them to a computer via serial connection. Or should I try something different?

Here’s my code:

/* Heltec Automation Receive communication test example
 *
 * Function:
 * 1. Receive the same frequency band lora signal program
 *
 *
 * this project also realess in GitHub:
 * https://github.com/HelTecAutomation/ASR650x-Arduino
 * */

#include "LoRaWan_APP.h"
#include "Arduino.h"

/*
 * set LoraWan_RGB to 1,the RGB active in loraWan
 * RGB red means sending;
 * RGB green means received done;
 */
#ifndef LoraWan_RGB
#define LoraWan_RGB 0
#endif

#define RF_FREQUENCY 433000000 // Hz

#define TX_OUTPUT_POWER 14 // dBm

#define LORA_BANDWIDTH 0        // [0: 125 kHz,
                                //  1: 250 kHz,
                                //  2: 500 kHz,
                                //  3: Reserved]
#define LORA_SPREADING_FACTOR 7 // [SF7..SF12]
#define LORA_CODINGRATE 1       // [1: 4/5,
                                //  2: 4/6,
                                //  3: 4/7,
                                //  4: 4/8]
#define LORA_PREAMBLE_LENGTH 8  // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT 0   // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON false
#define LORA_IQ_INVERSION_ON false

#define RX_TIMEOUT_VALUE 1000
#define BUFFER_SIZE 60 // Define the payload size here

char txpacket[BUFFER_SIZE];
char rxpacket[BUFFER_SIZE];

static RadioEvents_t RadioEvents;

uint32_t color = 0x100;

int16_t txNumber;

int16_t rssi, rxSize;

void OnRxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)
{
    rssi = rssi;
    rxSize = size;
    memcpy(rxpacket, payload, size);
    rxpacket[size] = '\0';
    turnOnRGB(color, 0);
    color = color == 0x100 ? 0x10000 : 0x100;
    Radio.Sleep();
    Serial.printf("RECEIVED %s\r\n", rxpacket);
}

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

    txNumber = 0;
    rssi = 0;

    RadioEvents.RxDone = OnRxDone;
    Radio.Init(&RadioEvents);
    Radio.SetChannel(RF_FREQUENCY);

    Radio.SetRxConfig(MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,
                      LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,
                      LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON,
                      0, true, 0, 0, LORA_IQ_INVERSION_ON, true);
    turnOnRGB(COLOR_SEND, 0); // change rgb color
    Serial.println("into RX mode");
}

void loop()
{
    Radio.Rx(0);
    delay(500);
    Radio.IrqProcess();
}

Update

I’ve now been able to increase the stability by changing the relevant parts of my code as follows:

void setup() {
  //
  RadioEvents.RxDone = OnRxDone;
  // ...
  Radio.Rx(0);
  Radio.IrqProcess();
}
void loop() {
  delay(1000);
}
void OnRxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) {
  if (size > BUFFER_SIZE - 1) {
    size = BUFFER_SIZE - 1;
  }
  memcpy(rxpacket, payload, size);
  rxpacket[size] = '\0';
  Radio.Sleep();
  // ...
}

Still, the receiver crashes typically after a few days, but occasionally much sooner.

How to find the problem? Or, could someone who successfully uses HTCC-AB02 as a receiver share their code?