Heltec CubeCell - part 2

This is the coding i used:

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


/* OTAA para*/
uint8_t devEui[] = { 0x00, 0x58, 0xD8, 0x09, 0xEF, 0x5D, 0x86, 0x98 };
uint8_t appEui[] = { 0x70, 0xB3, 0xD5, 0x7E, 0xD0, 0x03, 0x90, 0x67 };
uint8_t appKey[] = { 0xE2, 0xF0, 0xFC, 0xB9, 0x37, 0xEF, 0x66, 0x98, 0xD2, 0x3C, 0xD4, 0x2E, 0x30, 0x07, 0xEE, 0xF5 };
/* ABP para*/
uint8_t nwkSKey[] = { 0xEA, 0xBA, 0xB6, 0x18, 0xCB, 0x0A, 0xF2, 0xF5, 0x8C, 0x38, 0xD3, 0x98, 0x71, 0xF6, 0x16, 0xC9 };
uint8_t appSKey[] = { 0x1B, 0x83, 0x4A, 0x9B, 0x07, 0x71, 0xEF, 0x17, 0x52, 0xAD, 0x7F, 0xAE, 0x6B, 0xBB, 0xEB, 0x55 };
uint32_t devAddr =  ( uint32_t )0x26041414;
/*LoraWan channelsmask, default channels 0-7*/ 

uint16_t userChannelsMask[6]={ 0x00FF,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;

/*the application data transmission duty cycle.  value in [ms].*/
uint32_t appTxDutyCycle = 15000;

/*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 = 2;

uint8_t confirmedNbTrials = 4;

/* Prepares the payload of the frame */
static void prepareTxFrame( uint8_t port )
{
  
    appDataSize = 4;
    appData[0] = 0x00;
    appData[1] = 0x01;
    appData[2] = 0x02;
    appData[3] = 0x03;
}


void setup() {
  boardInitMcu();
  Serial.begin(115200);
#if(AT_SUPPORT)
  enableAt();
#endif
  deviceState = DEVICE_STATE_INIT;
  LoRaWAN.ifskipjoin();
}

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

Next time, please take a few seconds to properly format your post. Just cut-and-pasting code does not make a great message.

Im sorry about the post, Im new here and Im not used to the format writing. I thought if i post in arduino ide code format will be easier as i afraid there will be misintepretation.

By not adding formatting tags to your post the forum software will reformat it. By adding the [ code ] . . . [ /code ] (without the spaces within the brackets) tags you prevent it from messing with white space.

Ok, Mr. Kersing. Thank you

See this from my earlier message, it has all the instructions you need:

That log looks like the default code that comes with the device? are you sure you have uploaded your code correctly?

You’re in the wrong sub-band of US915.

You need to enable the 2nd bank of 8 channels, not the first.

uint16_t userChannelsMask[6]={ 0x00FF,0x0000,0x0000,0x0000,0x0000,0x0000 };

needs to become

uint16_t userChannelsMask[6]={ 0xFF00,0x0000,0x0000,0x0000,0x0000,0x0000 };

And yes, it’s confusing because bytes are being filled with words…

1 Like

Thank you! I played with my Cubcell like a year ago and had no luck. Had some time to play again, and this fixed my issues instantly with their demo code.

I already changed to 8 channel gateway as previously I was using single channel gateway but still I didnt get any data traffic on ttn

There’s so little detail here I don’t know where to begin!

Which 8 channel gateway?
Does it show any information about its connection to TTN - like a log?
Does the TTN console show any information about your gateway being connected?
Do your CubeCell uplinks show up on the gateway’s log or internal console?

1 Like

As previously explained, you are using the wrong channels

I already changed the sub band but still no data traffic

Show the new logs from both node and gateway

Sorry guys for the late reply, I get only these outputs as I have already connected Dht sensor.
It also takes quite a long time to upload although as i have put the device just beside the gateway
819d5d70-4320-42ac-97b4-9532d56d576e

That is neither a node log nor a gateway log. Also scribbling out information that goes over the air in cleartext is kind of silly

Hi Paul - just saw this question and was wondering if you had found a soln?

FYI, the ultrasonic sensors that most use are not stable on less than 5 volts. You have to purchase a special 3v sensor - they are expensive and harder to get.

BTW, where are you in Australia? I am in Armidale NSW.

Regards

Tim

Don’t think I have sorry, haven’t had the chance to revisit it yet.

Not sure if this is the correct place for this but this thread is all that pops up with my search on the matter.

My issue is that while I can use Arduino IDE just fine for Heltec modules, I would prefer to use Platform.io
But with Platform.io either the sketch comes out faulty or it is corrupted during upload.

I get no errors while building, nor when uploading. And an upload does take place because the previous sketch on the actual device stops working (the display goes out). But once the upload is complete, there is no serial output other than the “Copyright 2019 Heltec…etc” message, there is no RGB activity and there are no packets being sent.

This is my platformio.ini file:

[env:cubecell_gps]
platform = asrmicro650x
framework = arduino
board = cubecell_gps
monitor_speed = 115200
board_build.arduino.lorawan.region = EU868
board_build.arduino.lorawan.adr = ON
board_build.arduino.lorawan.debug_level = FREQ_AND_DIO

I have tried with the simplest examples on the Heltec github, and not one works when built/uploaded using Platform.io while all work perfectly when uploaded with Arduino IDE

Any ideas?

Have you asked about support for Platform.io on the Heltec forum?

1 Like