Cubecell capsule batter drain

Hello, this is my first post as I couldn’t find the answer anywhere.

I have been trying to play with two cubecell capsules I bought. My plan is to use them with TTN but so far I wanted to make some Lora tests. The thing is that the battery gets exhausted extremely fast. I suspect there is a problem with the capsules…

I have loaded the basic LoRa example to read and send the battery:

/* Heltec Automation Ping Pong communication test example
*

  • Function:
    1. CubeCell read battery voltage and transmit via LoRa.
  • Description:
    1. Only hardware layer communicate, no LoRaWAN protocol support;
    1. This examplese can communicate with other ESP32 LoRa device,
  • WiFi LoRa 32, Wireless Stick, Wireless Stick Lite, etc.
    1. This example is for CubeCell hardware basic test.
  • HelTec AutoMation, Chengdu, China
  • �ɶ��������Զ����Ƽ����޹�˾
  • this project also realess in GitHub:
  • */

#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 868000000 // 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 8 // [SF7…SF12]
#define LORA_CODINGRATE 4 // [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 30 // Define the payload size here

char txPacket[BUFFER_SIZE];

static RadioEvents_t RadioEvents;
void OnTxDone( void );
void OnTxTimeout( void );

typedef enum
{
LOWPOWER,
ReadVoltage,
TX
}States_t;

States_t state;
bool sleepMode = false;
int16_t rssi,rxSize;
uint16_t voltage;

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

voltage = 0;
rssi=0;

RadioEvents.TxDone = OnTxDone;
RadioEvents.TxTimeout = OnTxTimeout;

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

state=ReadVoltage;

}

void loop()
{
switch(state)
{
case TX:
{
sprintf(txPacket,"%s",“ADC_battery: “);
sprintf(txPacket+strlen(txPacket),”%d”,voltage);
turnOnRGB(COLOR_SEND,0);
//Serial.printf("\r\nsending packet “%s” , length %d\r\n",txPacket, strlen(txPacket));
Radio.Send( (uint8_t *)txPacket, strlen(txPacket) );
state=LOWPOWER;
break;
}
case LOWPOWER:
{
lowPowerHandler();
delay(50);
turnOffRGB();
delay(60000); //LowPower time
state = ReadVoltage;
break;
}
case ReadVoltage:
{
pinMode(VBAT_ADC_CTL,OUTPUT);
digitalWrite(VBAT_ADC_CTL,LOW);
voltage=analogRead(ADC)*2;

  /*
   * Board, BoardPlus, Capsule, GPS and HalfAA variants
   * have external 10K VDD pullup resistor
   * connected to GPIO7 (USER_KEY / VBAT_ADC_CTL) pin
   */
  pinMode(VBAT_ADC_CTL, INPUT);

  state = TX;
  break;
}
 default:
      break;

}
Radio.IrqProcess();
}

void OnTxDone( void )
{
turnOnRGB(0,0);
}

void OnTxTimeout( void )
{
Radio.Sleep( );
state=ReadVoltage;
}

I removed every serial and have reset the capsule after disconnecting. However I get the following reading while the Capsule is supposed to be deep sleeping. Current 9mA! I believe that is the reason for the fast draining… anyone can tell me if I am doing something wrong?

When sending the power goes up to 11 which I am assuming is normal.

Thanks!

This is what I receive in the other Capsule using the LoraRead… and which shows how quickly the battery is decreasing:

15:46:03.993 -> received packet “ADC_battery: 3958” with rssi -35 , length 17
15:47:05.360 ->
15:47:05.360 -> received packet “ADC_battery: 3890” with rssi -14 , length 17
15:48:06.205 ->
15:48:06.205 -> received packet “ADC_battery: 3852” with rssi -14 , length 17
15:49:07.597 ->
15:49:07.597 -> received packet “ADC_battery: 3836” with rssi -15 , length 17
15:50:08.443 ->
15:50:08.443 -> received packet “ADC_battery: 3828” with rssi -16 , length 17
15:51:09.818 ->
15:51:09.818 -> received packet “ADC_battery: 3822” with rssi -16 , length 17
15:52:11.185 ->
15:52:11.185 -> received packet “ADC_battery: 3816” with rssi -28 , length 17
15:53:12.028 ->
15:53:12.028 -> received packet “ADC_battery: 3812” with rssi -29 , length 17

I know I shouldn’t be sending every minute, my plan is to send twice per day but the battery is drained so fast that I cannot even receive two packets as the battery is exhausted before.

Hi,
looking at your sketch I noticed that you’re using the lowPowerHandler() wrong. The correct way is a bit confusing. Take a look at the lowPower examples (especially the interrupt by timer). The Program gets “stuck” when in lowPower mode and you therefore need no explicit delay. You’ll have to delay with Timers. Also notice that he lowPowerHandler() needs to be called 6 times before the MCU goes into deep sleep mode. With that mode active you’ll get a much lower energy consumption.

1 Like

Thanks @TomStein.

I will have a look, try and report. I am surprised thought to be using it wrong as I am using the default Lora examples that come with the libraries.

hi,

Greeting from heltec!

  1. Could you try these code to verify the LOW power:
    https://github.com/HelTecAutomation/CubeCell-Arduino/tree/master/libraries/Basics/examples/LowPower

  2. If there is no problem with the above. please try the lorawan code to verify LOW power again!
    https://github.com/HelTecAutomation/CubeCell-Arduino/tree/master/libraries/LoRa/examples/LoRaWAN/LoRaWan

Thanks @jasonXu. I will try an report. I am still learning and focusing on LoRa before using LoRaWAN.

The thing is that the LoRa example code seems to not use the lowPowerHandler well… or maybe I should include a delay before calling it.