Box opening - no video

Thx Jac, you are right, that was “raw message”
I had to activate the javascript formatter first
image
and then the message was shown
image
Thx!
now I need to play around with the sensors

1 Like

There isn’t a JS formatter in the device repository so unless you entered a formatter that would have no effect. All’s that happened here is you’ve looked on the application / device console where the payload is decoded for you.

Have you used the v2 stack much?

Hi Nick, I see, you are right. I am quite familiar with V2, mixed the “payload” and “Raw payload” in V3.

now i’m trying to add read temperature and send over lora

but while debugging, i see the SHT is not initializing, i see there might be a reported issue

will continue next weekend :slight_smile: Unless Nick has a hint

@Baxter @descartes a while back I made a hacky branch to add temperature humidity readings and send them over LoRaWAN. The app name is called "basic_lorawan_th.
This is where all the action happens:
generic-node-se/lora_app.c at feature/basic_lorawan_TH · TheThingsIndustries/generic-node-se (github.com)

static void SendTxData(void)
{
  UTIL_TIMER_Time_t nextTxIn = 0;

  UTIL_TIMER_Create(&TxLedTimer, 0xFFFFFFFFU, UTIL_TIMER_ONESHOT, OnTimerLedEvent, NULL);
  UTIL_TIMER_SetPeriod(&TxLedTimer, 200);
  UTIL_TIMER_Start(&TxLedTimer);


  // User can add any indication here (LED manipulation or Buzzer)
  GNSE_BSP_LED_Toggle(LED_BLUE);
  GNSE_BSP_Sensor_I2C1_Init();

  sensirion_i2c_init(); // placefiller function

  int32_t temperature = 0;
  int32_t humidity = 0;
  int16_t status = 0;
  uint16_t temp_int = 0;
  uint16_t humidity_int = 0;

  if (SHTC3_probe() != SHTC3_STATUS_OK)
  {
      APP_PPRINTF("\r\n Failed to initialize SHTC3 Sensor, entering error state\r\n");
      GNSE_BSP_LED_On(LED_RED);
      while (1)
      {
      }
  }

  status = SHTC3_measure_blocking_read(&temperature, &humidity);
    if (status == SHTC3_STATUS_OK)
    {
        //Remove the division by 1000 to observe the higher resolution
        APP_PPRINTF("\r\n Measured Temperature: %d'C & Relative Humidity: %d \r\n", temperature/100, humidity/100);
    }
    else
    {
        APP_PPRINTF("\r\n Failed to read data from SHTC3 sensor, Error status: %d \r\n", status);
        GNSE_BSP_LED_On(LED_RED);
        while (1)
        {
        }
    }

  temp_int = (uint16_t)((temperature/100)+400); // add offset value for the temp
  humidity_int = (uint16_t)(humidity/100);


  AppData.Port = LORAWAN_APP_PORT;
  AppData.BufferSize = 5;
  AppData.Buffer[0] = (uint8_t)(temp_int >> 8 );       // HI byte
  AppData.Buffer[1] = (uint8_t)(temp_int & 0xFF);      // LO byte
  AppData.Buffer[2] = (uint8_t)(humidity_int >> 8 );   // HI byte 2
  AppData.Buffer[3] = (uint8_t)(humidity_int & 0xFF);  // LO byte 2
  AppData.Buffer[4] = 0xAA; // placeholder


  if (LORAMAC_HANDLER_SUCCESS == LmHandlerSend(&AppData, LORAWAN_DEFAULT_CONFIRMED_MSG_STATE, &nextTxIn, false))
  {
    APP_LOG(TS_ON, VLEVEL_L, "SEND REQUEST\r\n");
  }
  else if (nextTxIn > 0)
  {
    APP_LOG(TS_ON, VLEVEL_L, "Next Tx in  : ~%d second(s)\r\n", (nextTxIn / 1000));
  }
}

And simple payload formatter looked like this:

function decodeUplink(input) {
  var data = {};
  data.temperature = ((input.bytes[0] << 8) + input.bytes[1]-400)/10;
  data.humidity = ((input.bytes[2] << 8) + input.bytes[3])/10;
  return {
    data: data,
  };
}
1 Like

Thanks Orkhan, works like a charm!
Also love the +400 for temperature, helps get along with temps below zero!
image

1 Like

I got a bit confused with the debug log!

Measured Temperature: 194'C & Relative Humidity: 605

I am confused about the superloop, the green LED is on very often very long… (I changed the colors), but the data init of SHT, the TX and the data flow are excellent.

MX_LoRaWAN_Init();

while (1)
{
MX_LoRaWAN_Process();
GNSE_BSP_LED_Toggle(LED_GREEN); // GREEN indicates the superloop, blue indicates LoRaWAN TXs.
}
}

image