CubeCell-Board Plus(HTCC-AB02)stop working or jam just after few minutes

I am using two HTCC-AB02 board, one as master and one as slave which is connected to DHT11 sensor. The master board will call slave to send respective temperature and humidity data to the master board. At first, both are functioning well. However, just after a few minutes, they stop working. Below is my coding for both master and slave.

Master:
#include “LoRaWan_APP.h”
#include “Arduino.h”
#include <Wire.h>
#include “HT_SH1107Wire.h”

#ifndef LoraWan_RGB
#define LoraWan_RGB 0
#endif

#define RF_FREQUENCY 923000000 // Hz

#define TX_OUTPUT_POWER 5 // 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 80 // Define the payload size here

unsigned long lastReadingTime = 0;
const unsigned long interval1 = 10000L;
const unsigned long interval2 = 5000L;
int i = 1;

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

static RadioEvents_t RadioEvents;
void OnTxTimeout( void );
void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr );

bool sleepMode = false;
int16_t Rssi, rxSize;

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

Rssi = 0;

RadioEvents.TxTimeout = OnTxTimeout;
RadioEvents.RxDone = OnRxDone;

Radio.Init( &RadioEvents );
Radio.SetChannel( RF_FREQUENCY );
Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
LORA_SPREADING_FACTOR, LORA_CODINGRATE,
LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
true, 0, 0, LORA_IQ_INVERSION_ON, 3000 );

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 );
}

void callTemp() {
sprintf(txpacket, “%s”, “Temp”);
turnOnRGB(COLOR_SEND, 0);
Serial.printf(txpacket, strlen(txpacket));
Radio.Send( (uint8_t *)txpacket, strlen(txpacket) );
lowPowerHandler();
delay(400);
turnOnRGB (1, 1);
}

void callHum() {
sprintf(txpacket, “%s”, “Hum”);
turnOnRGB(COLOR_SEND, 0);
Serial.printf(txpacket, strlen(txpacket));
Radio.Send( (uint8_t *)txpacket, strlen(txpacket) );
lowPowerHandler();
delay(400);
turnOnRGB (1, 1);
}

void loop()
{
if (millis() - lastReadingTime > interval1) {
i = 0;
lastReadingTime = millis();
callTemp();
}
if (millis() - lastReadingTime > interval2 && i == 0) {
i = 1;
callHum();
}
else {
turnOnRGB (1, 1);
Radio.Rx( 0 );
// lowPowerHandler();
Radio.IrqProcess( );
delay(400);
}
}

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_RECEIVED, 0);
delay(100);
Radio.Sleep( );
Serial.println();
Serial.printf(rxpacket);
delay(400);
}

void OnTxTimeout( void )
{
Radio.Sleep( );
Serial.println(“TX Timeout…”);
}

Slave:
#include “LoRaWan_APP.h”
#include “Arduino.h”
#include <Wire.h>
#include “HT_SH1107Wire.h”

#ifndef LoraWan_RGB
#define LoraWan_RGB 0
#endif

#define RF_FREQUENCY 923000000 // Hz

#define TX_OUTPUT_POWER 5 // 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 80 // Define the payload size here

//SH1107Wire displayz(0x3c, 500000, SDA, SCL , GEOMETRY_128_64, GPIO10); // addr, freq, sda, scl, resolution, rst

unsigned long lastReadingTime = 0;
const unsigned long interval = 10000L;

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

static RadioEvents_t RadioEvents;
//void OnTxDone( void );
void OnTxTimeout( void );
void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr );

bool sleepMode = false;
int16_t Rssi, rxSize;

#include <DHT.h>
#define DHTPIN GPIO5
#define DHTTYPE DHT11
char temp[10];
char humid[10];
float h, t;
DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(115200);
delay(50);
dht.begin();
delay(3000);
Rssi = 0;

RadioEvents.TxTimeout = OnTxTimeout;
RadioEvents.RxDone = OnRxDone;

Radio.Init( &RadioEvents );
Radio.SetChannel( RF_FREQUENCY );
Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
LORA_SPREADING_FACTOR, LORA_CODINGRATE,
LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
true, 0, 0, LORA_IQ_INVERSION_ON, 3000 );

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 );
}

byte getdata() {
h = dht.readHumidity();
delay(10);
t = dht.readTemperature();
delay(10);
Serial.print("Humid: ");
Serial.println(h);
Serial.print("Temp: ");
Serial.println(t);
}

void sending_temp_data() {

dtostrf(t, 4, 1, temp);
sprintf(txpacket , “%s”, temp );
sprintf(txpacket + strlen(txpacket), “%s”, “°C\n” );
turnOnRGB(COLOR_SEND, 0);
Serial.printf(txpacket, strlen(txpacket));
Radio.Send( (uint8_t *)txpacket, strlen(txpacket) );
lowPowerHandler();
delay(500);
turnOnRGB (1, 1);
}

void sending_hum_data() {
dtostrf(h, 4, 1, humid);
sprintf(txpacket, “%s”, humid);
sprintf(txpacket + strlen(txpacket), “%s”, “%\n”);

turnOnRGB(COLOR_SEND, 0);
Serial.printf(txpacket, strlen(txpacket));
Radio.Send( (uint8_t *)txpacket, strlen(txpacket) );
lowPowerHandler();
delay(500);
turnOnRGB (1, 1);
}

void loop()
{
turnOnRGB (1, 1);
if (millis() - lastReadingTime > interval) {
lastReadingTime = millis();
getdata();
}
else {
turnOnRGB (1, 1);
Radio.Rx( 0 );
// lowPowerHandler();
Radio.IrqProcess( );
}
}

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_RECEIVED, 0);
delay(500);
Radio.Sleep( );
Serial.printf(rxpacket);
String call(rxpacket);
if (call == “Temp”) {
sending_temp_data();
Radio.IrqProcess( );
}
if (call == “Hum”) {
sending_hum_data();
Radio.IrqProcess( );
}
}

void OnTxTimeout( void )
{
Radio.Sleep( );
Serial.println(“TX Timeout…”);
}

It looks/sounds to me like one of your nodes, probably the slave, is going to sleep and not waking up.

A few strategically placed ‘print’ statements might help work out where things are stalling. Removing all references to the lowPowerHandler(), and sleeping of the radio, might also eliminate those as potential causes. You can then add the sleep/low power stuff back in where it makes sense and see what happens.

After removing the lowPowerHandler() and sleeping, I think the problem is solved. Both can run without stopping for more than 12hours so far.

Thanks a lot.

Good morning, I was having similar problem of the board freezing after an undefined period of time, mostly related to the GPS (not that I know anything!)- so I’ve now added a watchdog into the which is disabled in lowpower mode.

They have example scripts.

CySysWdtEnable(); //enable the WDT
CySysWdtDisable(); //disable the WDT before going to sleep

etc…

Cheers, James