Combine CayenneLPP with arduino-lmic

Hi everyone,

I would like to ask you for your opinion about combine these two libraries, here is my sketch The point that I’m not sure is where I send the CayenneLPP buffer using the LMIC_setTxData2() function provided by arduino-lmic library. I’m not sure this is correct because I’m receiving the data in the TTN console in a strange way.

  • Firstly I’m receiving some negative values
  • Secondly I’d say those are not in the [0, 1023] range (which I guess should be the range for the acquired signal)

Captura de pantalla_2020-06-25_10-49-41

What could be causing these two things? I need CayenneLPP because is the data model supported by FIWARE, However … I like how arduino-lmic library transmits to my gateway. Some suggestions?

Thank you all.

The payload data looks OK, channel 1 with data type 2 (analog input). Keep in mind that this data type can only encode from -327.68 up to 327.67. The raw 16-bit data value is in 2-complement, so values larger than 327.67 will appear as negative values.

If you want to encode something bigger, you need to pick a Cayenne different data type. I don’t know of a cayenne data type than can encode a number 0…1023 though. Perhaps you can “abuse” the illuminance sensor data type.

1 Like

@bertrik did you read that in here? I don’t see that info about this data type (I mean the thing that can only encode from -327.68 up to 327.67) I’ll appreciate the source :smile:

Thank you anyway :slight_smile:

Yes, I infered it from that. The raw value is encoded as a number encoded in 2 bytes (16 bits signed) with a unit of 0.01. In 16 bits signed you can represent numbers from -32768 until 32767, so with a unit of 0.01, that amounts to a range from -327.68 to +327.67

1 Like

You could just map the 0…1023 arduino ADC range to (for example) 0…100.0, something like
potVal = 100.0 * potVal / 1023;

The range 0…100.0 will fit in the range that can be encoded in Cayenne.

1 Like