Skip to content

Commit 7ee3950

Browse files
committed
Merge pull request arduino#321 from Mickaelh51/development
Add Oregon decoder library
2 parents ebf183c + 2af93cf commit 7ee3950

File tree

10 files changed

+845
-0
lines changed

10 files changed

+845
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/**
2+
* The MySensors Arduino library handles the wireless radio link and protocol
3+
* between your home built sensors/actuators and HA controller of choice.
4+
* The sensors forms a self healing radio network with optional repeaters. Each
5+
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
6+
* network topology allowing messages to be routed to nodes.
7+
*
8+
* Created by Henrik Ekblad <[email protected]>
9+
* Copyright (C) 2013-2015 Sensnology AB
10+
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
11+
*
12+
* Documentation: http://www.mysensors.org
13+
* Support Forum: http://forum.mysensors.org
14+
*
15+
* This program is free software; you can redistribute it and/or
16+
* modify it under the terms of the GNU General Public License
17+
* version 2 as published by the Free Software Foundation.
18+
*
19+
*******************************
20+
*
21+
* REVISION HISTORY
22+
* WARNING: I use MySensors V1.6.0 (dev branch) (https://github.com/mysensors/Arduino/tree/development/libraries)
23+
*
24+
* Version 1.0 - Hubert Mickael <[email protected]> (https://github.com/Mickaelh51)
25+
* - Clean ino code
26+
* - Add MY_DEBUG mode in library
27+
* Version 0.2 (Beta 2) - Hubert Mickael <[email protected]> (https://github.com/Mickaelh51)
28+
* - Auto detect Oregon 433Mhz
29+
* - Add battery level
30+
* - etc ...
31+
* Version 0.1 (Beta 1) - Hubert Mickael <[email protected]> (https://github.com/Mickaelh51)
32+
*
33+
*******************************
34+
* DESCRIPTION
35+
* This sketch provides an example how to implement a humidity/temperature from Oregon sensor.
36+
* - Oregon sensor's battery level
37+
* - Oregon sensor's id
38+
* - Oregon sensor's type
39+
* - Oregon sensor's channel
40+
* - Oregon sensor's temperature
41+
* - Oregon sensor's humidity
42+
*
43+
* MySensors gateway <=======> Arduino UNO <-- (PIN 2) --> 433Mhz receiver <=============> Oregon sensors
44+
*/
45+
46+
// Enable debug prints
47+
#define MY_DEBUG
48+
49+
#define MY_NODE_ID 10
50+
51+
// Enable and select radio type attached
52+
#define MY_RADIO_NRF24
53+
//#define MY_RADIO_RFM69
54+
55+
#include <SPI.h>
56+
#include <MySensor.h>
57+
#include <Oregon.h>
58+
59+
//Define pin where is 433Mhz receiver (here, pin 2)
60+
#define MHZ_RECEIVER_PIN 2
61+
//Define maximum Oregon sensors (here, 3 differents sensors)
62+
#define COUNT_OREGON_SENSORS 3
63+
64+
#define CHILD_ID_HUM 0
65+
#define CHILD_ID_TEMP 1
66+
#define CHILD_ID_BAT 2
67+
68+
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
69+
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
70+
MyMessage msgBat(CHILD_ID_BAT, V_VAR1);
71+
72+
void setup ()
73+
{
74+
75+
Serial.println("Setup started");
76+
77+
//Setup received data
78+
attachInterrupt(digitalPinToInterrupt(MHZ_RECEIVER_PIN), ext_int_1, CHANGE);
79+
80+
Serial.println("Setup completed");
81+
}
82+
83+
void presentation()
84+
{
85+
// Send the Sketch Version Information to the Gateway
86+
sendSketchInfo("Oregon Sensor", "1.0");
87+
88+
// Present all sensors to controller
89+
for (int i=0; i<COUNT_OREGON_SENSORS; i++) {
90+
present(i, S_TEMP);
91+
present(i, S_HUM);
92+
present(i, S_CUSTOM); //battery level
93+
}
94+
}
95+
96+
97+
98+
void loop () {
99+
//------------------------------------------
100+
//Start process new data from Oregon sensors
101+
//------------------------------------------
102+
cli();
103+
word p = pulse;
104+
pulse = 0;
105+
sei();
106+
if (p != 0)
107+
{
108+
if (orscV2.nextPulse(p))
109+
{
110+
//Decode Hex Data once
111+
const byte* DataDecoded = DataToDecoder(orscV2);
112+
//Find or save Oregon sensors's ID
113+
int SensorID = FindSensor(id(DataDecoded),COUNT_OREGON_SENSORS);
114+
115+
// just for DEBUG
116+
OregonType(DataDecoded);
117+
channel(DataDecoded);
118+
119+
//Send messages to MySenors Gateway
120+
send(msgTemp.setSensor(SensorID).set(temperature(DataDecoded), 1));
121+
send(msgHum.setSensor(SensorID).set(humidity(DataDecoded), 1));
122+
send(msgBat.setSensor(SensorID).set(battery(DataDecoded), 1));
123+
}
124+
125+
}
126+
}

libraries/Oregon/INSTALL.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
With git:
2+
1) git clone https://github.com/Mickaelh51/Arduino-Oregon-Library.git Oregon
3+
2) Put the "Oregon" folder in your Arduino "libraries" folder.
4+
5+
Direct download:
6+
1) Download https://github.com/Mickaelh51/Arduino-Oregon-Library/archive/master.zip
7+
2) Extract master.zip
8+
3) rename folder: mv Arduino-Oregon-Library-master Oregon
9+
4) Put the "Oregon" folder in your Arduino "libraries" folder.

libraries/Oregon/LICENSE.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
##The MIT License (MIT)
2+
3+
####Copyright (c) 2015: Mickael Hubert, Dominique Pierre, Olivier Lebrun
4+
5+
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:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
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.

libraries/Oregon/README.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Arduino Oregon Library:
2+
##Tested Hardware:
3+
- Arduino UNO
4+
- 433Mhz receiver (connected on digital pin 2)
5+
- Oregon sensors THGR228N
6+
7+
## Example without MySensors:
8+
Serial output:
9+
```
10+
Brute Hexadecimal data from sensor:
11+
1A2D10E2711860043CDA
12+
Oregon ID: 226 Hexadecimal: E2
13+
Sensor ID: 226 has been find in position EEPROM: 0
14+
Oregon model: THGR228N
15+
Oregon channel: 1
16+
Oregon temperature: 18.70
17+
Oregon humidity: 46
18+
Oregon battery level: 90
19+
20+
----
21+
22+
Brute Hexadecimal data from sensor:
23+
1A2D10B4201340052F43
24+
Oregon ID: 180 Hexadecimal: B4
25+
Sensor ID: 180 has been find in position EEPROM: 1
26+
Oregon model: THGR228N
27+
Oregon channel: 1
28+
Oregon temperature: 13.20
29+
Oregon humidity: 54
30+
Oregon battery level: 90
31+
```
32+
33+
## Example with MySensors library (www.mysensors.org):
34+
Serial output:
35+
```
36+
Brute Hexadecimal data from sensor:
37+
1A2D10E2711860043CDA
38+
Oregon ID: 226 Hexadecimal: E2
39+
Sensor ID: 226 has been find in position EEPROM: 0
40+
Oregon model: THGR228N
41+
Oregon channel: 1
42+
Oregon temperature: 18.70
43+
send: 10-10-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:18.7
44+
Oregon humidity: 46
45+
send: 10-10-0-0 s=0,c=1,t=1,pt=7,l=5,sg=0,st=ok:46.0
46+
Oregon battery level: 90
47+
send: 10-10-0-0 s=0,c=1,t=24,pt=7,l=5,sg=0,st=ok:90.0
48+
49+
----
50+
51+
Brute Hexadecimal data from sensor:
52+
1A2D10B4201340052F43
53+
Oregon ID: 180 Hexadecimal: B4
54+
Sensor ID: 180 has been find in position EEPROM: 1
55+
Oregon model: THGR228N
56+
Oregon channel: 1
57+
Oregon temperature: 13.20
58+
send: 10-10-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=ok:13.2
59+
Oregon humidity: 54
60+
send: 10-10-0-0 s=1,c=1,t=1,pt=7,l=5,sg=0,st=ok:54.0
61+
Oregon battery level: 90
62+
send: 10-10-0-0 s=1,c=1,t=24,pt=7,l=5,sg=0,st=ok:90.0
63+
```
64+
## Result on OpenHAB controller (With MySensors)
65+
![Logo](http://i.imgur.com/Tsne6yv.png)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/**
2+
* The MySensors Arduino library handles the wireless radio link and protocol
3+
* between your home built sensors/actuators and HA controller of choice.
4+
* The sensors forms a self healing radio network with optional repeaters. Each
5+
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
6+
* network topology allowing messages to be routed to nodes.
7+
*
8+
* Created by Henrik Ekblad <[email protected]>
9+
* Copyright (C) 2013-2015 Sensnology AB
10+
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
11+
*
12+
* Documentation: http://www.mysensors.org
13+
* Support Forum: http://forum.mysensors.org
14+
*
15+
* This program is free software; you can redistribute it and/or
16+
* modify it under the terms of the GNU General Public License
17+
* version 2 as published by the Free Software Foundation.
18+
*
19+
*******************************
20+
*
21+
* REVISION HISTORY
22+
* WARNING: I use MySensors V1.6.0 (dev branch) (https://github.com/mysensors/Arduino/tree/development/libraries)
23+
*
24+
* Version 1.0 - Hubert Mickael <[email protected]> (https://github.com/Mickaelh51)
25+
* - Clean ino code
26+
* - Add MY_DEBUG mode in library
27+
* Version 0.2 (Beta 2) - Hubert Mickael <[email protected]> (https://github.com/Mickaelh51)
28+
* - Auto detect Oregon 433Mhz
29+
* - Add battery level
30+
* - etc ...
31+
* Version 0.1 (Beta 1) - Hubert Mickael <[email protected]> (https://github.com/Mickaelh51)
32+
*
33+
*******************************
34+
* DESCRIPTION
35+
* This sketch provides an example how to implement a humidity/temperature from Oregon sensor.
36+
* - Oregon sensor's battery level
37+
* - Oregon sensor's id
38+
* - Oregon sensor's type
39+
* - Oregon sensor's channel
40+
* - Oregon sensor's temperature
41+
* - Oregon sensor's humidity
42+
*
43+
* MySensors gateway <=======> Arduino UNO <-- (PIN 2) --> 433Mhz receiver <=============> Oregon sensors
44+
*/
45+
46+
// Enable debug prints
47+
#define MY_DEBUG
48+
49+
#define MY_NODE_ID 10
50+
51+
// Enable and select radio type attached
52+
#define MY_RADIO_NRF24
53+
//#define MY_RADIO_RFM69
54+
55+
#include <SPI.h>
56+
#include <MySensor.h>
57+
#include <Oregon.h>
58+
59+
//Define pin where is 433Mhz receiver (here, pin 2)
60+
#define MHZ_RECEIVER_PIN 2
61+
//Define maximum Oregon sensors (here, 3 differents sensors)
62+
#define COUNT_OREGON_SENSORS 3
63+
64+
#define CHILD_ID_HUM 0
65+
#define CHILD_ID_TEMP 1
66+
#define CHILD_ID_BAT 2
67+
68+
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
69+
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
70+
MyMessage msgBat(CHILD_ID_BAT, V_VAR1);
71+
72+
void setup ()
73+
{
74+
75+
Serial.println("Setup started");
76+
77+
//Setup received data
78+
attachInterrupt(digitalPinToInterrupt(MHZ_RECEIVER_PIN), ext_int_1, CHANGE);
79+
80+
Serial.println("Setup completed");
81+
}
82+
83+
void presentation()
84+
{
85+
// Send the Sketch Version Information to the Gateway
86+
sendSketchInfo("Oregon Sensor", "1.0");
87+
88+
// Present all sensors to controller
89+
for (int i=0; i<COUNT_OREGON_SENSORS; i++) {
90+
present(i, S_TEMP);
91+
present(i, S_HUM);
92+
present(i, S_CUSTOM); //battery level
93+
}
94+
}
95+
96+
97+
98+
void loop () {
99+
//------------------------------------------
100+
//Start process new data from Oregon sensors
101+
//------------------------------------------
102+
cli();
103+
word p = pulse;
104+
pulse = 0;
105+
sei();
106+
if (p != 0)
107+
{
108+
if (orscV2.nextPulse(p))
109+
{
110+
//Decode Hex Data once
111+
const byte* DataDecoded = DataToDecoder(orscV2);
112+
//Find or save Oregon sensors's ID
113+
int SensorID = FindSensor(id(DataDecoded),COUNT_OREGON_SENSORS);
114+
115+
// just for DEBUG
116+
OregonType(DataDecoded);
117+
channel(DataDecoded);
118+
119+
//Send messages to MySenors Gateway
120+
send(msgTemp.setSensor(SensorID).set(temperature(DataDecoded), 1));
121+
send(msgHum.setSensor(SensorID).set(humidity(DataDecoded), 1));
122+
send(msgBat.setSensor(SensorID).set(battery(DataDecoded), 1));
123+
}
124+
125+
}
126+
}

0 commit comments

Comments
 (0)