TTN Smart Sensor (Browan)

Sensor

Codec Description

Codec for Browan

Codec Preview

function decodeUplink(input) { var bytes = input.bytes; // Check if the payload is empty by verifying if all elements in 'bytes' are 0 or if 'bytes' is empty var isEmptyPayload = bytes.length === 0 || bytes.every(element => element === 0); if (isEmptyPayload) { return {}; // Return an empty object if the payload is empty } switch (input.fPort) { case 106: return { data: { status: bytes[0] & 0x01, temperatureChanged: (bytes[0] >> 5) & 0x01, humidityChanged: (bytes[0] >> 6) & 0x01, battery: (25 + (bytes[1] & 0x0f)) / 10, temperatureBoard: (bytes[2] & 0x7f) - 32, humidity: bytes[3], temperature: (bytes[4] & 0x7f) - 32 } }; default: return { errors: ['unknown FPort'], }; } } 

This codec is sourced from The Things Network. All rights belong to The Things Network.

This codec is licensed under the GNU General Public License v3 (GPL v3). Modifications, if any, are clearly marked. You are free to use, modify, and distribute the codec under the terms of GPL v3.

Community Feedback