Events

:

:

Elektronik | Funk | Software

Der Technik-Blog

  • Social Media

    Werbung:


    New Posts


    Events

    • Keine zukünftigen Events vorhanden

    The Tech-Blog

    Zenner RWM3 Payload Decoder

    Smoke Detector Payload Decoder

    Alex @ AEQ-WEB

    This page contains the payload decoder and test data for the Zenner Easy Protect smoke detector RWM3 for integration into The Things Network (TTN). More information about the product and the decoder is also available on our german YouTube channel part 1 and part 2.

    Note: This decoder has been tested and checked with two smoke detectors. No warranty is given for possible errors or malfunctions.


    Werbung:

    Decoder Script

    The decoder was developed based on the payload documentation provided by the manufacturer. The script was tested with two smoke detectors in TTNs LoRaWAN network. In addition, the decoder always provides a Boolean value (smoke_detection) about a smoke alarm with True/False in addition to various status information.

    1. /**
    2.  * Decoder for Zenner smoke detector (Easy Protect Rauchwarnmelder RWM3)
    3.  * More information: https://www.aeq-web.com/zenner-smoke-detector-rauch-warn-melder-3-payload-decoder/
    4.  * Version 1.2
    5.  */
    6. function Decoder(bytes, port) {
    7.  
    8. var packet = bytes[0];
    9. var packetType = (packet >> 4) & 0x0F;
    10. var packetSubtype = packet & 0x0F;
    11. var smokeDetection = false;
    12. var packetMessage = "unkown";
    13.  
    14. if (packetType == 9) {
    15.  
    16. if (packetSubtype == 2) {
    17. var firmwareVersion = "V" + bytes[4] + "." + bytes[3] + "." + bytes[2]
    18. var lorawanVersion = "V" + bytes[7] + "." + bytes[6] + "." + bytes[5]
    19. var lorawanCmdVersion = "V" + bytes[9] + "." + bytes[8]
    20. packetMessage = "SP9_02 (startup)";
    21.  
    22. return_data = {
    23. message: packetMessage,
    24. firmware_version: firmwareVersion,
    25. lorawan_version: lorawanVersion,
    26. lw_comand_version: lorawanCmdVersion,
    27. smoke_detection: smokeDetection
    28. }
    29. } else if (packetSubtype == 1 && (bytes[1] == convertToDec("CA") || bytes[1] == convertToDec("CE"))) {
    30. //LoRaWAN com. scenario
    31. if (bytes[1] == convertToDec("CA")) {
    32. packetMessage = "Smoke alarm via LoRaWAN is disabled";
    33. } else if (bytes[1] == convertToDec("CE")) {
    34. packetMessage = "Smoke alarm via LoRaWAN is enabled";
    35. } else {
    36. packetMessage = "unkown message";
    37. }
    38.  
    39. return_data = {
    40. message: packetMessage,
    41. smoke_detection: smokeDetection
    42. }
    43. } else if (packetSubtype == 1) {
    44.  
    45. var dateTime = convertDateTime(bytes[4], bytes[3], bytes[2], bytes[1]);
    46. var statusCode = bytes[6] << 8 | bytes[5];
    47.  
    48. packetMessage = "SP9_01 (status)";
    49.  
    50. return_data = {
    51. message: packetMessage,
    52. datetime: dateTime,
    53. status: statusCode,
    54. smoke_detection: smokeDetection
    55. }
    56. } else {
    57.  
    58. packetMessage = "SP9 (unkown subtype)";
    59.  
    60. return_data = {
    61. message: packetMessage,
    62. smoke_detection: smokeDetection
    63. }
    64. }
    65.  
    66. } else if (packetType == 1) {
    67.  
    68. var mValue = bytes[4] << 24 | bytes[3] << 16 | bytes[2] << 8 | bytes[1];
    69. packetMessage = "SP1 (daily message)";
    70.  
    71. return_data = {
    72. message: packetMessage,
    73. value: mValue,
    74. smoke_detection: smokeDetection
    75. }
    76. } else if (packetType == convertToDec("A")) {
    77.  
    78. var eventDate = convertDate(bytes[4], bytes[3]);
    79.  
    80.  
    81. if (bytes[1] == convertToDec(19)) {
    82. smokeDetection = true;
    83. packetMessage = "Smoke detection alarm";
    84. } else if (bytes[1] == convertToDec(2)) {
    85. packetMessage = "Smoke detector removed from holder";
    86. } else if (bytes[1] == convertToDec("1C")) {
    87. packetMessage = "Object close to the sensor";
    88. }
    89.  
    90. return_data = {
    91. message: packetMessage,
    92. date: eventDate,
    93. smoke_detection: smokeDetection
    94. }
    95. } else if (bytes[0] == convertToDec("FE") && bytes[1] == convertToDec(92)) {
    96.  
    97. packetMessage = "Message via LoRaWAN will be sent when smoke detection triggers";
    98.  
    99. return_data = {
    100. message: packetMessage,
    101. smoke_detection: smokeDetection
    102. }
    103. } else {
    104.  
    105. return_data = {
    106. error: "Packet type is unkown!"
    107. }
    108. }
    109.  
    110. function convertToDec(b) {
    111. var return_value = parseInt(b, 16);
    112. return return_value;
    113. }
    114.  
    115. function convertDate(b0, b1) {
    116. var day = "0" + (b1 & 0x1F);
    117. var mon = "0" + (b0 & 0x0F);
    118. var year = ((b1 & 0xE0) >> 5) | ((b0 & 0xF0) >> 1);
    119. var date = day.substr(-2) + "-" + mon.substr(-2) + "-20" + year;
    120. return date;
    121. }
    122.  
    123. function convertDateTime(b0, b1, b2, b3) {
    124. var day = "0" + (b1 & 0x1F);
    125. var mon = "0" + (b0 & 0x0F);
    126. var year = ((b1 & 0xE0) >> 5) | ((b0 & 0xF0) >> 1);
    127. var hour = "0" + (b2 & 0x1F);
    128. var min = "0" + (b3 & 0x3F);
    129. var datetime = day.substr(-2) + "-" + mon.substr(-2) + "-20" + year + " " + hour.substr(-2) + ":" + min.substr(-2);
    130. return datetime;
    131. }
    132.  
    133. return return_data
    134. }

    Payload test data

    The following payload data sets were recorded from a smoke detector and can be tested with the payload simulator at TTN:

    Werbung:

    Initial activation status packet:

    921C001402020001200008FFFFFFFF0000

    Smoke detection alarm packet:

    a01900ec29

    Query if alarm is also sent via LoRaWAN (DL: 91677E):

    Smoke alarm feedback via LoRaWAN is on:

    91ca00

    Smoke alarm feedback via LoRaWAN is off:

    91ce00

    Feedback after activation of LoRaWAN alarm packet (DL: 92CE0064A1) :

    FE92


    Info: This page was automatically translated and may contain errors
    122X122

    About the Author

    Alex, the founder of AEQ-WEB. He works for more of 10 years with different computers, microcontroller and semiconductors. In addition to hardware projects, he also develops websites, apps and software for computers.

    Top articles in this category:

    Vaisala RS41 Radiosonde Firmware Flash

    Radiosonde RS41 Firmware Flash

    • Video
    • DE/EN

    Every day hundreds of meteorological radiosondes fall from the sky. In this article we convert a radiosonde into a GPS tracker for APRS, RTTY & CW

    read more
    LHT65 TTN V3 Webhook PHP Webapp

    LHT65 TTN V3 Webapp

    • DE/EN

    The Things Network only handles the transport of LoRaWAN packets, but not the storage. This is about the integration of a webapp.

    read more

    Social Media

    Werbung:


    New Posts


    Events

    • Keine zukünftigen Events vorhanden