ElectronicCats / CayenneLPP

Library for Arduino compatible with Cayenne Low Power Payload
http://electroniccats.com/
MIT License
106 stars 48 forks source link

Enhance frequency from int to float and have 2 digits transmitted #44

Closed g6094199 closed 1 year ago

g6094199 commented 1 year ago

hi,

i stumbled over an another unaccuracy.

atm frequency is an int

uint8_t addFrequency(uint8_t channel, uint32_t value); // in hertzs

may i ask for which cases this value is usable?

i do some reseach in the energy sector and for this purpose its VERY important to know the exact electrical energy grid frequency. alt least 1 digit will do but 2 digits would be much better.

the cause is that the electrical grid is frequency controlled and actions MUST be taken when +/-0.1hz happen.
sorry, but i dont find the adequate articles in the english wiki, only a german explaination.

for this the Frequency value must be changed to a float value.

AndreaZGuz commented 1 year ago

Hello @g6094199 !

We appreciate you bringing this issue to our attention. Truly appreciated you have taken the time out of your day. Could you please a pull request with the correction you are mentioning? I will communicate this to our Engineering Team to review your pull request and fix this as quickly as possible. If you face any issues with doing the pull request, please do not hesitate to let me know. I will be pleased to help you.

Have a great day! Kind regards.

xoseperez commented 1 year ago

Just a note on this. Cayenne is based on original IPSO data types. IPSO data structure does allow to define the unit as optional field, but since Cayenne data structure does not have an option to define the unit this specific data type (ISP 3318, CayenneLPP 118) defaults to Hertz which is the SI and ISO31-7 unit. As much as I undertand the problem, changing it to a float will cause a big backwards incompatibility issue. My suggestion is that you encode it as 0.1Hz units and decode it back in your server. If I'm not wrong, grid frequency is around 50 or 60Hz depending on where you are living so you have plenty of room for decimals in a 4 bytes value.