-
Notifications
You must be signed in to change notification settings - Fork 2
/
ErriezOregonTHN128Receive.h
112 lines (103 loc) · 3.26 KB
/
ErriezOregonTHN128Receive.h
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
/*
* MIT License
*
* Copyright (c) 2020-2022 Erriez
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*!
* \file ErriezOregonTHN128Receive.h
* \brief Oregon THN128 433MHz temperature receive library for Arduino
* \details
* Source: https://github.com/Erriez/ErriezOregonTHN128
* Documentation: https://erriez.github.io/ErriezOregonTHN128
*
* Protocol:
*
* Transmit temperature twice every 30 seconds:
*
* Bit: 0 7 0 7 0 7 0 7
* +----+----+------+------+------+------+ +----+----+------+--
* |PREA|SYNC|Byte 0|Byte 1|Byte 2|Byte 3| |PREA|SYNC|Byte 0| ...
* +----+----+------+------+------+------+----/\/----+----+----+------+--
* |<--------------- 144ms ------------->|<- 100ms ->| 30 sec
*
*
* Logic '0': Logic '1':
* +----+ +----+
* | |
* +----+ +----+
* 1400 1500 1500 1400 (us)
*
*
* PREA: Preamble 12x logic '1', 3000us low
* SYNC:
* +--------+
* | |
* + +--------+
* 5500us 5500us
*
* Byte 0:
* - Bit 0..3: Rolling address (Random value after power cycle)
* - Bit 6..7: Channel: (0 = channel 1 .. 2 = channel 3)
*
* Byte 1:
* - Bit 0..3: TH3
* - Bit 4..7: TH2
*
* Byte 2:
* - Bit 0..3: TH1
* - Bit 5: Sign
* - Bit 7: Low battery
*
* Byte 3:
* - Bit 0..7: CRC
*
* Example: Rolling address = 5, channel = 1, temperature = 27.8 `C, low battery = false
* TH1 = 2, TH2 = 7, TH3 = 8:
* Byte 0: 0x05
* Byte 1: 0x78
* Byte 2: 0x02
* Byte 3: 0x7f
*
* Bits in time:
* PRE=1 S B0=0x05 B1=0x78 B2=0x02 B3=0x7f
* 111111111111 S 10100000 00011110 01000000 11111110
*/
#ifndef ERRIEZ_OREGON_THN128_RECEIVER_H_
#define ERRIEZ_OREGON_THN128_RECEIVER_H_
#include <stdint.h>
#include "ErriezOregonTHN128.h"
// Macro IRAM_ATTR is defined for ESP pin interrupts
#ifndef IRAM_ATTR
#define IRAM_ATTR
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Public functions */
void OregonTHN128_RxBegin(uint8_t extIntPin);
void OregonTHN128_RxEnable();
void OregonTHN128_RxDisable();
bool OregonTHN128_Available(void);
bool OregonTHN128_Read(OregonTHN128Data_t *data);
#ifdef __cplusplus
}
#endif
#endif /* ERRIEZ_OREGON_THN128_RECEIVER_H_ */