-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRuuviTag.json
113 lines (113 loc) · 4.32 KB
/
RuuviTag.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
[
{
"id": "c0199faeda68aec9",
"type": "inject",
"z": "4e7f71c7d2330428",
"name": "Test Data",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"data\": \"0201061BFF99040512FC5394C37C0004FFFC040CAC364200CDCBB8334C884F\"}",
"payloadType": "json",
"x": 400,
"y": 40,
"wires": [
[
"fd9f38d8d7415a26"
]
]
},
{
"id": "fd9f38d8d7415a26",
"type": "function",
"z": "4e7f71c7d2330428",
"name": "",
"func": "let str = msg.payload.data;\nconst data = {};\n\n//type\nlet part1 = \"0x\" + str[14] + str[15] ;\ndata.type = parseInt(part1);\n\n//temperature\nlet part2 = \"0x\" + str[16] + str[17] + str[18] + str[19];\ntemperature = parseInt(part2);\n if (temperature > 32767) {\n temperature -= 65534;\n }\ndata.temperature = temperature * 0.005;\n\n//humidity\nlet part3 = \"0x\" + str[20] + str[21] + str[22] + str[23];\ndata.humidity = parseInt(part3) / 400.0;\n\n//pressure\nlet part4 = \"0x\" + str[24] + str[25] + str[26] + str[27];\ndata.pressure = parseInt(part4) + 50000;\n\n//accelerometer\n//X\nlet part5 = \"0x\" + str[28] + str[29] + str[30] + str[31];\naccelerationX = parseInt(part5);\nif (accelerationX > 32767) accelerationX -= 65536; // two's complement\ndata.accelerationX = accelerationX /1000;\n//Y\nlet part6 = \"0x\" + str[32] + str[33] + str[34] + str[35];\naccelerationY = parseInt(part6);\nif (accelerationY > 32767) accelerationY -= 65536;\ndata.accelerationY = accelerationY /1000;\n//Z\nlet part7 = \"0x\" + str[36] + str[37] + str[38] + str[39];\naccelerationZ = parseInt(part7);\nif (accelerationZ > 32767) accelerationZ -= 65536; // two's complement\ndata.accelerationZ = accelerationZ /1000\n\n//Power\nlet part8 = \"0x\" + str[40] + str[41] + str[42] + str[43];\nlet power = parseInt(part8).toString(2);\nvoltage = power.substr(0, 11);\nTXdbm = power.slice(-5);\ndata.voltage = (parseInt(voltage, 2) + 1600) / 1000;\ndata.TXdbm = (parseInt(TXdbm, 2) & 0b11111) * 2 - 40;\n\n//movementCounter\nlet part9 = \"0x\" + str[44] + str[45];\ndata.movementCounter = parseInt(part9);\n\n//measurementSequenceNumber\nlet part10 = \"0x\" + str[46] + str[47] + str[48] + str[49];\ndata.measurementSequenceNumber = parseInt(part10);\n\n//mac\nlet part11 = str.slice(-12);\ndata.mac = part11;\n\nmsg.payload = data\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 80,
"wires": [
[
"cfb6a14adddababb"
]
]
},
{
"id": "cfb6a14adddababb",
"type": "debug",
"z": "4e7f71c7d2330428",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 730,
"y": 80,
"wires": []
},
{
"id": "c2515322ba5f69aa",
"type": "inject",
"z": "4e7f71c7d2330428",
"name": "Min Data",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"data\": \"0201061BFF9904058001000000008001800180010000000000CBB8334C884F\"}",
"payloadType": "json",
"x": 400,
"y": 80,
"wires": [
[
"fd9f38d8d7415a26"
]
]
},
{
"id": "548889d816ae0fa9",
"type": "inject",
"z": "4e7f71c7d2330428",
"name": "Max Data",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"data\": \"0201061BFF9904057FFFFFFEFFFE7FFF7FFF7FFFFFDEFEFFFECBB8334C884F\"}",
"payloadType": "json",
"x": 400,
"y": 120,
"wires": [
[
"fd9f38d8d7415a26"
]
]
}
]