forked from ToniA/Raw-IR-decoder-for-Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZHLT01Remote.cpp
375 lines (345 loc) · 10.5 KB
/
ZHLT01Remote.cpp
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
/********************************************************************************
* Airconditional remote control decoder for:
*
* ZH/LT-01 Remote control https://www.google.com/search?q=zh/lt-01
*
* The ZH/LT-01 remote control is used for many locally branded Split airconditioners,
* so it is better to name this protocol by the name of the protocol rather then the
* name of the Airconditioner. For this project I used a Eurom-airconditioner, which is
* Dutch-branded and sold in the Netherlands at Hornbach.
*
* For airco-brands:
* Eurom
* Chigo
* Tristar
* Tecnomaster
* Elgin
* Geant
* Tekno
* Topair
* Proma
* Sumikura
* JBS
* Turbo Air
* Nakatomy
* Celestial Air
* Ager
* Blueway
* Airlux
* Etc.
*
***********************************************************************************
* SUMMARY FUNCTIONAL DESCRIPTION
**********************************************************************************
* The remote sends a 12 Byte message which contains all possible settings every
* time.
*
* Byte 11 (and 10) contain the remote control identifier and are always 0xD5 and
* 0x2A respectively for the ZH/LT-01 remote control.
* Every UNeven Byte (01,03,05,07 and 09) hold command data
* Every EVEN Byte (00,02,04,06,08 and 10) hold a checksum of the corresponding
* command-, or identifier-byte by inverting the bits, for example:
*
* The identifier byte[11] = 0xD5 = B1101 0101
* The checksum byte[10] = 0x2A = B0010 1010
*
* So, you can check the message by:
* - inverting the bits of the checksum byte with the corresponding command-, or
* identifier byte, they should me the same, or
* - Summing up the checksum byte and the corresponding command-, or identifier byte,
* they should always add up to 0xFF = B11111111 = 255
*
* Control bytes:
* [01] - Timer (1-24 hours, Off)
* [03] - LAMP ON/OFF, TURBO ON/OFF, HOLD ON/OFF
* [05] - Indicates which button the user pressed on the remote control
* [07] - POWER ON/OFF, FAN AUTO/3/2/1, SLEEP ON/OFF, AIRFLOW ON/OFF,
* VERTICAL SWING/WIND/FIXED
* [09] - MODE AUTO/COOL/VENT/DRY/HEAT, TEMPERATURE (16 - 32°C)
*
* TIMINGS
* (Both Hyundai (option 4) and Samsung (option 5) timings work)
* Space: Not used
* Header Mark: 6200 us
* Header Space: 7500 us
* Bit Mark: 475 us
* Zero Space: 525 us
* One Space: 1650 us
*
* ******************************************************************************
* Written by: Marcel van der Kooij
* Date: 2018-06-07
* Version: 1.0
*******************************************************************************/
#include <Arduino.h>
bool decodeZHLT01remote(byte *bytes, int byteCount)
{
/********************************************************************************
* Is this a ZH/LT-01 Remote?
* Message should by 12 bytes, 100 symbols.
* Remote identifier
* Byte[11]: Always 0xD5, which makes Byte[10] always 0x2A (see checksum)
*
*******************************************************************************/
if (byteCount == 12 && bytes[10] == 0x2A && bytes[11] == 0xD5) {
Serial.println(F("Looks like a ZH/LT-01 remote control protocol"));
/*******************************************************************************
* Byte[01]: Timer (1-24 hours, Not used, Off, Changed, Set)
* TIMER ON/OFF: B1xxxxxxx
* TIMER CHANGED: Bxx1xxxxx
*
* Number of hours is determined by bit0-4:
* 0x01 = 1 hour
* 0x18 = 24 hours
*******************************************************************************/
Serial.print(F("bytes[1] bit5-7 Timer: "));
switch (bytes[1] & B10100000) {
case 0x00:
Serial.println(F("Not used"));
break;
case B00100000:
Serial.println(F("Off"));
break;
case B10000000:
Serial.println(F("Set"));
break;
case B10100000:
Serial.println(F("Changed"));
break;
default:
Serial.println("Unknown");
}
Serial.print(F("bytes[1] bit0-4 Hours: "));
Serial.println(bytes[1] & B00011111);
/********************************************************************************
* Byte[03]: LAMP, TURBO, HOLD ON/OFF
* LAMP ON: Bxxxxxxx1 (bit0)
* LAMP OFF: Bxxxxxxx0
* HOLD ON: Bxxxxx1xx (bit2)
* HOLD ON: Bxxxxx0xx
* TURBO ON: Bxxxx1xxx (bit3)
* TURBO ON: Bxxxx0xxx
*******************************************************************************/
// LAMP ON/OFF
Serial.print(F("bytes[3] bit0 Lamp: "));
switch (bytes[3]& B00000001) {
case B00000000:
Serial.println(F("Off"));
break;
case B00000001:
Serial.println(F("On"));
break;
default:
Serial.println(F("Unknown"));
}
// HOLD ON/OFF
Serial.print(F("bytes[3] bit2 Hold: "));
switch (bytes[3]& B00000100) {
case B00000000:
Serial.println(F("Off"));
break;
case B00000100:
Serial.println(F("On"));
break;
default:
Serial.println(F("Unknown"));
}
// TURBO ON/OFF
Serial.print(F("bytes[3] bit3 Turbo: "));
switch (bytes[3]& B00001000) {
case B00000000:
Serial.println(F("Off"));
break;
case B00001000:
Serial.println(F("On"));
break;
default:
Serial.println(F("Unknown"));
}
/********************************************************************************
* Byte[05]: Button pressed
* 0x00: POWER
* 0x01: MODE
* 0x02: Temperature Up
* 0x03: Temperature Down
* 0x04: Vertical Swing
* 0x05: FAN
* 0x06: TIMER
* 0x07: Horizontal swing
* 0x08: HOLD
* 0x09: SLEEP
* 0x0A: TURBO
* 0x0B: LAMP
*******************************************************************************/
Serial.print(F("bytes[5] Button pressed: "));
switch (bytes[5]) {
case 0x00:
Serial.println(F("POWER"));
break;
case 0x01:
Serial.println(F("MODE"));
break;
case 0x02:
Serial.println(F("TEMP UP"));
break;
case 0x03:
Serial.println(F("TEMP DOWN"));
break;
case 0x04:
Serial.println(F("SWING (vertical)"));
break;
case 0x05:
Serial.println(F("FAN SPEED"));
break;
case 0x06:
Serial.println(F("TIMER"));
break;
case 0x07:
Serial.println(F("AIR FLOW (horizontal)"));
break;
case 0x08:
Serial.println(F("HOLD"));
break;
case 0x09:
Serial.println(F("SLEEP"));
break;
case 0x0A:
Serial.println(F("TURBO"));
break;
case 0x0B:
Serial.println(F("LAMP"));
break;
default:
Serial.println(F("Unknown"));
}
/********************************************************************************
* Byte[07]: POWER, FAN, SLEEP, HORIZONTAL, VERTICAL
* SLEEP ON: Bxxxxxxx1 (LSB)
* SLEEP OFF: Bxxxxxxx0
* POWER ON: Bxxxxxx1x
* POWER OFF: Bxxxxxx0x
* VERTICAL SWING: Bxxxx01xx
* VERTICAL WIND: Bxxxx00xx
* VERTICAL FIXED: Bxxxx10xx
* HORIZONTAL SWING: Bxxx0xxxx
* HORIZONTAL OFF: Bxxx1xxxx
* FAN AUTO: Bx00xxxxx
* FAN3: Bx01xxxxx
* FAN2: Bx10xxxxx
* FAN1: Bx11xxxxx
*******************************************************************************/
// SLEEP ON/OFF
Serial.print(F("bytes[7] bit0 Sleep: "));
switch (bytes[7]& B00000001) {
case B00000000:
Serial.println(F("Off"));
break;
case B00000001:
Serial.println(F("On"));
break;
default:
Serial.println(F("Unknown"));
}
// POWER ON/OFF
Serial.print(F("bytes[7] bit1 Power: "));
switch (bytes[7]& B00000010) {
case B00000000:
Serial.println(F("Off"));
break;
case B00000010:
Serial.println(F("On"));
break;
default:
Serial.println(F("Unknown"));
}
// Vertical air swing
Serial.print(F("bytes[7] bit2-3 Vertical: "));
switch (bytes[7] & B00001100) {
case B00000100:
Serial.println(F("Swing"));
break;
case 0x00:
Serial.println(F("Wind"));
break;
case B00001000:
Serial.println(F("Fixed"));
break;
default:
Serial.println(F("Unknown"));
}
// Air flow (Horizontal) ON/OFF
Serial.print(F("bytes[7] bit4 Air flow: "));
switch (bytes[7]& B00010000) {
case B00000000:
Serial.println(F("Swing"));
break;
case B00010000:
Serial.println(F("Fixed"));
break;
default:
Serial.println(F("Unknown"));
}
// Fan Speed
Serial.print(F("bytes[7] bit5-6 Fan Speed: "));
switch (bytes[7] & B01100000) {
case B00000000:
Serial.println(F("Auto"));
break;
case B00100000:
Serial.println(F("3"));
break;
case B01000000:
Serial.println(F("2"));
break;
case B01100000:
Serial.println(F("1"));
break;
default:
Serial.println(F("Unknown"));
}
/********************************************************************************
* Byte[09]: Mode, Temperature
* MODE AUTO: B000xxxxx
* MODE COOL: B001xxxxx
* MODE VENT: B011xxxxx
* MODE DRY: B010xxxxx
* MODE HEAT: B100xxxxx
* Temperature is determined by bit0-4:
* 0x00 = 16C
* 0x10 = 32C
*******************************************************************************/
// MODE
Serial.print(F("bytes[9] bit5-7 Mode: "));
switch (bytes[9] & B11100000) {
case 0x00:
Serial.println(F("Auto"));
break;
case B00100000:
Serial.println(F("Cool"));
break;
case B01100000:
Serial.println(F("Ventilate"));
break;
case B01000000:
Serial.println(F("Dry"));
break;
case B10000000:
Serial.println(F("Heat"));
break;
default:
Serial.println("Unknown");
}
//Temperature
Serial.print("Bytes[9] Temperature: ");
Serial.print((bytes[9] & B00011111)+16);
Serial.println("°C");
// Checksum
bool checksum = true;
for (int i = 0; i < 12; i+=2) {
checksum &= (bytes[i] + bytes[i+1] == 255);
}
Serial.println(checksum?"Checksum: MATCHES":"Checksum: DOES NOT MATCH");
return true;
}
return false;
}