Hi, I bought two Cubecell boards and wanted to use them with TTS (TTN v3). I’ve got a multi-channel RAK Gateway which works perfectly with my Dragino node I bought.
I also have a Heltec ESP32 Lora Board which also works flawlessly with my gateway.
I am in EU868 and am using v1.3.0 of the Cubecell Board config for Arduino.
In TTN I am using v1.0.2 rev B like indicated in other posts.
For my code I am using the bmp280 example file from here https://github.com/HelTecAutomation/CubeCell-Arduino/blob/master/libraries/Sensor_ThirdParty/examples/BMP280/bmp280/bmp280.ino with my added devEUI, appKey…
Using OTAA results in multiple join requests which are accepted like e.g. also described here If there is some data received afterwards its pure luck (sending ever minute for 8h results in like 2 messages received). Using ABP it’s the same problem.
Using the SendReceive Example which only tries to join results in the same behavior.
I tried putting the node right beside the gateway and also some walls away and nothing changes.
I tried also converting to plain basicmac which did not work and for lmic I did not find the right pin mapping.
As far as I see my gateway is configured right, the global_conf matches the one I can download from TTN directly and other devices are successful using it.
I also found some other threads concerning EU868 but all without solutions.
What could be the issue which I did not yet find, anybody else from Europe here with a solution to those problems?
#include "LoRaWan_APP.h"
#include "Arduino.h"
#include <Wire.h>
#include <BMP280.h>
// SHT21 Library
#include <Adafruit_Si7021.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;
*/
// TTN OTAA
uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
uint8_t devEui[] = { 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX };
uint8_t appKey[] = { 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX };
// TTN ABP
uint8_t nwkSKey[] = { };
uint8_t appSKey[] = { };
uint32_t devAddr = ( uint32_t )0x260XXXX;
/*LoraWan channelsmask, default channels 0-7*/
uint16_t userChannelsMask[6]={ 0x00FF,0x0000,0x0000,0x0000,0x0000,0x0000 };
/*LoraWan Class*/
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;
/*LoraWan REGION*/
LoRaMacRegion_t loraWanRegion = ACTIVE_REGION;
/* Indicates if the node is sending confirmed or unconfirmed messages */
bool isTxConfirmed = LORAWAN_UPLINKMODE;
/*!
* Number of trials to transmit the frame, if the LoRaMAC layer did not
* receive an acknowledgment. The MAC performs a datarate adaptation,
* according to the LoRaWAN Specification V1.0.2, chapter 18.4, according
* to the following table:
*
* Transmission nb | Data Rate
* ----------------|-----------
* 1 (first) | DR
* 2 | DR
* 3 | max(DR-1,0)
* 4 | max(DR-1,0)
* 5 | max(DR-2,0)
* 6 | max(DR-2,0)
* 7 | max(DR-3,0)
* 8 | max(DR-3,0)
*
* 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 = 1;
/* Application port */
uint8_t appPort = 2;
/*the application data transmission duty cycle. value in [ms].*/
uint32_t appTxDutyCycle = 15 * 1000;
float Temperature, Humidity, Pressure, lux, co2, tvoc;
BMP280 bmp;
Adafruit_Si7021 sensor = Adafruit_Si7021();
/*!
\brief Prepares the payload of the frame
*/
static void PrepareTxFrame( uint8_t port )
{
pinMode(Vext, OUTPUT);
digitalWrite(Vext, LOW);
//delay(500);
bmp.begin();
//delay(100);
//Temperature = bmp.readTemperature();
//Pressure = bmp.readPressure()/100.0;
Temperature = sensor.readTemperature();
Humidity = sensor.readHumidity();
Wire.end();
digitalWrite(Vext, HIGH);
uint16_t BatteryVoltage = getBatteryVoltage();
unsigned char *puc;
puc = (unsigned char *)(&Temperature);
appDataSize = 26;//AppDataSize max value is 64
appData[0] = puc[0];
appData[1] = puc[1];
appData[2] = puc[2];
appData[3] = puc[3];
puc = (unsigned char *)(&Humidity);
appData[4] = puc[0];
appData[5] = puc[1];
appData[6] = puc[2];
appData[7] = puc[3];
puc = (unsigned char *)(&Pressure);
appData[8] = puc[0];
appData[9] = puc[1];
appData[10] = puc[2];
appData[11] = puc[3];
appData[12] = (uint8_t)(BatteryVoltage >> 8);
appData[13] = (uint8_t)BatteryVoltage;
Serial.print("T=");
Serial.print(Temperature);
Serial.print("C, RH=");
Serial.print(Humidity);
Serial.print(" lx, Pressure=");
Serial.print(Pressure);
Serial.print(", BatteryVoltage:");
Serial.println(BatteryVoltage);
}
void setup() {
boardInitMcu( );
Serial.begin(115200);
deviceState = DEVICE_STATE_INIT;
//LoRaWAN.ifskipjoin(); // what does this actually do?
}
void loop()
{
switch ( deviceState )
{
case DEVICE_STATE_INIT:
{
Serial.printf("LoRaWan Class%X start! \r\n", loraWanClass + 10);
#if(AT_SUPPORT)
enableAt();
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;
}
}
}