node-red-contrib-periph-light 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # node-red-contrib-periph-light
2
2
 
3
- Node-RED nodes for light sensor chips: APDS-9930, APDS9250, APDS9960, BH1750, MAX44009, SI1132, SI1133, SI1145 — part of the [Periph](https://github.com/tuhde/Periph) library.
3
+ Node-RED nodes for light sensor chips: APDS-9930, APDS9250, APDS9960, BH1750, MAX44009, SI1132, SI1133, SI1145, TSL2561, TSL2591, VCNL4040, VCNL4200 — part of the [Periph](https://github.com/tuhde/Periph) library.
4
4
 
5
- **Supported chips (8):** APDS9930, APDS9250, APDS9960, BH1750, MAX44009, SI1132, SI1133, SI1145.
5
+ **Supported chips (12):** APDS9930, APDS9250, APDS9960, BH1750, MAX44009, SI1132, SI1133, SI1145, TSL2561, TSL2591, VCNL4040, VCNL4200.
6
6
 
7
7
  Each chip has a sensor/actuator node plus a shared `-device` config node that holds the bus settings. Importable example flows are in [`examples/`](https://github.com/tuhde/Periph/tree/main/nodejs/packages/node-red-contrib-periph-light/examples).
8
8
 
@@ -36,6 +36,14 @@ npm install node-red-contrib-periph-light
36
36
  | `si1133` | input | Reads the raw UV and white-light counts from a Silicon Labs Si1133 over I²C (address 0x55 or 0x52) with one forced measurement per message. |
37
37
  | `si1145-device` | config | I²C bus and address for a SI1145 |
38
38
  | `si1145` | input | Reads proximity, UV index and ambient light from a Silicon Labs Si1145 over I²C (address 0x60) with one forced PS + ALS measurement per message. |
39
+ | `tsl2561-device` | config | I²C bus and address for a TSL2561 |
40
+ | `tsl2561` | input | Reads the illuminance and both channel counts of a TSL2561 two-channel ambient light sensor (I²C, visible + infrared and infrared photodiodes). |
41
+ | `tsl2591-device` | config | Bus configuration for a TSL2591 |
42
+ | `tsl2591` | input | Reads the illuminance and both channel counts of a TSL2591 very-high-sensitivity ambient light sensor (I²C address 0x29, visible + infrared and infrared photodiodes, dynamic range about 600 000 000 : 1). |
43
+ | `vcnl4040-device` | config | Bus configuration for a VCNL4040 |
44
+ | `vcnl4040` | input | Reads the proximity, ambient light and white channel of a Vishay VCNL4040 proximity sensor with ambient light sensor (I²C address 0x60, internal 940 nm IRED, 16-bit ALS). |
45
+ | `vcnl4200-device` | config | Bus configuration for a VCNL4200 |
46
+ | `vcnl4200` | input | Reads the proximity, ambient light and white channel of a Vishay VCNL4200 long-distance proximity and ambient light sensor (I²C address 0x51, external 940 nm IRED on the on-chip current sink, 16-bit ALS). |
39
47
 
40
48
  ## Links
41
49
 
@@ -0,0 +1,174 @@
1
+ [
2
+ {
3
+ "id": "tab-tsl2561-demo",
4
+ "type": "tab",
5
+ "label": "TSL2561 Light Meter Demo",
6
+ "disabled": false,
7
+ "info": "Light meter on a TSL2561 two-channel ambient light sensor. An inject node fires every 2 s into tsl2561 (auto-range on the config node); a function node splits the reading: output 1 carries the lux for a gauge, output 2 the lux for a chart, and a debug node shows the full {lux, ch0, ch1} payload. The gauge and chart need node-red-dashboard."
8
+ },
9
+ {
10
+ "id": "inj-read",
11
+ "type": "inject",
12
+ "name": "Read every 2 s",
13
+ "topic": "",
14
+ "payload": "",
15
+ "payloadType": "date",
16
+ "repeat": "2",
17
+ "crontab": "",
18
+ "once": true,
19
+ "onceDelay": 1,
20
+ "z": "tab-tsl2561-demo",
21
+ "x": 150,
22
+ "y": 140,
23
+ "wires": [
24
+ [
25
+ "tsl2561-node"
26
+ ]
27
+ ]
28
+ },
29
+ {
30
+ "id": "tsl2561-device-1",
31
+ "type": "tsl2561-device",
32
+ "name": "TSL2561",
33
+ "bus": "1",
34
+ "address": "0x39",
35
+ "gain": "auto",
36
+ "integration": "402",
37
+ "package": "T"
38
+ },
39
+ {
40
+ "id": "tsl2561-node",
41
+ "type": "tsl2561",
42
+ "name": "TSL2561",
43
+ "z": "tab-tsl2561-demo",
44
+ "x": 360,
45
+ "y": 140,
46
+ "wires": [
47
+ [
48
+ "fn-split",
49
+ "dbg-tsl2561"
50
+ ]
51
+ ],
52
+ "device": "tsl2561-device-1"
53
+ },
54
+ {
55
+ "id": "fn-split",
56
+ "type": "function",
57
+ "name": "split lux",
58
+ "func": "// Output 1: lux for the gauge, output 2: lux for the chart.\nconst lux = Math.round(msg.payload.lux * 10) / 10;\nreturn [{ payload: lux }, { payload: lux, topic: 'lux' }];",
59
+ "outputs": 2,
60
+ "noerr": 0,
61
+ "z": "tab-tsl2561-demo",
62
+ "x": 560,
63
+ "y": 120,
64
+ "wires": [
65
+ [
66
+ "gauge-lux"
67
+ ],
68
+ [
69
+ "chart-lux"
70
+ ]
71
+ ]
72
+ },
73
+ {
74
+ "id": "gauge-lux",
75
+ "type": "ui_gauge",
76
+ "name": "Illuminance",
77
+ "group": "tsl2561-group-1",
78
+ "order": 1,
79
+ "width": 6,
80
+ "height": 4,
81
+ "gtype": "gage",
82
+ "title": "Illuminance",
83
+ "label": "lx",
84
+ "format": "{{value}}",
85
+ "min": "0",
86
+ "max": "2000",
87
+ "colors": [
88
+ "#1e3a8a",
89
+ "#e6e600",
90
+ "#ffffff"
91
+ ],
92
+ "seg1": "300",
93
+ "seg2": "1000",
94
+ "className": "",
95
+ "z": "tab-tsl2561-demo",
96
+ "x": 780,
97
+ "y": 100,
98
+ "wires": []
99
+ },
100
+ {
101
+ "id": "chart-lux",
102
+ "type": "ui_chart",
103
+ "name": "Lux history",
104
+ "group": "tsl2561-group-1",
105
+ "order": 2,
106
+ "width": 6,
107
+ "height": 4,
108
+ "label": "Illuminance (lx)",
109
+ "chartType": "line",
110
+ "legend": "false",
111
+ "xformat": "HH:mm:ss",
112
+ "interpolate": "linear",
113
+ "nodata": "",
114
+ "dot": false,
115
+ "ymin": "0",
116
+ "ymax": "",
117
+ "removeOlder": 10,
118
+ "removeOlderPoints": "",
119
+ "removeOlderUnit": "60",
120
+ "cutout": 0,
121
+ "useOneColor": false,
122
+ "colors": [
123
+ "#C084FC",
124
+ "#aec7e8",
125
+ "#ff7f0e",
126
+ "#2ca02c",
127
+ "#98df8a",
128
+ "#d62728",
129
+ "#ff9896",
130
+ "#9467bd",
131
+ "#c5b0d5"
132
+ ],
133
+ "outputs": 1,
134
+ "useDifferentColor": false,
135
+ "className": "",
136
+ "z": "tab-tsl2561-demo",
137
+ "x": 780,
138
+ "y": 160,
139
+ "wires": [
140
+ []
141
+ ]
142
+ },
143
+ {
144
+ "id": "dbg-tsl2561",
145
+ "type": "debug",
146
+ "name": "lux / ch0 / ch1",
147
+ "active": true,
148
+ "tosidebar": true,
149
+ "console": false,
150
+ "tostatus": false,
151
+ "complete": "payload",
152
+ "targetType": "msg",
153
+ "z": "tab-tsl2561-demo",
154
+ "x": 580,
155
+ "y": 200,
156
+ "wires": []
157
+ },
158
+ {
159
+ "id": "tsl2561-group-1",
160
+ "type": "ui_group",
161
+ "name": "TSL2561 Light Meter",
162
+ "tab": "tsl2561-ui-tab-1",
163
+ "order": 1,
164
+ "disp": true,
165
+ "width": 6
166
+ },
167
+ {
168
+ "id": "tsl2561-ui-tab-1",
169
+ "type": "ui_tab",
170
+ "name": "TSL2561 Demo",
171
+ "icon": "dashboard",
172
+ "order": 1
173
+ }
174
+ ]
@@ -0,0 +1,126 @@
1
+ [
2
+ {
3
+ "id": "tab-tsl2591-demo",
4
+ "type": "tab",
5
+ "label": "TSL2591 Light Meter Demo",
6
+ "disabled": false,
7
+ "info": "Wide-range light meter on a TSL2591 very-high-sensitivity ambient light sensor (I²C 0x29). An inject node fires every 2 s into tsl2591; the config node uses auto-gain, so the reading stays valid from darkness to direct sunlight. A function node formats the lux as text (e.g. \"120.5 lx\") for the status line and passes the numeric value to a gauge; a debug node shows the full {lux, ch0, ch1} payload. Cover and uncover the sensor to watch the gain change and the lux follow. Pick a fixed gain or a longer integration time on the config node to compare; the gauge needs node-red-dashboard."
8
+ },
9
+ {
10
+ "id": "inj-read",
11
+ "type": "inject",
12
+ "name": "Read every 2 s",
13
+ "topic": "",
14
+ "payload": "",
15
+ "payloadType": "date",
16
+ "repeat": "2",
17
+ "crontab": "",
18
+ "once": true,
19
+ "onceDelay": 1,
20
+ "z": "tab-tsl2591-demo",
21
+ "x": 150,
22
+ "y": 140,
23
+ "wires": [
24
+ [
25
+ "tsl2591-node"
26
+ ]
27
+ ]
28
+ },
29
+ {
30
+ "id": "tsl2591-device-1",
31
+ "type": "tsl2591-device",
32
+ "name": "TSL2591",
33
+ "bus": "1",
34
+ "gain": "auto",
35
+ "integration": "0"
36
+ },
37
+ {
38
+ "id": "tsl2591-node",
39
+ "type": "tsl2591",
40
+ "name": "TSL2591",
41
+ "z": "tab-tsl2591-demo",
42
+ "x": 360,
43
+ "y": 140,
44
+ "wires": [
45
+ [
46
+ "fn-format",
47
+ "dbg-tsl2591"
48
+ ]
49
+ ],
50
+ "device": "tsl2591-device-1"
51
+ },
52
+ {
53
+ "id": "fn-format",
54
+ "type": "function",
55
+ "name": "format lux",
56
+ "func": "// Show \"120.5 lx\" as status and send the number to the gauge.\nconst lux = Math.round(msg.payload.lux * 10) / 10;\nnode.status({ text: lux.toFixed(1) + ' lx' });\nreturn { payload: lux, topic: 'lux' };",
57
+ "outputs": 1,
58
+ "noerr": 0,
59
+ "z": "tab-tsl2591-demo",
60
+ "x": 560,
61
+ "y": 120,
62
+ "wires": [
63
+ [
64
+ "gauge-lux"
65
+ ]
66
+ ]
67
+ },
68
+ {
69
+ "id": "gauge-lux",
70
+ "type": "ui_gauge",
71
+ "name": "Illuminance",
72
+ "group": "tsl2591-group-1",
73
+ "order": 1,
74
+ "width": 6,
75
+ "height": 4,
76
+ "gtype": "gage",
77
+ "title": "Illuminance",
78
+ "label": "lx",
79
+ "format": "{{value}}",
80
+ "min": "0",
81
+ "max": "2000",
82
+ "colors": [
83
+ "#1e3a8a",
84
+ "#e6e600",
85
+ "#ffffff"
86
+ ],
87
+ "seg1": "300",
88
+ "seg2": "1000",
89
+ "className": "",
90
+ "z": "tab-tsl2591-demo",
91
+ "x": 780,
92
+ "y": 120,
93
+ "wires": []
94
+ },
95
+ {
96
+ "id": "dbg-tsl2591",
97
+ "type": "debug",
98
+ "name": "lux / ch0 / ch1",
99
+ "active": true,
100
+ "tosidebar": true,
101
+ "console": false,
102
+ "tostatus": false,
103
+ "complete": "payload",
104
+ "targetType": "msg",
105
+ "z": "tab-tsl2591-demo",
106
+ "x": 580,
107
+ "y": 200,
108
+ "wires": []
109
+ },
110
+ {
111
+ "id": "tsl2591-group-1",
112
+ "type": "ui_group",
113
+ "name": "TSL2591 Light Meter",
114
+ "tab": "tsl2591-ui-tab-1",
115
+ "order": 1,
116
+ "disp": true,
117
+ "width": 6
118
+ },
119
+ {
120
+ "id": "tsl2591-ui-tab-1",
121
+ "type": "ui_tab",
122
+ "name": "TSL2591 Demo",
123
+ "icon": "dashboard",
124
+ "order": 1
125
+ }
126
+ ]
@@ -0,0 +1,196 @@
1
+ [
2
+ {
3
+ "id": "tab-vcnl4040-demo",
4
+ "type": "tab",
5
+ "label": "VCNL4040 Presence Light Demo",
6
+ "disabled": false,
7
+ "info": "Presence-activated display light on a VCNL4040 proximity and ambient light sensor (I²C 0x60). An inject node fires every 200 ms into vcnl4040. A function node applies a close/away hysteresis to the proximity count (close above 1000, away below 300 counts) and only passes a message when the state changes; a switch node routes 'close' to a \"wake display\" message and 'away' to a \"dim display\" message. A second debug node shows the ambient light in lux. Move a hand towards the sensor to wake the display; adjust the thresholds in the function node for your cover glass and target."
8
+ },
9
+ {
10
+ "id": "inj-read",
11
+ "type": "inject",
12
+ "name": "Read every 200 ms",
13
+ "topic": "",
14
+ "payload": "",
15
+ "payloadType": "date",
16
+ "repeat": "0.2",
17
+ "crontab": "",
18
+ "once": true,
19
+ "onceDelay": 1,
20
+ "z": "tab-vcnl4040-demo",
21
+ "x": 150,
22
+ "y": 140,
23
+ "wires": [
24
+ [
25
+ "vcnl4040-node"
26
+ ]
27
+ ]
28
+ },
29
+ {
30
+ "id": "vcnl4040-device-1",
31
+ "type": "vcnl4040-device",
32
+ "name": "VCNL4040",
33
+ "bus": "1",
34
+ "integration": "80",
35
+ "current": "100",
36
+ "resolution": "16"
37
+ },
38
+ {
39
+ "id": "vcnl4040-node",
40
+ "type": "vcnl4040",
41
+ "name": "VCNL4040",
42
+ "z": "tab-vcnl4040-demo",
43
+ "x": 360,
44
+ "y": 140,
45
+ "wires": [
46
+ [
47
+ "fn-hysteresis",
48
+ "fn-lux"
49
+ ]
50
+ ],
51
+ "device": "vcnl4040-device-1"
52
+ },
53
+ {
54
+ "id": "fn-hysteresis",
55
+ "type": "function",
56
+ "name": "close/away hysteresis",
57
+ "func": "// Close above 1000 counts, away below 300; only report changes.\nconst CLOSE = 1000, AWAY = 300;\nconst p = msg.payload.proximity;\nlet state = context.get('state') || 'away';\nif (state === 'away' && p > CLOSE) state = 'close';\nelse if (state === 'close' && p < AWAY) state = 'away';\nelse return null;\ncontext.set('state', state);\nnode.status({ text: state + ' (' + p + ')' });\nreturn { payload: state, topic: 'presence' };",
58
+ "outputs": 1,
59
+ "noerr": 0,
60
+ "z": "tab-vcnl4040-demo",
61
+ "x": 580,
62
+ "y": 120,
63
+ "wires": [
64
+ [
65
+ "sw-state"
66
+ ]
67
+ ]
68
+ },
69
+ {
70
+ "id": "sw-state",
71
+ "type": "switch",
72
+ "name": "close / away",
73
+ "property": "payload",
74
+ "propertyType": "msg",
75
+ "rules": [
76
+ {
77
+ "t": "eq",
78
+ "v": "close",
79
+ "vt": "str"
80
+ },
81
+ {
82
+ "t": "eq",
83
+ "v": "away",
84
+ "vt": "str"
85
+ }
86
+ ],
87
+ "checkall": "true",
88
+ "repair": false,
89
+ "outputs": 2,
90
+ "z": "tab-vcnl4040-demo",
91
+ "x": 790,
92
+ "y": 120,
93
+ "wires": [
94
+ [
95
+ "chg-wake"
96
+ ],
97
+ [
98
+ "chg-dim"
99
+ ]
100
+ ]
101
+ },
102
+ {
103
+ "id": "chg-wake",
104
+ "type": "change",
105
+ "name": "wake display",
106
+ "rules": [
107
+ {
108
+ "t": "set",
109
+ "p": "payload",
110
+ "pt": "msg",
111
+ "to": "wake display",
112
+ "tot": "str"
113
+ }
114
+ ],
115
+ "z": "tab-vcnl4040-demo",
116
+ "x": 990,
117
+ "y": 100,
118
+ "wires": [
119
+ [
120
+ "dbg-display"
121
+ ]
122
+ ]
123
+ },
124
+ {
125
+ "id": "chg-dim",
126
+ "type": "change",
127
+ "name": "dim display",
128
+ "rules": [
129
+ {
130
+ "t": "set",
131
+ "p": "payload",
132
+ "pt": "msg",
133
+ "to": "dim display",
134
+ "tot": "str"
135
+ }
136
+ ],
137
+ "z": "tab-vcnl4040-demo",
138
+ "x": 990,
139
+ "y": 140,
140
+ "wires": [
141
+ [
142
+ "dbg-display"
143
+ ]
144
+ ]
145
+ },
146
+ {
147
+ "id": "dbg-display",
148
+ "type": "debug",
149
+ "name": "display",
150
+ "active": true,
151
+ "tosidebar": true,
152
+ "console": false,
153
+ "tostatus": true,
154
+ "complete": "payload",
155
+ "targetType": "msg",
156
+ "statusVal": "payload",
157
+ "statusType": "auto",
158
+ "z": "tab-vcnl4040-demo",
159
+ "x": 1180,
160
+ "y": 120,
161
+ "wires": []
162
+ },
163
+ {
164
+ "id": "fn-lux",
165
+ "type": "function",
166
+ "name": "lux",
167
+ "func": "// Ambient light for the debug sidebar.\nreturn { payload: Math.round(msg.payload.lux * 10) / 10, topic: 'lux' };",
168
+ "outputs": 1,
169
+ "noerr": 0,
170
+ "z": "tab-vcnl4040-demo",
171
+ "x": 560,
172
+ "y": 200,
173
+ "wires": [
174
+ [
175
+ "dbg-lux"
176
+ ]
177
+ ]
178
+ },
179
+ {
180
+ "id": "dbg-lux",
181
+ "type": "debug",
182
+ "name": "lux",
183
+ "active": true,
184
+ "tosidebar": true,
185
+ "console": false,
186
+ "tostatus": true,
187
+ "complete": "payload",
188
+ "targetType": "msg",
189
+ "statusVal": "payload",
190
+ "statusType": "auto",
191
+ "z": "tab-vcnl4040-demo",
192
+ "x": 750,
193
+ "y": 200,
194
+ "wires": []
195
+ }
196
+ ]