LMIC Unknown event: 20

now i have made some testing and i get it working :slight_smile:

here i will share the payload decoder its sure not very good code but i works for me maybe it will help other people where searching for ThingSpeak Payload decoders.

regards from Germany

function Decoder(bytes, port) {
    if(bytes.length == 1) {
        if(bytes[0] == 1) {
            return {
                'button': 'activated'
            }
        } else {
            return {
                'error': 'button action unknown'
            }   
        }
    } else if(bytes.length == 5) {
        var field2 = (bytes[0]<<8) | bytes[1];
        var field1 = (bytes[2]<<8) | bytes[3];
        var field3 = (bytes[4] +250) / 100;
        return {
            'field2': field2/100,
            'field1': field1/100,
            'field3': field3,
        }
    } else {
        return {
            'error': 'payload unknown'
        }
    }
} 

and the result:

{
  "field1": 21.6,
  "field2": 42.3,
  "field3": 2.93
}

Bildschirmfoto 2021-01-07 um 18.50.14

1 Like