Heltec CubeCell - part 2

Hi,
I have a HTCC-AB01 board. It operates on a LiFePo battery that is connected directly to the 3.3Vpin. I removed the BR1 zero Ohm resistor to be able to use the only available ADC for battery measurement.
I created the same divider (200k+100k) for the ADC. I use the sample code that makes the processor sleep after data sending. I modified the code to measure temperature with a DS18B20. It is supplied from a GPIO just before measuring. It works fine. The consumption of the whole is a bit less than 20uA. The divider costs almost the half of it. So the panel seems perfect and works according to the documentation.

My question would be that how long the deep sleep can be?
There is a variable in the code that contains the length of the sleep time in milli sec.

/the application data transmission duty cycle. value in [ms]./
uint32_t appTxDutyCycle = 600000; //10min

How big this could be?

thanks
Ákos

Do you mean that 20 uA is the current usage during deep sleep?

While this does not answer your question, wasting half of your deep sleep energy to a voltage divider that is only used when awake is wasting valuable battery energy.

You can disable the divider during deep sleep by switching it on/off with a simple MOSFET switch using VExt (or some GPIO) to control it.
I have not used this with CubeCell myself yet but it should be possible.

it is absolutely true. This setup is just a prototype to prove that all the idea works as it should be. The final version will have the switch for the divider. But this setup proved that the deep sleep consumption is around 10uA which is OK for me.

Any idea about the maximum length of deep sleep time?
the variable is a 32bit one. The max number is 2^32msec, which is about 49.7days. Is this the max time that the processor can spend in deep sleep?

I don’t know what the real maximum is. Ideally this should be specified in the documentation, but I wonder if this is documented.

I tested it with four hour, which is 14400000msec and it worked.

1 Like

I tried to put the whole program under PlatformIO. I installed the environment. The IDE misses an include and indicates it in the LoRaWAN_APP.cpp:

cannot open source file “soc/rtc.h” (dependency of “LoRaWan_APP.h”)C/C++(1696)

Any idea how to solve this?

Hi All,

I am trying to use the small Cubecell board (AB01) for a rain gauge but getting random, phantom counts for some reason.

Hardware

  • Davis tipping bucket rain gauge with two wires, one connected to ground and the other to GPIO0.

Software

  • sketch attached below
  • it uses a combination of the example LoRaWAN and Interrupt sketches.
  • Rain Gauge reed switch is debounced
  • GPIO0 is set as a pullup
  • It counts interrupts while asleep and then wakes up at a set interval to send the count.

Unusual Behaviour

  • Rain gauge will run for days without any issues and then all of a sudden register a few interrupts for no reason (rain gauge is sitting on a bench in a locked office, so no chance of it being bumped), and then register nothing for another few days, and then have a random interrupt count again.

What I have tried

  • I have tried using an external pullup resistor (10K and then 20K - GPIO0 to VDD) but it still happens.
    -also tried several boards, same thing happens

Any ideas would be greatly appreciated.

thanks Paul

/*For a Davis Rain Gauge
 * Red Wire to GPIO0 (interrupt attached)
 * Green wire to Ground
 * interrupt works on falling (pulling to GND)
 * Rain Guage tipping bucket is debounced with 200ms time out
 * Downlink format - send one byte to change send interval = 'byte sent value' X 'txMultiplier'
 */

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

/*
 * set LoraWan_RGB to Active,the RGB active in loraWan
 * RGB red means sending;
 * RGB purple means joined done;
 * RGB blue means RxWindow1;
 * RGB yellow means RxWindow2;
 * RGB green means received done;
 */

/*the application data transmission duty cycle.  value in [ms].*/
uint32_t appTxDutyCycle = 600000; // Default 10 mins
uint32_t txMultiplier = 300000; 	//Multiplier used for downlink 
#define rainPin GPIO0
int rain = 0;
uint16_t vbat;

/* OTAA para*/
uint8_t devEui[] = {  };
//generic_meshed_testing app
uint8_t appEui[] = {  };
uint8_t appKey[] = {  };

/* ABP para*/ 
uint8_t nwkSKey[] = {  };
uint8_t appSKey[] = {  };
uint32_t devAddr =  ( uint32_t );

/*LoraWan channelsmask, default channels 0-7 - 0xFF00 sets to sub band 2 */
uint16_t userChannelsMask[6]={ 0xFF00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000};

/*LoraWan region, select in arduino IDE tools*/
LoRaMacRegion_t loraWanRegion = ACTIVE_REGION;

/*LoraWan Class, Class A and Class C are supported*/
DeviceClass_t  loraWanClass = LORAWAN_CLASS;

/*OTAA or ABP*/
bool overTheAirActivation = LORAWAN_NETMODE;

/*ADR enable*/
bool loraWanAdr = LORAWAN_ADR;

/* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */
bool keepNet = LORAWAN_NET_RESERVE;

/* Indicates if the node is sending confirmed or unconfirmed messages */
bool isTxConfirmed = LORAWAN_UPLINKMODE;

/* Application port */
uint8_t appPort = 1;

/* Note, that if NbTrials is set to 1 or 2, the MAC will not decrease
* the datarate, in case the LoRaMAC layer did not receive an acknowledgment
*/
uint8_t confirmedNbTrials = 4;

/* Prepares the payload of the frame */
static void prepareTxFrame( uint8_t port )
{
	uint16_t vbat = getBatteryVoltage();
  Serial.println("");
  Serial.println("");
  Serial.println("");
  Serial.print("Vbat = ");Serial.println(vbat);
  Serial.print("Rain = ");Serial.println(rain);  
    appDataSize = 4;//AppDataSize max value is 64
    appData[0] = highByte(vbat);
    appData[1] = lowByte(vbat);
    appData[2] = highByte(rain);
    appData[3] = lowByte(rain);
}

void setup() {
	boardInitMcu();
	Serial.begin(115200);
#if(AT_SUPPORT)
	enableAt();
#endif
	deviceState = DEVICE_STATE_INIT;
	LoRaWAN.ifskipjoin();
  pinMode(rainPin,INPUT_PULLUP);
  attachInterrupt(rainPin,raincounter,FALLING);
}

void loop()
{
	switch( deviceState )
	{
		case DEVICE_STATE_INIT:
		{
#if(AT_SUPPORT)
			getDevParam();
#endif
			printDevParam();
			LoRaWAN.init(loraWanClass,loraWanRegion);
			deviceState = DEVICE_STATE_JOIN;
			break;
		}
		case DEVICE_STATE_JOIN:
		{
			LoRaWAN.join();
			break;
		}
		case DEVICE_STATE_SEND:
		{
			prepareTxFrame( appPort );
			LoRaWAN.send();
			deviceState = DEVICE_STATE_CYCLE;
			break;
		}
		case DEVICE_STATE_CYCLE:
		{
			// Schedule next packet transmission
			txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND );
			LoRaWAN.cycle(txDutyCycleTime);
			deviceState = DEVICE_STATE_SLEEP;
			break;
		}
		case DEVICE_STATE_SLEEP:
		{
			LoRaWAN.sleep();
			break;
		}
		default:
		{
			deviceState = DEVICE_STATE_INIT;
			break;
		}
	}
}

void raincounter() {
 //Debounce switch
      static unsigned long last_interrupt_time = 0;
      unsigned long interrupt_time = millis();
     // If interrupts come faster than 200ms, assume it's a bounce and ignore
      if (interrupt_time - last_interrupt_time > 200)
        {
          rain = rain + 1;
        }
      last_interrupt_time = interrupt_time;
 }

//downlink data handle function
void downLinkDataHandle(McpsIndication_t *mcpsIndication)
{
  Serial.printf("+REV DATA:%s,RXSIZE %d,PORT %d\r\n",mcpsIndication->RxSlot?"RXWIN2":"RXWIN1",mcpsIndication->BufferSize,mcpsIndication->Port);
  Serial.print("+REV DATA:");
  for(uint8_t i=0;i<mcpsIndication->BufferSize;i++) {
    Serial.printf("%02X",mcpsIndication->Buffer[i]);
  }
  Serial.println();

  if (mcpsIndication->BufferSize == 1) {
    Serial.println("Check 1 Byte Message");
    appTxDutyCycle = (mcpsIndication->Buffer[0])*txMultiplier;
    Serial.print("Changing TX Interval to: ");Serial.print(appTxDutyCycle/60000);Serial.println(" mins");
  }
}

Hello,
I’m looking for a good battery for de CubeCell development board to combine with a solar cell. At Ali express I found this one:https://nl.aliexpress.com/item/4000036263960.html?spm=a2g0s.8937460.0.0.26392e0eKvAelk
Is this a battery suitable for this board and with the right connector?

LiPo is a 3.7V (nominal voltage) chemistry which is supported by CubeCell development boards’ battery connector.
Which Cubecell board do you have?

I don’t see details about the battery’s connector so how shall we determine whether it is suitable?

As a general rule of thumb: When buying a battery (cable) separately, always CHECK that polarity of the cable’s connector matches polarity of the board’s connector - before connecting the battery (if reversed this may toast your board).

@bluejedi: thank you for your good advice to check the polarity of the battery before connecting it.

I’ve got the ab01 development board from the cubecell serie. The documentation on the Heltec site tells me the board has a SH1.25 x 2 battery connector. The documentation with the battery tells It has a 1.25MM 2pin connector. It looks to me this should be the right connector, but I am not completely convinced because it doesn’t mention it is suitable for an SH connector. Since I’m not familiar with al the connector types there are, I hope someone on this forum could give me an good advice or can tell me where to buy a battery that is suitable for this board.

My apologies for the the lack of information in my previous post.

No need to apologize.

I missed the 1.25 mm in the battery’s description.

The CubeCell HTCC-AB01 indeed uses a 2-pin connector with 1.25 mm spacing for the battery.

But Heltec’s product information is incorrect in calling this a ‘SH’ connector!

JST Connectors

‘XH’, ‘PH’, ‘ZH’, ‘GH’ and ‘SH’ connector designations come from JST connectors.

JST type connectors are manufactured to the design standards originally developed by J.S.T. Mfg. Co. (Japan Solderless Terminal).

The following are popular JST (type) connectors. Each has a different pin spacing:

JST connector type Pin spacing
JST-XH 2.5 mm
JST-PH 2.0 mm
JST-ZH 1.5 mm
JST-GH 1.25 mm
JST-SH 1.0 mm

JST-SH has a pin spacing of 1.0 mm, therefore the connector with 1.25 mm spacing on the HTCC-AB01 board is not ‘SH’ type.

So is it JST-GH then, which has the same 1.25 mm pin spacing?
Actually not. Original JST-GH from JST has a lock (clearly visible) while ‘JST 1.25 mm’, JST-XH, JST-PH, JST-ZH and JST-SH have not.

The battery connector on the HTCC-AB01 (which is also used on some other boards) looks more like a Molex Picoblade 1.25 mm connector.

On Chinese sites like AliExpress you will often see this connector being referred as ‘JST 1.25 mm’ (without type name) or sometimes (probably incorrect) as (JST) GH 1.25 mm.
Sometimes they are even incorrectly listed as PH 1.25 mm (or in case of Heltec’s product information SH 1.25 mm).

If on sites like AliExpress a connector is described as ‘JST 1.25 mm’ or ‘GH 1.25mm’ then it will probably fit HTCC-AB01’s battery connector.

Don’t forget to check for correct polarity. If polarity is reversed you will first have to correct it by switching the cable cores in the connector. Cable cores can be removed by unlatching them with a needle (with some care and patience).

1 Like

@TheNetStriker Did you ever get to the bottom of this? I have only ever used my board (HTCC-AB01) via USB or via 3.7v lithium battery but have been unable to get it down into the microamp range in sleep. I have nothing connected other than antenna and battery.

Using the LowPower_WakeUpByTimer example I can see my device moving from 2mA in sleep to 13mA awake, I’m nowhere close to the microamp range. I had this device set up as part of a weather station but the battery didn’t last long at all so it looks like something is causing it to draw far too much current in sleep mode. At this point I am wondering if I have a faulty unit, I have another one on the way though so will be able to compare when it arrives.

My devices are working at the moment. One device is working off a 18650 battery for about two months now and the battery is still almost fully charged. Did you also update the firmware to the latest version and are you using the lastest board code from the GitHub repository?

Thanks for the reply! I’m using the latest board code, that definitely helped, but I haven’t considered updating the firmware. I’m having trouble finding it - could you point me in the right direction?

I used the CubeCell Configurator to update the firmware. It automatically finds the latest firmware for your board and updates the firmware.

Thanks! I haven’t seen this tool before. I just updated the firmware and checked; it made no difference. However as I was doing that my new board arrived in the mail; I tested that with the exact same code and configuration and I’m seeing the ~9uA as expected, so perhaps some hardware fault with my first board.

add this part of code
/* Prepares the payload of the frame */
extern “C” void systemTimer(void); // We need this as a work-around …

static void prepareTxFrame( uint8_t port )

and finish

case DEVICE_STATE_SLEEP:
{
LoRaWAN.sleep();
CySysTickSetCallback(4,&systemTimer);
break;
}

Although I have some experience with TTN / Arduino / LMIC, I don’t know how to get the Heltec Cubecell board working with TTN. I can program the board via Arduino IDE with, for example, the demo sketch from Heltec called MultiSensorAutoRecognize. Unfortunately, I have not been able to find out how to link to TTN in such a program. I don’t want to work with AT commands but just program in Arduino.

Maybe I’m overlooking something … That’s why I want to ask if someone can help me, for example with a working sketch.

You’ll have to blend a couple together

Start with their Lorawan example and get that working - then blend in the sensor code you need

There is also an app available too - search on the Heltec Forum for the user WASN

Thanks Paul! Do you mean the Heltec example called “LoRaWan.ino” and is this sketch ment to be used for TTN? If so I’ll try after entering the right keys, thereafter I will contact WASN when needed.