Newbie Question about Digital and Analog values

the below cayenne properties.

#define LPP_DIGITAL_INPUT       0       // 1 byte
#define LPP_DIGITAL_OUTPUT      1       // 1 byte
#define LPP_ANALOG_INPUT        2       // 2 bytes, 0.01 signed
#define LPP_ANALOG_OUTPUT       3       // 2 bytes, 0.01 signed

Does this mean for digital( I/O) the only possible values are 0 and 1.

but for Analog what is the range of possible values?

that is the data type value in cayenne LPP. read more about it here Cayenne Docs

1 Like

Thanks for the linkā€¦in the docā€¦this piece of code for example:

"if ((cursor + LPP_ANALOG_INPUT_SIZE) > maxsize) {
return 0;
}
"

What would be the set maxsize value for analog I/O? ā€¦Sorry for basic question Iā€™m just getting requirements for a IoT project.

you dont have to add anything for this class. you can use TTN cayenne LPP example code which simplifies the coding and can be used with much ease. arduino-device-lib/CayenneLPP.ino at master Ā· TheThingsNetwork/arduino-device-lib Ā· GitHub and add an analog input just by using:
lpp.addAnalogInput(uint8_t channel, float value); where you to add the channel and the analog value reading.

@jeryl.cook From the github repository I see #define LPP_ANALOG_INPUT_SIZE 4 // 2 bytes, 0.01 signed and #define LPP_ANALOG_OUTPUT_SIZE 4 // 2 bytes, 0.01 signed Since itā€™s signed 0.01 that would make the min/max -327.68 to 327.67. If you need larger ranges you can try Energy and Concentration data types. Let me know if that answers your question.

2 Likes

yes that answers my question!..:grinning:

I did do a bit of research on why last night it is 2 bytes long, thatā€™s 16 bits. The range of a 16 bit twoā€™s complement number is from -32768 to 32767.

0.01 units to represent a single bit that gives you a range of -327.68 to 327.67. which is your answer! Thanks again.

I donā€™t see ā€œEnergy and Concentrationā€ data type in the specification?

Type IPSO LPP Hex Data Size Data Resolution per bit
Digital Input 3200 0 0 1 1
Digital Output 3201 1 1 1 1
Analog Input 3202 2 2 2 0.01 Signed
Analog Output 3203 3 3 2 0.01 Signed
Illuminance Sensor 3301 101 65 2 1 Lux Unsigned MSB
Presence Sensor 3302 102 66 1 1
Temperature Sensor 3303 103 67 2 0.1 Ā°C Signed MSB
Humidity Sensor 3304 104 68 1 0.5 % Unsigned
Accelerometer 3313 113 71 6 0.001 G Signed MSB per axis
Barometer 3315 115 73 2 0.1 hPa Unsigned MSB
Gyrometer 3334 134 86 6 0.01 Ā°/s Signed MSB per axis
GPS Location 3336 136 88 9 Latitude : 0.0001 Ā° Signed MSB
Longitude : 0.0001 Ā° Signed MSB
Altitude : 0.01 meter Signed MSB

Looks like itā€™s not in the github repository yet but it is supported now.

Concentration (ppm) - hex value 0x7D, 3 bytes unsigned
Energy (Wh) - hex value 0x83, 4 bytes unsigned

I canā€™t promise anything but Iā€™ll take a look at it when I have time and try to make a pull request to add it in.

1 Like

Understood. Thank you @adam.
I assume these are the only two new additions to the spec?

Yes, just those two. I was talking to one of the cayenne devs and that what they said. You can also manually send that payload if you want, but itā€™s just not in a convenient package yet.

1 Like

one more question lol.

There are quite a few extended datatypesā€¦are there plans to support all of the 'extended IPSO data types" in the dashboard?

@eptak Are there any plans to add these extended data types?

What scaling should be applied to Concentration and Energy?

Thanks in advance.

Sorry but when I use type ā€˜0x7Dā€™, the chirpstack tells me the wrong type, is there anything wrong?

Not sure what you mean by chirpstack tells the wrong type. But in cayenne 0x7D type is not supported. The only datatypes are from the table shared above.